From f0e8e6bce48a5434cd514df16aa280e5e427f77c Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 3 Dec 2022 18:45:24 -0800 Subject: [PATCH] Hide share button if unavailable (closes #9175) --- packages/client/src/pages/gallery/post.vue | 3 ++- packages/client/src/pages/page.vue | 3 ++- packages/client/src/scripts/get-note-menu.ts | 5 +++-- packages/client/src/scripts/share-available.ts | 6 ++++++ 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 packages/client/src/scripts/share-available.ts diff --git a/packages/client/src/pages/gallery/post.vue b/packages/client/src/pages/gallery/post.vue index 43d3651b81..a4be9e85fa 100644 --- a/packages/client/src/pages/gallery/post.vue +++ b/packages/client/src/pages/gallery/post.vue @@ -24,7 +24,7 @@
- +
@@ -67,6 +67,7 @@ import { url } from '@/config'; import { useRouter } from '@/router'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; +import { shareAvailable } from '@/scripts/share-available'; const router = useRouter(); diff --git a/packages/client/src/pages/page.vue b/packages/client/src/pages/page.vue index 2497db950e..e89fd3e2a8 100644 --- a/packages/client/src/pages/page.vue +++ b/packages/client/src/pages/page.vue @@ -34,7 +34,7 @@
- +
@@ -81,6 +81,7 @@ import MkPagination from '@/components/MkPagination.vue'; import MkPagePreview from '@/components/MkPagePreview.vue'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; +import { shareAvailable } from '@/scripts/share-available'; const props = defineProps<{ pageName: string; diff --git a/packages/client/src/scripts/get-note-menu.ts b/packages/client/src/scripts/get-note-menu.ts index 9c52b2e242..e17ade59c0 100644 --- a/packages/client/src/scripts/get-note-menu.ts +++ b/packages/client/src/scripts/get-note-menu.ts @@ -8,6 +8,7 @@ import * as os from '@/os'; import copyToClipboard from '@/scripts/copy-to-clipboard'; import { url } from '@/config'; import { noteActions } from '@/store'; +import { shareAvailable } from '@/scripts/share-available'; export function getNoteMenu(props: { note: misskey.entities.Note; @@ -220,11 +221,11 @@ export function getNoteMenu(props: { window.open(appearNote.url || appearNote.uri, '_blank'); }, } : undefined, - { + shareAvailable() ? { icon: 'ph-share-network-bold ph-lg', text: i18n.ts.share, action: share, - }, + } : undefined, instance.translatorAvailable ? { icon: 'ph-translate-bold ph-lg', text: i18n.ts.translate, diff --git a/packages/client/src/scripts/share-available.ts b/packages/client/src/scripts/share-available.ts new file mode 100644 index 0000000000..8056d6dc2e --- /dev/null +++ b/packages/client/src/scripts/share-available.ts @@ -0,0 +1,6 @@ +export function shareAvailable(): boolean { + if (navigator.share) { + return true; + } + return false; +}