Share dropdown w/ remote copy

This commit is contained in:
Freeplay 2023-06-19 16:50:51 -04:00
parent 8281817c0f
commit d830a6dad3
1 changed files with 64 additions and 36 deletions

View File

@ -108,6 +108,11 @@ export function getNoteMenu(props: {
os.success(); os.success();
} }
function copyOriginal(): void {
copyToClipboard(appearNote.url ?? appearNote.uri);
os.success();
}
function togglePin(pin: boolean): void { function togglePin(pin: boolean): void {
os.apiWithDialog( os.apiWithDialog(
pin ? "i/pin" : "i/unpin", pin ? "i/pin" : "i/unpin",
@ -263,32 +268,6 @@ export function getNoteMenu(props: {
null, null,
] ]
: []), : []),
{
icon: "ph-clipboard-text ph-bold ph-lg",
text: i18n.ts.copyContent,
action: copyContent,
},
{
icon: "ph-link-simple ph-bold ph-lg",
text: i18n.ts.copyLink,
action: copyLink,
},
appearNote.url || appearNote.uri
? {
icon: "ph-arrow-square-out ph-bold ph-lg",
text: i18n.ts.showOnRemote,
action: () => {
window.open(appearNote.url || appearNote.uri, "_blank");
},
}
: undefined,
shareAvailable()
? {
icon: "ph-share-network ph-bold ph-lg",
text: i18n.ts.share,
action: share,
}
: undefined,
instance.translatorAvailable instance.translatorAvailable
? { ? {
icon: "ph-translate ph-bold ph-lg", icon: "ph-translate ph-bold ph-lg",
@ -296,7 +275,6 @@ export function getNoteMenu(props: {
action: translate, action: translate,
} }
: undefined, : undefined,
null,
statePromise.then((state) => statePromise.then((state) =>
state?.isFavorited state?.isFavorited
? { ? {
@ -356,6 +334,44 @@ export function getNoteMenu(props: {
action: () => togglePin(true), action: () => togglePin(true),
} }
: undefined, : undefined,
appearNote.url || appearNote.uri
? {
icon: "ph-arrow-square-out ph-bold ph-lg",
text: i18n.ts.showOnRemote,
action: () => {
window.open(appearNote.url || appearNote.uri, "_blank");
},
}
: undefined,
{
type: "parent",
icon: "ph-share-network ph-bold ph-lg",
text: i18n.ts.share,
children: [
{
icon: "ph-clipboard-text ph-bold ph-lg",
text: i18n.ts.copyContent,
action: copyContent,
},
{
icon: "ph-link-simple ph-bold ph-lg",
text: i18n.ts.copyLink,
action: copyLink,
},
appearNote.url || appearNote.uri ? {
icon: "ph-link-simple ph-bold ph-lg",
text: `${i18n.ts.copyLink} (${i18n.ts.remote})`,
action: copyOriginal,
} : undefined,
shareAvailable()
? {
icon: "ph-share-network ph-bold ph-lg",
text: i18n.ts.share,
action: share,
}
: undefined,
]
},
/* /*
...($i.isModerator || $i.isAdmin ? [ ...($i.isModerator || $i.isAdmin ? [
null, null,
@ -424,6 +440,15 @@ export function getNoteMenu(props: {
].filter((x) => x !== undefined); ].filter((x) => x !== undefined);
} else { } else {
menu = [ menu = [
appearNote.url || appearNote.uri
? {
icon: "ph-arrow-square-out ph-bold ph-lg",
text: i18n.ts.showOnRemote,
action: () => {
window.open(appearNote.url || appearNote.uri, "_blank");
},
}
: undefined,
{ {
icon: "ph-clipboard-text ph-bold ph-lg", icon: "ph-clipboard-text ph-bold ph-lg",
text: i18n.ts.copyContent, text: i18n.ts.copyContent,
@ -434,13 +459,16 @@ export function getNoteMenu(props: {
text: i18n.ts.copyLink, text: i18n.ts.copyLink,
action: copyLink, action: copyLink,
}, },
appearNote.url || appearNote.uri appearNote.url || appearNote.uri ? {
icon: "ph-link-simple ph-bold ph-lg",
text: `${i18n.ts.copyLink} (${i18n.ts.remote})`,
action: copyOriginal,
} : undefined,
shareAvailable()
? { ? {
icon: "ph-arrow-square-out ph-bold ph-lg", icon: "ph-share-network ph-bold ph-lg",
text: i18n.ts.showOnRemote, text: i18n.ts.share,
action: () => { action: share,
window.open(appearNote.url || appearNote.uri, "_blank");
},
} }
: undefined, : undefined,
].filter((x) => x !== undefined); ].filter((x) => x !== undefined);