Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Jan 11, 2025
1 parent d338566 commit be57adb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
12 changes: 8 additions & 4 deletions src/components/compose-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ function SortablePost({ post, index, onTextChange, onRemove }) {
};

return (
<div ref={setNodeRef} style={style} className="flex gap-2 sm:px-4 -mx-4 sm:mx-0">
<div
ref={setNodeRef}
style={style}
className="flex gap-2 sm:px-4 -mx-4 sm:mx-0"
>
<div className="flex-none w-8">
<div
{...attributes}
Expand Down Expand Up @@ -77,8 +81,8 @@ function SortablePost({ post, index, onTextChange, onRemove }) {
</span>
<Button
onClick={() => onRemove(index)}
variant="destructive"
size="sm"
variant="destructive"
size="sm"
>
Remove
</Button>
Expand All @@ -96,7 +100,7 @@ export function ComposePost({ onSubmit }) {
useSensor(PointerSensor),
useSensor(KeyboardSensor, {
coordinateGetter: sortableKeyboardCoordinates,
})
}),
);

const [isThreadMode, setIsThreadMode] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function Home() {

return (
<main className="p-6">
{/* <TwitterApiNotice /> */}
{/* <TwitterApiNotice /> */}
{/* MAIN CONTENT */}

{!signedAccountId ? (
Expand Down
21 changes: 14 additions & 7 deletions src/services/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ export class TwitterService {
if (!credentials.clientId || !credentials.clientSecret) {
throw new Error("Twitter OAuth 2.0 credentials are required");
}

// OAuth 2.0 client for tweet operations
this.oauth2Client = new TwitterApi({
clientId: credentials.clientId,
clientSecret: credentials.clientSecret,
});

// OAuth 1.0a client for user operations if credentials are provided
if (credentials.apiKey && credentials.apiSecret && credentials.accessToken && credentials.accessSecret) {
if (
credentials.apiKey &&
credentials.apiSecret &&
credentials.accessToken &&
credentials.accessSecret
) {
this.oauth1Client = new TwitterApi({
appKey: credentials.apiKey,
appSecret: credentials.apiSecret,
Expand All @@ -41,10 +46,10 @@ export class TwitterService {

async getAuthLink(callbackUrl) {
// Use OAuth 2.0 with PKCE for more granular scope control
const { url, codeVerifier, state } = this.oauth2Client.generateOAuth2AuthLink(
callbackUrl,
{ scope: ["tweet.read", "tweet.write", "users.read"] },
);
const { url, codeVerifier, state } =
this.oauth2Client.generateOAuth2AuthLink(callbackUrl, {
scope: ["tweet.read", "tweet.write", "users.read"],
});
return { url, codeVerifier, state };
}

Expand Down Expand Up @@ -89,7 +94,9 @@ export class TwitterService {

async getUserInfo(accessToken) {
if (!this.oauth1Client) {
throw new Error("OAuth 1.0a credentials are required for user operations");
throw new Error(
"OAuth 1.0a credentials are required for user operations",
);
}

try {
Expand Down

0 comments on commit be57adb

Please sign in to comment.