Skip to content

Commit

Permalink
allow clicking on notification to open url
Browse files Browse the repository at this point in the history
  • Loading branch information
iiPythonx committed Mar 28, 2024
1 parent 842e5ff commit ef58851
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
"allowDownloading": "allow downloading",
"description": "description",
"setExpiration": "set expiration",
"success": "share link copied to clipboard",
"success": "share link copied to clipboard (or click here to open)",
"expireInvalid": "expiration must be in the future",
"createFailed": "failed to create share (is sharing enabled?)"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,25 @@ export const ShareItemContextModal = ({
onSuccess: (_data) => {
if (!server) throw new Error('Server not found');
if (!_data?.id) throw new Error('Failed to share item');
navigator.clipboard.writeText(`${server.url}/share/${_data.id}`);

const shareUrl = `${server.url}/share/${_data.id}`;

navigator.clipboard.writeText(shareUrl);
toast.success({
autoClose: 5000,
id: 'share-item-toast',
message: t('form.shareItem.success', {
postProcess: 'sentenceCase',
}),
onClick: (a) => {
if (!(a.target instanceof HTMLElement)) return;

// Make sure we weren't clicking close (otherwise clicking close /also/ opens the url)
if (a.target.nodeName !== 'svg') {
window.open(shareUrl);
toast.hide('share-item-toast');
}
},
});
},
},
Expand Down

0 comments on commit ef58851

Please sign in to comment.