From 26986b150376142d63dc3b0b552268019671c116 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 8 Apr 2023 16:52:07 +0900 Subject: [PATCH 001/147] feat(frontend): tms: drafts --- packages/client/src/components/MkPostForm.vue | 65 ++----- .../pages/messaging/messaging-room.form.vue | 59 +++---- packages/client/src/scripts/tms/drafts.ts | 167 ++++++++++++++++++ 3 files changed, 205 insertions(+), 86 deletions(-) create mode 100644 packages/client/src/scripts/tms/drafts.ts diff --git a/packages/client/src/components/MkPostForm.vue b/packages/client/src/components/MkPostForm.vue index 245e30e1ecde..00ab1a2ae8f3 100644 --- a/packages/client/src/components/MkPostForm.vue +++ b/packages/client/src/components/MkPostForm.vue @@ -94,6 +94,7 @@ import { uploadFile } from '@/scripts/upload'; import { deepClone } from '@/scripts/clone'; import { parseObject, parseArray } from '@/scripts/tms/parse'; import { imanonashi } from '@/scripts/tms/imanonashi'; +import { getDraft as _getDraft, setDraft as _setDraft, deleteDraft as _deleteDraft } from '@/scripts/tms/drafts'; const modal = inject('modal'); @@ -453,14 +454,15 @@ const clear = (): void => { }; const onKeydown = (ev: KeyboardEvent): void => { + typing(); + if (ev.isComposing || ev.key === 'Process' || ev.keyCode === 229) return; if (ev.key === 'Enter' && (ev.ctrlKey || ev.metaKey) && canPost) post(); if (ev.key === 'Escape' || ev.key === 'Esc') emit('esc'); - typing(); }; const onCompositionUpdate = (ev: CompositionEvent): void => { - imeText = ev.data; typing(); + imeText = ev.data; }; const onCompositionEnd = (_ev: CompositionEvent): void => { @@ -555,45 +557,9 @@ const onDrop = (ev: DragEvent): void => { //#endregion }; -type DraftData = { - updatedAt: string; - data: { - text: typeof text; - useCw: typeof useCw; - cw: typeof cw; - visibility: typeof visibility; - localOnly: typeof localOnly; - files: typeof files; - poll: typeof poll; - }; -}; +const saveDraft = (): void => _setDraft(draftKey, { text, useCw, cw, visibility, localOnly, files, poll }); -const saveDraft = (): void => { - const draftData = parseObject>(localStorage.getItem('drafts')); - - draftData[draftKey] = { - updatedAt: new Date().toJSON(), - data: { - text: text, - useCw: useCw, - cw: cw, - visibility: visibility, - localOnly: localOnly, - files: files, - poll: poll, - }, - }; - - localStorage.setItem('drafts', JSON.stringify(draftData)); -}; - -const deleteDraft = (): void => { - const draftData = parseObject>(localStorage.getItem('drafts')); - - delete draftData[draftKey]; - - localStorage.setItem('drafts', JSON.stringify(draftData)); -}; +const deleteDraft = (): void => _deleteDraft(draftKey); const post = async (ev?: MouseEvent): Promise => { if (ev) { @@ -728,24 +694,22 @@ onMounted(() => { nextTick(() => { // 書きかけの投稿を復元 if (!props.instant && !props.mention && !props.specified) { - const draft = parseObject>(localStorage.getItem('drafts'))[draftKey]; + const draft = _getDraft(draftKey); if (draft) { text = draft.data.text; useCw = draft.data.useCw; cw = draft.data.cw; visibility = draft.data.visibility; localOnly = draft.data.localOnly; - files = (draft.data.files || []).filter(draftFile => draftFile); - if (draft.data.poll) { - poll = draft.data.poll; - } + files = draft.data.files; + poll = draft.data.poll; } } // 削除して編集 if (props.initialNote) { const init = props.initialNote; - text = init.text ? init.text : ''; + text = init.text ?? ''; files = init.files; cw = init.cw; useCw = init.cw != null; @@ -758,11 +722,14 @@ onMounted(() => { }; } visibility = init.visibility; - localOnly = init.localOnly; - quoteId = init.renote ? init.renote.id : null; + localOnly = !!init.localOnly; + quoteId = init.renote?.id ?? null; } - nextTick(() => watchForDraft()); + nextTick(() => { + saveDraft(); + watchForDraft(); + }); }); }); diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index 66d86c451a77..2bbf4c9d2560 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -27,7 +27,7 @@ - diff --git a/packages/client/src/components/MkPostFormDialog.vue b/packages/client/src/components/MkPostFormDialog.vue index 6dabb1db14e8..b5f183db7ae4 100644 --- a/packages/client/src/components/MkPostFormDialog.vue +++ b/packages/client/src/components/MkPostFormDialog.vue @@ -1,19 +1,46 @@ - diff --git a/packages/client/src/components/MkVisibility.vue b/packages/client/src/components/MkVisibility.vue index 53f1be617179..ebfce3ae78f6 100644 --- a/packages/client/src/components/MkVisibility.vue +++ b/packages/client/src/components/MkVisibility.vue @@ -4,7 +4,7 @@ - + diff --git a/packages/client/src/components/MkVisibilityPicker.vue b/packages/client/src/components/MkVisibilityPicker.vue index fb61304831d8..8a8f7a14c81c 100644 --- a/packages/client/src/components/MkVisibilityPicker.vue +++ b/packages/client/src/components/MkVisibilityPicker.vue @@ -1,42 +1,47 @@ From fba26298670726e8cb1d2f817dcc854b5d4b4b3f Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Tue, 11 Apr 2023 04:31:51 +0900 Subject: [PATCH 009/147] fix watch callback --- packages/client/src/components/MkPostForm.vue | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/packages/client/src/components/MkPostForm.vue b/packages/client/src/components/MkPostForm.vue index 643ed12818eb..e4a11117f34a 100644 --- a/packages/client/src/components/MkPostForm.vue +++ b/packages/client/src/components/MkPostForm.vue @@ -244,20 +244,6 @@ const canPost = $computed((): boolean => { const withHashtags = $computed(defaultStore.makeGetterSetter('postFormWithHashtags')); const hashtags = $computed(defaultStore.makeGetterSetter('postFormHashtags')); -watch($$(text), () => { - checkMissingMention(); -}, { immediate: true }); - -watch($$(visibleUsers), () => { - checkMissingMention(); -}, { - deep: true, -}); - -watch($$(text), () => checkAnnoyingPost()); -watch($$(useCw), () => checkAnnoyingPost()); -watch($$(visibility), () => checkAnnoyingPost()); - const pushVisibleUser = (user: misskey.entities.User): void => { if (!visibleUsers.some(u => u.username === user.username && u.host === user.host)) { visibleUsers.push(user); @@ -352,13 +338,13 @@ if (defaultStore.state.keepCw && props.reply && props.reply.cw) { } const watchForDraft = (): void => { - watch($$(text), () => saveDraft()); - watch($$(useCw), () => saveDraft()); - watch($$(cw), () => saveDraft()); - watch($$(poll), () => saveDraft()); - watch($$(files), () => saveDraft(), { deep: true }); - watch($$(visibility), () => saveDraft()); - watch($$(localOnly), () => saveDraft()); + watch($$(text), saveDraft); + watch($$(useCw), saveDraft); + watch($$(cw), saveDraft); + watch($$(poll), saveDraft); + watch($$(files), saveDraft, { deep: true }); + watch($$(visibility), saveDraft); + watch($$(localOnly), saveDraft); }; const checkMissingMention = (): void => { @@ -401,6 +387,13 @@ const checkAnnoyingPost = (): void => { } }; +watch($$(text), checkMissingMention, { immediate: true }); +watch($$(visibleUsers), checkMissingMention, { deep: true }); + +watch($$(text), checkAnnoyingPost); +watch($$(useCw), checkAnnoyingPost); +watch($$(visibility), checkAnnoyingPost); + const togglePoll = (): void => { if (poll) { poll = null; From 3fb6d74373de73fec72be1f0224b3ac31f657968 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Tue, 11 Apr 2023 06:43:59 +0900 Subject: [PATCH 010/147] =?UTF-8?q?feat(frontend):=20tms:=20=E3=83=8E?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AE=E4=B8=8B=E6=9B=B8=E3=81=8D=E6=A9=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 1 + packages/client/src/components/MkPostForm.vue | 27 ++++++- .../src/components/TmsDraftsList.draft.vue | 50 ++++++++++++ .../client/src/components/TmsDraftsList.vue | 61 +++++++++++++++ packages/client/src/scripts/tms/drafts.ts | 78 +++++++++++++++---- 5 files changed, 198 insertions(+), 19 deletions(-) create mode 100644 packages/client/src/components/TmsDraftsList.draft.vue create mode 100644 packages/client/src/components/TmsDraftsList.vue diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 1640c40c6326..063e602d943e 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2304,3 +2304,4 @@ _tms: unreact: "リアクションを解除" pakuru: "パクる" numberquote: "数字引用する" + drafts: "下書き" diff --git a/packages/client/src/components/MkPostForm.vue b/packages/client/src/components/MkPostForm.vue index e4a11117f34a..c59a67de7a10 100644 --- a/packages/client/src/components/MkPostForm.vue +++ b/packages/client/src/components/MkPostForm.vue @@ -15,6 +15,10 @@
+
- + @@ -33,7 +33,7 @@ From ea00ea0ec151117535267c383117cc96c3b09e00 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 06:51:21 +0900 Subject: [PATCH 033/147] fix --- packages/client/src/components/TmsPostForm.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/TmsPostForm.vue b/packages/client/src/components/TmsPostForm.vue index bb1f037a9a93..a62a35263c6e 100644 --- a/packages/client/src/components/TmsPostForm.vue +++ b/packages/client/src/components/TmsPostForm.vue @@ -582,7 +582,8 @@ watch([ if (!draftWatching) return; saveDraft(); }, { deep: true }); -watch($$(draftId), () => { + +const loadDraft = (): void => { draftWatching = false; draft = Draft.getDraft(draftId ?? autosaveDraftId); @@ -598,6 +599,9 @@ watch($$(draftId), () => { channelId = draft?.data.channelId ?? null; draftWatching = true; +}; +watch($$(draftId), () => { + loadDraft(); }); // ハッシュタグ @@ -993,6 +997,8 @@ onMounted(() => { }); defaultStore.set('postFormWithHashtags', false); draftId = _draftId; + } else { + loadDraft(); } draftWatching = true; From 2c375da824383734d1b9e36e36511458a103b4d9 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 07:20:01 +0900 Subject: [PATCH 034/147] fix --- .../client/src/components/TmsPostForm.vue | 53 +++++++------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/packages/client/src/components/TmsPostForm.vue b/packages/client/src/components/TmsPostForm.vue index a62a35263c6e..6893a0d9f467 100644 --- a/packages/client/src/components/TmsPostForm.vue +++ b/packages/client/src/components/TmsPostForm.vue @@ -523,7 +523,7 @@ let draftWatching = $ref(false); let draftId = $ref(null); let draft = $ref(null); const saveDraft = (): void => { - Draft.setDraft(draftId ?? autosaveDraftId, { + Draft.setDraft(draftId, { text, useCw, cw, @@ -537,36 +537,8 @@ const saveDraft = (): void => { }); }; const deleteDraft = (): void => { - Draft.deleteDraft(draftId ?? autosaveDraftId); + Draft.deleteDraft(draftId); }; -const autosaveDraftId = $computed((): string | null => { - if (!$i?.id) return null; - - let key = ''; - - if (channel) { - key += `ch:${channel.id}/`; - } - - if (renote) { - key += `rn:${renote.id}`; - } else if (reply) { - key += `re:${reply.id}`; - } else { - key += `new:${$i.id}`; - } - - // rename - if (!draftId || draftId === key) { - const _draft = Draft.getDraft(key); - if (_draft) { - Draft.deleteDraft(key); - Draft.setDraft(key, _draft.data); - } - } - - return key; -}); watch([ $$(text), $$(useCw), @@ -586,7 +558,7 @@ watch([ const loadDraft = (): void => { draftWatching = false; - draft = Draft.getDraft(draftId ?? autosaveDraftId); + draft = Draft.getDraft(draftId); text = draft?.data.text ?? ''; useCw = draft?.data.useCw ?? false; cw = draft?.data.cw ?? ''; @@ -794,9 +766,8 @@ const cancel = (): void => { }; const chooseDraft = (): void => { - const defaultDraftId = draftId ?? autosaveDraftId; os.popup(defineAsyncComponent(() => import('@/components/TmsDraftsList.vue')), { - ignoreDraftIds: defaultDraftId ? [defaultDraftId] : [], + ignoreDraftIds: draftId ? [draftId] : [], }, { chosen: ({ id }: Draft.DraftWithId) => { draftId = id; @@ -998,7 +969,21 @@ onMounted(() => { defaultStore.set('postFormWithHashtags', false); draftId = _draftId; } else { - loadDraft(); + let _draftId = ''; + + if (props.channel) { + _draftId += `ch:${props.channel.id}/`; + } + + if (props.renote) { + _draftId += `rn:${props.renote.id}`; + } else if (props.reply) { + _draftId += `re:${props.reply.id}`; + } else if ($i) { + _draftId += `new:${$i.id}`; + } + + draftId = _draftId || null; } draftWatching = true; From 22166f78863df8a586cebb4bff1a232b0ab39d20 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 07:53:52 +0900 Subject: [PATCH 035/147] fix --- .../client/src/components/TmsPostForm.vue | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/packages/client/src/components/TmsPostForm.vue b/packages/client/src/components/TmsPostForm.vue index 6893a0d9f467..e9bc906963e6 100644 --- a/packages/client/src/components/TmsPostForm.vue +++ b/packages/client/src/components/TmsPostForm.vue @@ -306,7 +306,7 @@ const addMissingMention = (): void => { for (const x of extractMentions(ast)) { if (!visibleUsers.some(u => (u.username === x.username) && (u.host === x.host))) { - os.api('users/show', { username: x.username, host: x.host ?? undefined }).then(user => { + os.api('users/show', { username: x.username, host: x.host ?? undefined }, token).then(user => { visibleUsers.push(user); }); } @@ -345,7 +345,31 @@ watch($$(postAccount), async () => { id: string; token: string; }[]; - token = storedAccounts.find(x => x.id === postAccount?.id)?.token ?? null; + const newToken = storedAccounts.find(x => x.id === postAccount?.id)?.token ?? null; + + if (token !== newToken) { + token = newToken; + + const { popFetchList } = pushFetchList(); + + if (reply) { + await os.apiWithDialog('notes/show', { noteId: reply.id }, token) + .then(updateReply) + .catch(updateReply); + } + if (renote) { + await os.apiWithDialog('notes/show', { noteId: renote.id }, token) + .then(updateRenote) + .catch(updateRenote); + } + if (channel) { + await os.apiWithDialog('channels/show', { channelId: channel.id }, token) + .then(updateChannel) + .catch(updateChannel); + } + + popFetchList(); + } }); const openAccountMenu = (ev: MouseEvent): void => { openAccountMenu_({ @@ -395,7 +419,7 @@ const mergeVisibility = async (note: Misskey.entities.Note): Promise => { await os.api('users/show', { userIds: visibleUserIds, - }).then(users => { + }, token).then(users => { users.forEach(pushVisibleUser); }); @@ -453,12 +477,12 @@ const updateReply = (_reply: Misskey.entities.Note | null): void => { text = `${mentionText}${text}`; }; -watch([$$(replyId), $$(token)], async ([, newToken]) => { +watch($$(replyId), async () => { if (!replyId) { updateReply(null); return; } - if (replyId === reply?.id && token === newToken) return; + if (replyId === reply?.id) return; const { popFetchList } = pushFetchList(); @@ -476,12 +500,12 @@ const updateRenote = (_renote: Misskey.entities.Note | null): void => { renote = _renote; if (!renote) return; }; -watch([$$(renoteId), $$(token)], async ([, newToken]) => { +watch($$(renoteId), async () => { if (!renoteId) { updateRenote(null); return; } - if (renoteId === renote?.id && token === newToken) return; + if (renoteId === renote?.id) return; const { popFetchList } = pushFetchList(); @@ -502,12 +526,12 @@ const updateChannel = (_channel: unknown | Misskey.entities.Channel | null): voi visibility = 'public'; localOnly = true; }; -watch([$$(channelId), $$(token)], async ([, newToken]) => { +watch($$(channelId), async () => { if (!channelId) { updateChannel(null); return; } - if (channelId === channel?.id && token === newToken) return; + if (channelId === channel?.id) return; const { popFetchList } = pushFetchList(); @@ -531,9 +555,9 @@ const saveDraft = (): void => { localOnly, files, poll, - replyId, - renoteId, - channelId, + replyId: reply?.id ?? null, + renoteId: renote?.id ?? null, + channelId: channel?.id ?? null, }); }; const deleteDraft = (): void => { From 3baebf3a567ce31b83e0d99e50678758d1e87f7c Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 08:09:08 +0900 Subject: [PATCH 036/147] fix --- packages/client/src/components/TmsPostForm.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/TmsPostForm.vue b/packages/client/src/components/TmsPostForm.vue index e9bc906963e6..b2691b5beb0e 100644 --- a/packages/client/src/components/TmsPostForm.vue +++ b/packages/client/src/components/TmsPostForm.vue @@ -76,7 +76,7 @@
- +
{{ maxTextLength - textLength }}
@@ -435,6 +435,7 @@ let replyId = $ref(null); let reply = $ref(null); const updateReply = (_reply: Misskey.entities.Note | null): void => { reply = _reply; + replyId = reply?.id ?? null; if (!reply) return; mergeVisibility(reply); @@ -479,7 +480,7 @@ const updateReply = (_reply: Misskey.entities.Note | null): void => { }; watch($$(replyId), async () => { if (!replyId) { - updateReply(null); + reply = null; return; } if (replyId === reply?.id) return; @@ -498,11 +499,12 @@ let renoteId = $ref(null); let renote = $ref(null); const updateRenote = (_renote: Misskey.entities.Note | null): void => { renote = _renote; + renoteId = renote?.id ?? null; if (!renote) return; }; watch($$(renoteId), async () => { if (!renoteId) { - updateRenote(null); + renote = null; return; } if (renoteId === renote?.id) return; @@ -521,6 +523,7 @@ let channelId = $ref(null); let channel = $ref(null); const updateChannel = (_channel: unknown | Misskey.entities.Channel | null): void => { channel = (_channel as Misskey.entities.Channel | null); + channelId = channel?.id ?? null; if (!channel) return; visibility = 'public'; @@ -528,7 +531,7 @@ const updateChannel = (_channel: unknown | Misskey.entities.Channel | null): voi }; watch($$(channelId), async () => { if (!channelId) { - updateChannel(null); + channel = null; return; } if (channelId === channel?.id) return; @@ -955,17 +958,14 @@ onMounted(() => { if (props.reply) { updateReply(props.reply); - replyId = props.reply.id; } if (props.renote) { updateRenote(props.renote); - renoteId = props.renote.id; } if (props.channel) { updateChannel(props.channel); - channelId = props.channel.id; } if (props.initialNote) { From d9a69fee9dcaf2b3697a80926c2bd0d8b3e40525 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 08:16:58 +0900 Subject: [PATCH 037/147] tweak --- packages/client/src/components/TmsPostForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/TmsPostForm.vue b/packages/client/src/components/TmsPostForm.vue index b2691b5beb0e..954d2f2dd56e 100644 --- a/packages/client/src/components/TmsPostForm.vue +++ b/packages/client/src/components/TmsPostForm.vue @@ -76,7 +76,7 @@
- +
{{ maxTextLength - textLength }}
From 22bd6ba4b96535684736183e5e600859e64b8d9b Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 08:37:45 +0900 Subject: [PATCH 038/147] fix --- .../client/src/components/TmsPostForm.vue | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/client/src/components/TmsPostForm.vue b/packages/client/src/components/TmsPostForm.vue index 954d2f2dd56e..251f471006b2 100644 --- a/packages/client/src/components/TmsPostForm.vue +++ b/packages/client/src/components/TmsPostForm.vue @@ -586,16 +586,20 @@ const loadDraft = (): void => { draftWatching = false; draft = Draft.getDraft(draftId); - text = draft?.data.text ?? ''; - useCw = draft?.data.useCw ?? false; - cw = draft?.data.cw ?? ''; - visibility = draft?.data.visibility ?? Draft.getVisibility(); - localOnly = draft?.data.localOnly ?? Draft.getLocalOnly(); - files = draft?.data.files ?? []; - poll = draft?.data.poll ?? null; - replyId = draft?.data.replyId ?? null; - renoteId = draft?.data.renoteId ?? null; - channelId = draft?.data.channelId ?? null; + if (draft) { + text = draft.data.text; + useCw = draft.data.useCw; + cw = draft.data.cw; + visibility = draft.data.visibility; + localOnly = draft.data.localOnly; + files = draft.data.files; + poll = draft.data.poll; + replyId = draft.data.replyId; + renoteId = draft.data.renoteId; + channelId = draft.data.channelId; + } else { + clear(); + } draftWatching = true; }; From e9ff34f57289d94e07c20a2f75c2abc53273a29f Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 08:52:47 +0900 Subject: [PATCH 039/147] fix --- packages/client/src/components/TmsPostForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/TmsPostForm.vue b/packages/client/src/components/TmsPostForm.vue index 251f471006b2..2b4e4f14a6ea 100644 --- a/packages/client/src/components/TmsPostForm.vue +++ b/packages/client/src/components/TmsPostForm.vue @@ -492,7 +492,7 @@ watch($$(replyId), async () => { .catch(updateReply); popFetchList(); -}, { immediate: true }); +}); // Renote, 引用 let renoteId = $ref(null); From 185e503aa7d83a2dbcbd431f772cc66718a653b9 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sat, 15 Apr 2023 09:30:48 +0900 Subject: [PATCH 040/147] tweak --- locales/en-US.yml | 2 ++ locales/ja-CJP.yml | 2 ++ locales/ja-JP.yml | 1 + locales/ja-KS.yml | 2 ++ .../src/components/TmsDraftsList.draft.vue | 25 ++++++++++++++++--- .../client/src/components/TmsDraftsList.vue | 19 +++++++++++--- .../client/src/components/TmsPostForm.vue | 2 +- packages/client/src/scripts/tms/drafts.ts | 2 +- 8 files changed, 46 insertions(+), 9 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 99c7419bf78e..d2314c92d02e 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2212,3 +2212,5 @@ _tms: unreact: "Unreact" pakuru: "Pakuru" numberquote: "Numberquote" + drafts: "Drafts" + loadDraft: "Load from draft" diff --git a/locales/ja-CJP.yml b/locales/ja-CJP.yml index 397ee5708f8f..1a33d0b8c5c8 100644 --- a/locales/ja-CJP.yml +++ b/locales/ja-CJP.yml @@ -2304,3 +2304,5 @@ _tms: unreact: "刂マケツ゚彐ソを解除" pakuru: "八゜ケゑ" numberquote: "数字引用ずゑ" + drafts: "草稿" + loadDraft: "草稿を読み込む" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 063e602d943e..e627b5b67d89 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2305,3 +2305,4 @@ _tms: pakuru: "パクる" numberquote: "数字引用する" drafts: "下書き" + loadDraft: "下書きを読み込む" diff --git a/locales/ja-KS.yml b/locales/ja-KS.yml index c7ba36495544..7594d7d3810c 100644 --- a/locales/ja-KS.yml +++ b/locales/ja-KS.yml @@ -2304,3 +2304,5 @@ _tms: unreact: "リアクションやめる" pakuru: "パクる" numberquote: "数字引用する" + drafts: "下書き" + loadDraft: "下書きを読み込む" diff --git a/packages/client/src/components/TmsDraftsList.draft.vue b/packages/client/src/components/TmsDraftsList.draft.vue index 1f0553fb0f01..223dd098315a 100644 --- a/packages/client/src/components/TmsDraftsList.draft.vue +++ b/packages/client/src/components/TmsDraftsList.draft.vue @@ -1,5 +1,5 @@ + + diff --git a/packages/client/src/components/MkReactionsViewer.vue b/packages/client/src/components/MkReactionsViewer.vue index 596d52911aaf..451d09d7f66d 100644 --- a/packages/client/src/components/MkReactionsViewer.vue +++ b/packages/client/src/components/MkReactionsViewer.vue @@ -1,24 +1,21 @@ - diff --git a/packages/client/src/components/MkReactionsViewer.vue b/packages/client/src/components/MkReactionsViewer.vue index 451d09d7f66d..56caa96f879a 100644 --- a/packages/client/src/components/MkReactionsViewer.vue +++ b/packages/client/src/components/MkReactionsViewer.vue @@ -1,5 +1,5 @@ @@ -10,7 +10,7 @@ import { } from 'vue'; import XColumn from './column.vue'; import { Column } from './deck-store'; -import XNotes from '@/components/MkNotes.vue'; +import MkNotes from '@/components/MkNotes.vue'; defineProps<{ column: Column; diff --git a/packages/client/src/ui/deck/notifications-column.vue b/packages/client/src/ui/deck/notifications-column.vue index bceec14a0f07..ee2ea95e5f69 100644 --- a/packages/client/src/ui/deck/notifications-column.vue +++ b/packages/client/src/ui/deck/notifications-column.vue @@ -2,15 +2,16 @@ - + diff --git a/packages/client/src/ui/deck/tl-column.vue b/packages/client/src/ui/deck/tl-column.vue index 182bee9346a7..bcb93c5b1499 100644 --- a/packages/client/src/ui/deck/tl-column.vue +++ b/packages/client/src/ui/deck/tl-column.vue @@ -11,11 +11,11 @@

- {{ $t('disabled-timeline.title') }} + {{ i18n.t('disabled-timeline.title') }}

-

{{ $t('disabled-timeline.description') }}

+

{{ i18n.t('disabled-timeline.description') }}

- + @@ -23,7 +23,7 @@ import { onMounted } from 'vue'; import XColumn from './column.vue'; import { removeColumn, updateColumn, Column } from './deck-store'; -import XTimeline from '@/components/MkTimeline.vue'; +import MkTimeline from '@/components/MkTimeline.vue'; import * as os from '@/os'; import { $i } from '@/account'; import { instance } from '@/instance'; @@ -53,17 +53,21 @@ onMounted(() => { } }); -async function setType() { +const setType = async (): Promise => { const { canceled, result: src } = await os.select({ title: i18n.ts.timeline, items: [{ - value: 'home' as const, text: i18n.ts._timelines.home, + value: 'home' as const, + text: i18n.ts._timelines.home, }, { - value: 'local' as const, text: i18n.ts._timelines.local, + value: 'local' as const, + text: i18n.ts._timelines.local, }, { - value: 'social' as const, text: i18n.ts._timelines.social, + value: 'social' as const, + text: i18n.ts._timelines.social, }, { - value: 'global' as const, text: i18n.ts._timelines.global, + value: 'global' as const, + text: i18n.ts._timelines.global, }], }); if (canceled) { @@ -75,27 +79,27 @@ async function setType() { updateColumn(props.column.id, { tl: src, }); -} +}; -function queueUpdated(q) { +const queueUpdated = (q: number): void => { if (columnActive) { indicated = q !== 0; } -} +}; -function onNote() { +const onNote = (): void => { if (!columnActive) { indicated = true; } -} +}; -function onChangeActiveState(state) { +const onChangeActiveState = (state: boolean): void => { columnActive = state; if (columnActive) { indicated = false; } -} +}; const menu = [{ icon: 'ti ti-pencil', diff --git a/packages/client/src/ui/deck/widgets-column.vue b/packages/client/src/ui/deck/widgets-column.vue index fc61d18ff6d0..9258090a38e8 100644 --- a/packages/client/src/ui/deck/widgets-column.vue +++ b/packages/client/src/ui/deck/widgets-column.vue @@ -4,7 +4,7 @@
{{ i18n.ts._deck.widgetsIntroduction }}
- +
@@ -13,7 +13,7 @@ import { } from 'vue'; import XColumn from './column.vue'; import { addColumnWidget, Column, removeColumnWidget, setColumnWidgets, updateColumnWidget } from './deck-store'; -import XWidgets from '@/components/MkWidgets.vue'; +import MkWidgets, { Widget, EditedWidget } from '@/components/MkWidgets.vue'; import { i18n } from '@/i18n'; const props = defineProps<{ @@ -27,30 +27,30 @@ const emit = defineEmits<{ let edit = $ref(false); -function addWidget(widget) { +const addWidget = (widget: Widget): void => { addColumnWidget(props.column.id, widget); -} +}; -function removeWidget(widget) { +const removeWidget = (widget: Widget): void => { removeColumnWidget(props.column.id, widget); -} +}; -function updateWidget({ id, data }) { +const updateWidget = ({ id, data }: EditedWidget): void => { updateColumnWidget(props.column.id, id, data); -} +}; -function updateWidgets(widgets) { +const updateWidgets = (widgets: Widget[]): void => { setColumnWidgets(props.column.id, widgets); -} +}; -function func() { +const toggleWidgetEdit = (): void => { edit = !edit; -} +}; const menu = [{ icon: 'ti ti-pencil', text: i18n.ts.editWidgets, - action: func, + action: toggleWidgetEdit, }]; diff --git a/packages/client/src/ui/universal.vue b/packages/client/src/ui/universal.vue index bca8ca2dabe6..5696d0f1f1bb 100644 --- a/packages/client/src/ui/universal.vue +++ b/packages/client/src/ui/universal.vue @@ -28,19 +28,19 @@ - + - + - +
- + diff --git a/packages/client/src/ui/universal.widgets.vue b/packages/client/src/ui/universal.widgets.vue index 33fb49283693..de9937867295 100644 --- a/packages/client/src/ui/universal.widgets.vue +++ b/packages/client/src/ui/universal.widgets.vue @@ -1,6 +1,6 @@ @@ -62,6 +62,14 @@ const emit = defineEmits<{ const isDragging = ref(false); const title = computed(() => `${props.file.name}\n${props.file.type} ${bytes(props.file.size)}`); +const fileName = computed(() => { + const lio = props.file.name.lastIndexOf('.'); + return lio !== -1 ? props.file.name.substring(0, lio) : props.file.name; +}); +const fileExt = computed(() => { + const lio = props.file.name.lastIndexOf('.'); + return lio !== -1 ? props.file.name.substring(lio) : null; +}); const getMenu = (): MenuItem[] => { return [{ diff --git a/packages/client/src/components/MkUrlPreview.vue b/packages/client/src/components/MkUrlPreview.vue index c6a5cfe33c76..4643ed8f80f3 100644 --- a/packages/client/src/components/MkUrlPreview.vue +++ b/packages/client/src/components/MkUrlPreview.vue @@ -38,7 +38,7 @@
- +
diff --git a/packages/client/src/components/MkUserPreview.vue b/packages/client/src/components/MkUserPreview.vue index 4198fe0030eb..29ff940f2ee4 100644 --- a/packages/client/src/components/MkUserPreview.vue +++ b/packages/client/src/components/MkUserPreview.vue @@ -66,7 +66,7 @@ onMounted(() => { user = props.q; } else { const query = props.q.startsWith('@') ? - Acct.parse(props.q.substr(1)) : + Acct.parse(props.q.slice(1)) : { userId: props.q }; os.api('users/show', query).then(res => { diff --git a/packages/client/src/components/global/MkUrl.vue b/packages/client/src/components/global/MkUrl.vue index be547983ed36..8d448506412a 100644 --- a/packages/client/src/components/global/MkUrl.vue +++ b/packages/client/src/components/global/MkUrl.vue @@ -1,7 +1,7 @@