Hide share button if unavailable (closes #9175)

This commit is contained in:
ThatOneCalculator 2022-12-03 18:45:24 -08:00
parent 0683529145
commit f0e8e6bce4
4 changed files with 13 additions and 4 deletions

View File

@ -24,7 +24,7 @@
<div class="other"> <div class="other">
<button v-if="$i && $i.id === post.user.id" v-tooltip="i18n.ts.edit" v-click-anime class="_button" @click="edit"><i class="ph-pencil-bold ph-lg ph-fw ph-lg"></i></button> <button v-if="$i && $i.id === post.user.id" v-tooltip="i18n.ts.edit" v-click-anime class="_button" @click="edit"><i class="ph-pencil-bold ph-lg ph-fw ph-lg"></i></button>
<button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ph-repeat-bold ph-lg ph-fw ph-lg"></i></button> <button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ph-repeat-bold ph-lg ph-fw ph-lg"></i></button>
<button v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network-bold ph-lg ph-fw ph-lg"></i></button> <button v-if="shareAvailable()" v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network-bold ph-lg ph-fw ph-lg"></i></button>
</div> </div>
</div> </div>
<div class="user"> <div class="user">
@ -67,6 +67,7 @@ import { url } from '@/config';
import { useRouter } from '@/router'; import { useRouter } from '@/router';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import { shareAvailable } from '@/scripts/share-available';
const router = useRouter(); const router = useRouter();

View File

@ -34,7 +34,7 @@
</div> </div>
<div class="other"> <div class="other">
<button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ph-repeat-bold ph-lg ph-fw ph-lg"></i></button> <button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ph-repeat-bold ph-lg ph-fw ph-lg"></i></button>
<button v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network-bold ph-lg ph-fw ph-lg"></i></button> <button v-if="shareAvailable()" v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network-bold ph-lg ph-fw ph-lg"></i></button>
</div> </div>
<div class="user"> <div class="user">
<MkAvatar :user="page.user" class="avatar"/> <MkAvatar :user="page.user" class="avatar"/>
@ -81,6 +81,7 @@ import MkPagination from '@/components/MkPagination.vue';
import MkPagePreview from '@/components/MkPagePreview.vue'; import MkPagePreview from '@/components/MkPagePreview.vue';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import { shareAvailable } from '@/scripts/share-available';
const props = defineProps<{ const props = defineProps<{
pageName: string; pageName: string;

View File

@ -8,6 +8,7 @@ import * as os from '@/os';
import copyToClipboard from '@/scripts/copy-to-clipboard'; import copyToClipboard from '@/scripts/copy-to-clipboard';
import { url } from '@/config'; import { url } from '@/config';
import { noteActions } from '@/store'; import { noteActions } from '@/store';
import { shareAvailable } from '@/scripts/share-available';
export function getNoteMenu(props: { export function getNoteMenu(props: {
note: misskey.entities.Note; note: misskey.entities.Note;
@ -220,11 +221,11 @@ export function getNoteMenu(props: {
window.open(appearNote.url || appearNote.uri, '_blank'); window.open(appearNote.url || appearNote.uri, '_blank');
}, },
} : undefined, } : undefined,
{ shareAvailable() ? {
icon: 'ph-share-network-bold ph-lg', icon: 'ph-share-network-bold ph-lg',
text: i18n.ts.share, text: i18n.ts.share,
action: share, action: share,
}, } : undefined,
instance.translatorAvailable ? { instance.translatorAvailable ? {
icon: 'ph-translate-bold ph-lg', icon: 'ph-translate-bold ph-lg',
text: i18n.ts.translate, text: i18n.ts.translate,

View File

@ -0,0 +1,6 @@
export function shareAvailable(): boolean {
if (navigator.share) {
return true;
}
return false;
}