forked from FoundKeyGang/FoundKey
parent
7e1ce04db8
commit
49a98b1eb0
1 changed files with 124 additions and 124 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { defineAsyncComponent, Ref, inject } from 'vue';
|
import { defineAsyncComponent, Ref, inject } from 'vue';
|
||||||
import * as misskey from 'misskey-js';
|
import * as misskey from 'misskey-js';
|
||||||
|
import { pleaseLogin } from './please-login';
|
||||||
import { $i } from '@/account';
|
import { $i } from '@/account';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { instance } from '@/instance';
|
import { instance } from '@/instance';
|
||||||
|
@ -7,7 +8,6 @@ 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 { pleaseLogin } from './please-login';
|
|
||||||
|
|
||||||
export function getNoteMenu(props: {
|
export function getNoteMenu(props: {
|
||||||
note: misskey.entities.Note;
|
note: misskey.entities.Note;
|
||||||
|
@ -34,7 +34,7 @@ export function getNoteMenu(props: {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|
||||||
os.api('notes/delete', {
|
os.api('notes/delete', {
|
||||||
noteId: appearNote.id
|
noteId: appearNote.id,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ export function getNoteMenu(props: {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|
||||||
os.api('notes/delete', {
|
os.api('notes/delete', {
|
||||||
noteId: appearNote.id
|
noteId: appearNote.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel });
|
os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel });
|
||||||
|
@ -56,19 +56,19 @@ export function getNoteMenu(props: {
|
||||||
|
|
||||||
function toggleFavorite(favorite: boolean): void {
|
function toggleFavorite(favorite: boolean): void {
|
||||||
os.apiWithDialog(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
|
os.apiWithDialog(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
|
||||||
noteId: appearNote.id
|
noteId: appearNote.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleWatch(watch: boolean): void {
|
function toggleWatch(watch: boolean): void {
|
||||||
os.apiWithDialog(watch ? 'notes/watching/create' : 'notes/watching/delete', {
|
os.apiWithDialog(watch ? 'notes/watching/create' : 'notes/watching/delete', {
|
||||||
noteId: appearNote.id
|
noteId: appearNote.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleThreadMute(mute: boolean): void {
|
function toggleThreadMute(mute: boolean): void {
|
||||||
os.apiWithDialog(mute ? 'notes/thread-muting/create' : 'notes/thread-muting/delete', {
|
os.apiWithDialog(mute ? 'notes/thread-muting/create' : 'notes/thread-muting/delete', {
|
||||||
noteId: appearNote.id
|
noteId: appearNote.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,12 +84,12 @@ export function getNoteMenu(props: {
|
||||||
|
|
||||||
function togglePin(pin: boolean): void {
|
function togglePin(pin: boolean): void {
|
||||||
os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', {
|
os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', {
|
||||||
noteId: appearNote.id
|
noteId: appearNote.id,
|
||||||
}, undefined, null, res => {
|
}, undefined, null, res => {
|
||||||
if (res.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
|
if (res.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
text: i18n.ts.pinLimitExceeded
|
text: i18n.ts.pinLimitExceeded,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -104,26 +104,26 @@ export function getNoteMenu(props: {
|
||||||
const { canceled, result } = await os.form(i18n.ts.createNewClip, {
|
const { canceled, result } = await os.form(i18n.ts.createNewClip, {
|
||||||
name: {
|
name: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
label: i18n.ts.name
|
label: i18n.ts.name,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: false,
|
required: false,
|
||||||
multiline: true,
|
multiline: true,
|
||||||
label: i18n.ts.description
|
label: i18n.ts.description,
|
||||||
},
|
},
|
||||||
isPublic: {
|
isPublic: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
label: i18n.ts.public,
|
label: i18n.ts.public,
|
||||||
default: false
|
default: false,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|
||||||
const clip = await os.apiWithDialog('clips/create', result);
|
const clip = await os.apiWithDialog('clips/create', result);
|
||||||
|
|
||||||
os.apiWithDialog('clips/add-note', { clipId: clip.id, noteId: appearNote.id });
|
os.apiWithDialog('clips/add-note', { clipId: clip.id, noteId: appearNote.id });
|
||||||
}
|
},
|
||||||
}, null, ...clips.map(clip => ({
|
}, null, ...clips.map(clip => ({
|
||||||
text: clip.name,
|
text: clip.name,
|
||||||
action: () => {
|
action: () => {
|
||||||
|
@ -146,9 +146,9 @@ export function getNoteMenu(props: {
|
||||||
text: err.message + '\n' + err.id,
|
text: err.message + '\n' + err.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
}))], props.menuButton.value, {
|
}))], props.menuButton.value, {
|
||||||
}).then(focus);
|
}).then(focus);
|
||||||
}
|
}
|
||||||
|
@ -193,86 +193,86 @@ export function getNoteMenu(props: {
|
||||||
let menu;
|
let menu;
|
||||||
if ($i) {
|
if ($i) {
|
||||||
const statePromise = os.api('notes/state', {
|
const statePromise = os.api('notes/state', {
|
||||||
noteId: appearNote.id
|
noteId: appearNote.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
menu = [
|
menu = [
|
||||||
...(
|
...(
|
||||||
props.currentClipPage?.value.userId === $i.id ? [{
|
props.currentClipPage?.value.userId === $i.id ? [{
|
||||||
icon: 'fas fa-circle-minus',
|
icon: 'fas fa-circle-minus',
|
||||||
text: i18n.ts.unclip,
|
text: i18n.ts.unclip,
|
||||||
danger: true,
|
danger: true,
|
||||||
action: unclip,
|
action: unclip,
|
||||||
}, null] : []
|
}, null] : []
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
icon: 'fas fa-copy',
|
icon: 'fas fa-copy',
|
||||||
text: i18n.ts.copyContent,
|
text: i18n.ts.copyContent,
|
||||||
action: copyContent
|
action: copyContent,
|
||||||
}, {
|
}, {
|
||||||
icon: 'fas fa-link',
|
icon: 'fas fa-link',
|
||||||
text: i18n.ts.copyLink,
|
text: i18n.ts.copyLink,
|
||||||
action: copyLink
|
action: copyLink,
|
||||||
}, (appearNote.url || appearNote.uri) ? {
|
}, (appearNote.url || appearNote.uri) ? {
|
||||||
icon: 'fas fa-external-link-square-alt',
|
icon: 'fas fa-external-link-square-alt',
|
||||||
text: i18n.ts.showOnRemote,
|
text: i18n.ts.showOnRemote,
|
||||||
action: () => {
|
action: () => {
|
||||||
window.open(appearNote.url || appearNote.uri, '_blank');
|
window.open(appearNote.url || appearNote.uri, '_blank');
|
||||||
}
|
},
|
||||||
} : undefined,
|
} : undefined,
|
||||||
{
|
{
|
||||||
icon: 'fas fa-share-alt',
|
icon: 'fas fa-share-alt',
|
||||||
text: i18n.ts.share,
|
text: i18n.ts.share,
|
||||||
action: share
|
action: share,
|
||||||
},
|
},
|
||||||
instance.translatorAvailable ? {
|
instance.translatorAvailable ? {
|
||||||
icon: 'fas fa-language',
|
icon: 'fas fa-language',
|
||||||
text: i18n.ts.translate,
|
text: i18n.ts.translate,
|
||||||
action: translate
|
action: translate,
|
||||||
} : undefined,
|
} : undefined,
|
||||||
null,
|
null,
|
||||||
statePromise.then(state => state.isFavorited ? {
|
statePromise.then(state => state.isFavorited ? {
|
||||||
icon: 'fas fa-star',
|
icon: 'fas fa-star',
|
||||||
text: i18n.ts.unfavorite,
|
text: i18n.ts.unfavorite,
|
||||||
action: () => toggleFavorite(false)
|
action: () => toggleFavorite(false),
|
||||||
} : {
|
} : {
|
||||||
icon: 'fas fa-star',
|
icon: 'fas fa-star',
|
||||||
text: i18n.ts.favorite,
|
text: i18n.ts.favorite,
|
||||||
action: () => toggleFavorite(true)
|
action: () => toggleFavorite(true),
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
icon: 'fas fa-paperclip',
|
icon: 'fas fa-paperclip',
|
||||||
text: i18n.ts.clip,
|
text: i18n.ts.clip,
|
||||||
action: () => clip()
|
action: () => clip(),
|
||||||
},
|
},
|
||||||
(appearNote.userId !== $i.id) ? statePromise.then(state => state.isWatching ? {
|
(appearNote.userId !== $i.id) ? statePromise.then(state => state.isWatching ? {
|
||||||
icon: 'fas fa-eye-slash',
|
icon: 'fas fa-eye-slash',
|
||||||
text: i18n.ts.unwatch,
|
text: i18n.ts.unwatch,
|
||||||
action: () => toggleWatch(false)
|
action: () => toggleWatch(false),
|
||||||
} : {
|
} : {
|
||||||
icon: 'fas fa-eye',
|
icon: 'fas fa-eye',
|
||||||
text: i18n.ts.watch,
|
text: i18n.ts.watch,
|
||||||
action: () => toggleWatch(true)
|
action: () => toggleWatch(true),
|
||||||
}) : undefined,
|
}) : undefined,
|
||||||
statePromise.then(state => state.isMutedThread ? {
|
statePromise.then(state => state.isMutedThread ? {
|
||||||
icon: 'fas fa-comment-slash',
|
icon: 'fas fa-comment-slash',
|
||||||
text: i18n.ts.unmuteThread,
|
text: i18n.ts.unmuteThread,
|
||||||
action: () => toggleThreadMute(false)
|
action: () => toggleThreadMute(false),
|
||||||
} : {
|
} : {
|
||||||
icon: 'fas fa-comment-slash',
|
icon: 'fas fa-comment-slash',
|
||||||
text: i18n.ts.muteThread,
|
text: i18n.ts.muteThread,
|
||||||
action: () => toggleThreadMute(true)
|
action: () => toggleThreadMute(true),
|
||||||
}),
|
}),
|
||||||
appearNote.userId === $i.id ? ($i.pinnedNoteIds || []).includes(appearNote.id) ? {
|
appearNote.userId === $i.id ? ($i.pinnedNoteIds || []).includes(appearNote.id) ? {
|
||||||
icon: 'fas fa-thumbtack',
|
icon: 'fas fa-thumbtack',
|
||||||
text: i18n.ts.unpin,
|
text: i18n.ts.unpin,
|
||||||
action: () => togglePin(false)
|
action: () => togglePin(false),
|
||||||
} : {
|
} : {
|
||||||
icon: 'fas fa-thumbtack',
|
icon: 'fas fa-thumbtack',
|
||||||
text: i18n.ts.pin,
|
text: i18n.ts.pin,
|
||||||
action: () => togglePin(true)
|
action: () => togglePin(true),
|
||||||
} : undefined,
|
} : undefined,
|
||||||
/*
|
/*
|
||||||
...($i.isModerator || $i.isAdmin ? [
|
...($i.isModerator || $i.isAdmin ? [
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
|
@ -282,52 +282,52 @@ export function getNoteMenu(props: {
|
||||||
}]
|
}]
|
||||||
: []
|
: []
|
||||||
),*/
|
),*/
|
||||||
...(appearNote.userId !== $i.id ? [
|
...(appearNote.userId !== $i.id ? [
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
icon: 'fas fa-exclamation-circle',
|
icon: 'fas fa-exclamation-circle',
|
||||||
text: i18n.ts.reportAbuse,
|
text: i18n.ts.reportAbuse,
|
||||||
action: () => {
|
action: () => {
|
||||||
const u = appearNote.url || appearNote.uri || `${url}/notes/${appearNote.id}`;
|
const u = appearNote.url || appearNote.uri || `${url}/notes/${appearNote.id}`;
|
||||||
os.popup(defineAsyncComponent(() => import('@/components/abuse-report-window.vue')), {
|
os.popup(defineAsyncComponent(() => import('@/components/abuse-report-window.vue')), {
|
||||||
user: appearNote.user,
|
user: appearNote.user,
|
||||||
initialComment: `Note: ${u}\n-----\n`
|
initialComment: `Note: ${u}\n-----\n`,
|
||||||
}, {}, 'closed');
|
}, {}, 'closed');
|
||||||
}
|
},
|
||||||
}]
|
}]
|
||||||
: []
|
: []
|
||||||
),
|
),
|
||||||
...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [
|
...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [
|
||||||
null,
|
null,
|
||||||
appearNote.userId === $i.id ? {
|
appearNote.userId === $i.id ? {
|
||||||
icon: 'fas fa-edit',
|
icon: 'fas fa-edit',
|
||||||
text: i18n.ts.deleteAndEdit,
|
text: i18n.ts.deleteAndEdit,
|
||||||
action: delEdit
|
action: delEdit,
|
||||||
} : undefined,
|
} : undefined,
|
||||||
{
|
{
|
||||||
icon: 'fas fa-trash-alt',
|
icon: 'fas fa-trash-alt',
|
||||||
text: i18n.ts.delete,
|
text: i18n.ts.delete,
|
||||||
danger: true,
|
danger: true,
|
||||||
action: del
|
action: del,
|
||||||
}]
|
}]
|
||||||
: []
|
: []
|
||||||
)]
|
)]
|
||||||
.filter(x => x !== undefined);
|
.filter(x => x !== undefined);
|
||||||
} else {
|
} else {
|
||||||
menu = [{
|
menu = [{
|
||||||
icon: 'fas fa-copy',
|
icon: 'fas fa-copy',
|
||||||
text: i18n.ts.copyContent,
|
text: i18n.ts.copyContent,
|
||||||
action: copyContent
|
action: copyContent,
|
||||||
}, {
|
}, {
|
||||||
icon: 'fas fa-link',
|
icon: 'fas fa-link',
|
||||||
text: i18n.ts.copyLink,
|
text: i18n.ts.copyLink,
|
||||||
action: copyLink
|
action: copyLink,
|
||||||
}, (appearNote.url || appearNote.uri) ? {
|
}, (appearNote.url || appearNote.uri) ? {
|
||||||
icon: 'fas fa-external-link-square-alt',
|
icon: 'fas fa-external-link-square-alt',
|
||||||
text: i18n.ts.showOnRemote,
|
text: i18n.ts.showOnRemote,
|
||||||
action: () => {
|
action: () => {
|
||||||
window.open(appearNote.url || appearNote.uri, '_blank');
|
window.open(appearNote.url || appearNote.uri, '_blank');
|
||||||
}
|
},
|
||||||
} : undefined]
|
} : undefined]
|
||||||
.filter(x => x !== undefined);
|
.filter(x => x !== undefined);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ export function getNoteMenu(props: {
|
||||||
text: action.title,
|
text: action.title,
|
||||||
action: () => {
|
action: () => {
|
||||||
action.handler(appearNote);
|
action.handler(appearNote);
|
||||||
}
|
},
|
||||||
}))]);
|
}))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue