Skip to content

Commit

Permalink
Release v1.0.1 (#382)
Browse files Browse the repository at this point in the history
* Feature: Replace OG image (#380)

* Fix:copy link not working on mobile (#378)

* fix: add await

* chore: move the return keyword

* fix: put fetch function when the dialog open

* chore: reset the hash state when copy button clicked

* docs: modify the documentation

* chore: typo

* fix: update based on given feedback

---------

Co-authored-by: Nick Ito <[email protected]>

---------

Co-authored-by: ShoeheyOt <[email protected]>
  • Loading branch information
nick-y-ito and ShoeheyOt authored Mar 27, 2024
1 parent c728648 commit 2b6d2cf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
Binary file added public/images/og.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/og.png
Binary file not shown.
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const metadata: Metadata = {
url: APP_CONST.BASE_URL,
images: [
{
url: `${APP_CONST.BASE_URL}/images/og.png?v=0`,
url: `${APP_CONST.BASE_URL}/images/og.jpg?v=0`,
width: 1200,
height: 630,
alt: APP_CONST.NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,43 @@ export const InviteMemberDialogContent = ({
groupId,
}: IInviteMemberDialogContentProps) => {
const [isLinkButtonClicked, setIsLinkButtonClicked] = useState(false);
const [hash, setHash] = useState('');

/**
* This useEffect has two dependencies. When one of them,`isDialogOpen` state, is changed to true, the setup is fired
* which is generating the invitation link hash and put it as state `hash`
*/
useEffect(() => {
const getHash = async () => {
if (!isDialogOpen) return;

const result = await putGenerateInvitationLinkHash(groupId);
if (!result.ok) {
alert('Something went wrong. Please try again');
return;
}
setHash(result.value.invitationLinkHash);
};

getHash();
}, [isDialogOpen, groupId]);
/**
* Handle the link copy button click.
* If the generatedLink is not valid, do nothing.
* If success, generated invitation link URL is copied to clipboard and change the text of button to 'Copied!'
* *A hash, which is part of the URL, is already generated when the dialog open
*/
const handleLinkCopy = async () => {
setIsLinkButtonClicked(true);
const result = await putGenerateInvitationLinkHash(groupId);

if (!result.ok) {
alert('Something went wrong. Please try again');
return;
try {
if (!hash) throw new Error('Invitation link hash is not set.');
return await navigator.clipboard.writeText(`${CLIENT_BASE_URL}/groups/join/${hash}`);
} catch (err) {
console.error(
'Error occurred while copying the link:',
err instanceof Error ? err.message : err,
);
alert('Error occurred while copying the link. Please try again.');
}

const hash = result.value.invitationLinkHash;
navigator.clipboard.writeText(`${CLIENT_BASE_URL}/groups/join/${hash}`);
return;
};

Expand Down

0 comments on commit 2b6d2cf

Please sign in to comment.