Skip to content

Commit

Permalink
use twitter handle in shares
Browse files Browse the repository at this point in the history
  • Loading branch information
codyzu committed Jul 3, 2023
1 parent 640da45 commit c17510f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions functions/src/presentation.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
export type Doc = {
id: string;
};

// TODO: use this when uploading
export type PresentationData = {
title: string;
thumb: string;
pages: string[];
notes: Note[];
uid: string;
username: string;
// TODO: use this in function metadata
twitterHandle: string;
thumbIndex?: number;
};
export type PresentationDoc = Doc & PresentationData;
Expand Down
17 changes: 14 additions & 3 deletions src/components/Shares.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ export default function Shares({
slideIndex + 1
}`;

const tweetText = `${presentation?.title ?? 'preentation'}${
presentation?.username === undefined ? '' : ' by ' + presentation.username
} ${shareUrl}`;
const tweetText =
presentation === undefined
? ''
: `${
presentation.title.length > 0 ? presentation.title : 'presentation'
}${
presentation.username.length > 0 ? ' by ' + presentation.username : ''
}${
// TODO: make the twitter handle required in the rules and set it to an empty string on upload
// Then remove the ?? '' below
(presentation.twitterHandle ?? '').length > 0
? ' ' + presentation.twitterHandle
: ''
} ${shareUrl}`;

const [copied, setCopied] = useState(false);
useEffect(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/pages/Viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ export default function Viewer() {
<div>{presentation?.title ?? ''}</div>
{presentation && (
<div className="text-base">
by {presentation.username ?? 'Anonymous User'}
by{' '}
{presentation.username.length > 0
? presentation.username
: 'Anonymous User'}
</div>
)}
</div>
Expand Down

0 comments on commit c17510f

Please sign in to comment.