Skip to content

Commit

Permalink
Add share feature
Browse files Browse the repository at this point in the history
  • Loading branch information
longern committed Dec 17, 2024
1 parent 034bd48 commit cccc5a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ function Main({
await fetch(`/webdav/${encodeKey(key)}`, { method: "DELETE" });
fetchFiles();
}}
onShare={() => {
if (multiSelected?.length !== 1) return;
const url = new URL(
`/webdav/${encodeKey(multiSelected[0])}`,
window.location.href
);
navigator.share({ url: url.toString() });
}}
/>
</React.Fragment>
);
Expand Down
4 changes: 3 additions & 1 deletion src/MultiSelectToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ function MultiSelectToolbar({
onDownload,
onRename,
onDelete,
onShare,
}: {
multiSelected: string[] | null;
onClose: () => void;
onDownload: () => void;
onRename: () => void;
onDelete: () => void;
onShare: () => void;
}) {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);

Expand Down Expand Up @@ -69,7 +71,7 @@ function MultiSelectToolbar({
{multiSelected.length === 1 && (
<React.Fragment>
<MenuItem onClick={onRename}>Rename</MenuItem>
<MenuItem>Share</MenuItem>
<MenuItem onClick={onShare}>Share</MenuItem>
</React.Fragment>
)}
</Menu>
Expand Down

0 comments on commit cccc5a8

Please sign in to comment.