From bba3097765317cbf95d09627961b5b5dce16a972 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:30:24 +0900 Subject: enhance: クリップのノート数を表示するように (#13686) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance: クリップのノート数を表示できるように * Update Changelog --- packages/frontend/src/scripts/get-note-menu.ts | 36 +++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'packages/frontend/src/scripts/get-note-menu.ts') diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index b273bd36f3..87921bc67f 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -26,6 +26,14 @@ export async function getNoteClipMenu(props: { isDeleted: Ref; currentClip?: Misskey.entities.Clip; }) { + function getClipName(clip: Misskey.entities.Clip) { + if ($i && clip.userId === $i.id && clip.notesCount != null) { + return `${clip.name} (${clip.notesCount}/${$i.policies.noteEachClipsLimit})`; + } else { + return clip.name; + } + } + const isRenote = ( props.note.renote != null && props.note.text == null && @@ -37,7 +45,7 @@ export async function getNoteClipMenu(props: { const clips = await clipsCache.fetch(); const menu: MenuItem[] = [...clips.map(clip => ({ - text: clip.name, + text: getClipName(clip), action: () => { claimAchievement('noteClipped1'); os.promiseDialog( @@ -50,7 +58,18 @@ export async function getNoteClipMenu(props: { text: i18n.tsx.confirmToUnclipAlreadyClippedNote({ name: clip.name }), }); if (!confirm.canceled) { - os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id }); + os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id }).then(() => { + clipsCache.set(clips.map(c => { + if (c.id === clip.id) { + return { + ...c, + notesCount: Math.max(0, ((c.notesCount ?? 0) - 1)), + }; + } else { + return c; + } + })); + }); if (props.currentClip?.id === clip.id) props.isDeleted.value = true; } } else { @@ -60,7 +79,18 @@ export async function getNoteClipMenu(props: { }); } }, - ); + ).then(() => { + clipsCache.set(clips.map(c => { + if (c.id === clip.id) { + return { + ...c, + notesCount: (c.notesCount ?? 0) + 1, + }; + } else { + return c; + } + })); + }); }, })), { type: 'divider' }, { icon: 'ti ti-plus', -- cgit v1.2.3-freya From 9f66f229537915f47da8e6e08e92a78be390f454 Mon Sep 17 00:00:00 2001 From: taiy <53635909+taiyme@users.noreply.github.com> Date: Wed, 1 May 2024 15:29:38 +0900 Subject: fix(frontend): 連合なしの状態の読み書きができない問題 (#13777) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 連合なしの状態の読み書きができない問題 * update changelog * fix types: https://github.com/misskey-dev/misskey/pull/13777#discussion_r1585901601 --- CHANGELOG.md | 1 + packages/frontend/src/components/MkPostForm.vue | 8 ++++++-- packages/frontend/src/components/MkPostFormDialog.vue | 6 ++++-- packages/frontend/src/scripts/get-note-menu.ts | 5 ++--- packages/frontend/src/store.ts | 4 ++-- 5 files changed, 15 insertions(+), 9 deletions(-) (limited to 'packages/frontend/src/scripts/get-note-menu.ts') diff --git a/CHANGELOG.md b/CHANGELOG.md index 68015596bd..4b65550daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ - Fix: ページのOGP URLが間違っているのを修正 - Fix: リバーシの対局を正しく共有できないことがある問題を修正 - Fix: 通知をグループ化している際に、人数が正常に表示されないことがある問題を修正 +- Fix: 連合なしの状態の読み書きができない問題を修正 ### Server - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index d7efca9de9..7dbc127298 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -156,6 +156,7 @@ const props = withDefaults(defineProps<{ initialVisibleUsers: () => [], autofocus: true, mock: false, + initialLocalOnly: undefined, }); provide('mock', props.mock); @@ -185,8 +186,8 @@ watch(showPreview, () => defaultStore.set('showPreview', showPreview.value)); const showAddMfmFunction = ref(defaultStore.state.enableQuickAddMfmFunction); watch(showAddMfmFunction, () => defaultStore.set('enableQuickAddMfmFunction', showAddMfmFunction.value)); const cw = ref(props.initialCw ?? null); -const localOnly = ref(props.initialLocalOnly ?? defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly); -const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility) as typeof Misskey.noteVisibilities[number]); +const localOnly = ref(props.initialLocalOnly ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly)); +const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility)); const visibleUsers = ref([]); if (props.initialVisibleUsers) { props.initialVisibleUsers.forEach(pushVisibleUser); @@ -518,6 +519,9 @@ async function toggleLocalOnly() { } localOnly.value = !localOnly.value; + if (defaultStore.state.rememberNoteVisibility) { + defaultStore.set('localOnly', localOnly.value); + } } async function toggleReactionAcceptance() { diff --git a/packages/frontend/src/components/MkPostFormDialog.vue b/packages/frontend/src/components/MkPostFormDialog.vue index 6331dfed29..ac37cb31bc 100644 --- a/packages/frontend/src/components/MkPostFormDialog.vue +++ b/packages/frontend/src/components/MkPostFormDialog.vue @@ -15,7 +15,7 @@ import * as Misskey from 'misskey-js'; import MkModal from '@/components/MkModal.vue'; import MkPostForm from '@/components/MkPostForm.vue'; -const props = defineProps<{ +const props = withDefaults(defineProps<{ reply?: Misskey.entities.Note; renote?: Misskey.entities.Note; channel?: any; // TODO @@ -31,7 +31,9 @@ const props = defineProps<{ instant?: boolean; fixed?: boolean; autofocus?: boolean; -}>(); +}>(), { + initialLocalOnly: undefined, +}); const emit = defineEmits<{ (ev: 'closed'): void; diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 87921bc67f..2cd21c1edc 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -492,10 +492,9 @@ export function getNoteMenu(props: { }; } -type Visibility = 'public' | 'home' | 'followers' | 'specified'; +type Visibility = (typeof Misskey.noteVisibilities)[number]; -// defaultStore.state.visibilityがstringなためstringも受け付けている -function smallerVisibility(a: Visibility | string, b: Visibility | string): Visibility { +function smallerVisibility(a: Visibility, b: Visibility): Visibility { if (a === 'specified' || b === 'specified') return 'specified'; if (a === 'followers' || b === 'followers') return 'followers'; if (a === 'home' || b === 'home') return 'home'; diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index e6a348b79f..e8eb5a1ed7 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -94,7 +94,7 @@ export const defaultStore = markRaw(new Storage('base', { }, defaultNoteVisibility: { where: 'account', - default: 'public', + default: 'public' as (typeof Misskey.noteVisibilities)[number], }, defaultNoteLocalOnly: { where: 'account', @@ -150,7 +150,7 @@ export const defaultStore = markRaw(new Storage('base', { }, visibility: { where: 'deviceAccount', - default: 'public' as 'public' | 'home' | 'followers' | 'specified', + default: 'public' as (typeof Misskey.noteVisibilities)[number], }, localOnly: { where: 'deviceAccount', -- cgit v1.2.3-freya From 6a637db36b8a0c32774b5da5e40236c5f14a59e8 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 21 May 2024 17:23:20 +0900 Subject: enhance(frontend): 通常のノートでも、お気に入りに登録したチャンネルにリノートできるように (#13855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(frontend): チャンネルにリノートできるように * Update Changelog --- CHANGELOG.md | 1 + locales/index.d.ts | 12 ++++++++ locales/ja-JP.yml | 3 ++ packages/frontend/src/scripts/get-note-menu.ts | 38 ++++++++++++++++++++++++++ 4 files changed, 54 insertions(+) (limited to 'packages/frontend/src/scripts/get-note-menu.ts') diff --git a/CHANGELOG.md b/CHANGELOG.md index ecacefe84e..9bdc1d135a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ - Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように - Enhance: `Ui:C:postForm` および `Ui:C:postFormButton` に `localOnly` と `visibility` を設定できるように - Enhance: AiScriptを0.18.0にバージョンアップ +- Enhance: 通常のノートでも、お気に入りに登録したチャンネルにリノートできるように - Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: ローカルURLのプレビューポップアップが左上に表示される diff --git a/locales/index.d.ts b/locales/index.d.ts index 779a5d2c3f..70741b6460 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -448,6 +448,10 @@ export interface Locale extends ILocale { * リノートしました。 */ "renoted": string; + /** + * {name} にリノートしました。 + */ + "renotedToX": ParameterizedString<"name">; /** * この投稿はリノートできません。 */ @@ -468,6 +472,14 @@ export interface Locale extends ILocale { * チャンネル内引用 */ "inChannelQuote": string; + /** + * チャンネルにリノート + */ + "renoteToChannel": string; + /** + * 他のチャンネルにリノート + */ + "renoteToOtherChannel": string; /** * ピン留めされたノート */ diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 8f17215802..b5808f7541 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -108,11 +108,14 @@ enterEmoji: "絵文字を入力" renote: "リノート" unrenote: "リノート解除" renoted: "リノートしました。" +renotedToX: "{name} にリノートしました。" cantRenote: "この投稿はリノートできません。" cantReRenote: "リノートをリノートすることはできません。" quote: "引用" inChannelRenote: "チャンネル内リノート" inChannelQuote: "チャンネル内引用" +renoteToChannel: "チャンネルにリノート" +renoteToOtherChannel: "他のチャンネルにリノート" pinnedNote: "ピン留めされたノート" pinned: "ピン留め" you: "あなた" diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 2cd21c1edc..e7c9a848e0 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -518,6 +518,7 @@ export function getRenoteMenu(props: { const channelRenoteItems: MenuItem[] = []; const normalRenoteItems: MenuItem[] = []; + const normalExternalChannelRenoteItems: MenuItem[] = []; if (appearNote.channel) { channelRenoteItems.push(...[{ @@ -596,12 +597,49 @@ export function getRenoteMenu(props: { }); }, }]); + + normalExternalChannelRenoteItems.push({ + type: 'parent', + icon: 'ti ti-repeat', + text: appearNote.channel ? i18n.ts.renoteToOtherChannel : i18n.ts.renoteToChannel, + children: async () => { + const channels = await misskeyApi('channels/my-favorites', { + limit: 30, + }); + return channels.filter((channel) => { + if (!appearNote.channelId) return true; + return channel.id !== appearNote.channelId; + }).map((channel) => ({ + text: channel.name, + action: () => { + const el = props.renoteButton.value; + if (el) { + const rect = el.getBoundingClientRect(); + const x = rect.left + (el.offsetWidth / 2); + const y = rect.top + (el.offsetHeight / 2); + os.popup(MkRippleEffect, { x, y }, {}, 'end'); + } + + if (!props.mock) { + misskeyApi('notes/create', { + renoteId: appearNote.id, + channelId: channel.id, + }).then(() => { + os.toast(i18n.tsx.renotedToX({ name: channel.name })); + }); + } + }, + })); + }, + }); } const renoteItems = [ ...normalRenoteItems, ...(channelRenoteItems.length > 0 && normalRenoteItems.length > 0) ? [{ type: 'divider' }] as MenuItem[] : [], ...channelRenoteItems, + ...(normalExternalChannelRenoteItems.length > 0 && (normalRenoteItems.length > 0 || channelRenoteItems.length > 0)) ? [{ type: 'divider' }] as MenuItem[] : [], + ...normalExternalChannelRenoteItems, ]; return { -- cgit v1.2.3-freya From d013e4516d7afb6ed4362467f69df2d79b9f0f9f Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 27 May 2024 17:19:09 +0900 Subject: enhance(frontend): お気に入りチャンネルをキャッシュするように (#13881) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/cache.ts | 1 + packages/frontend/src/pages/channel.vue | 3 +++ packages/frontend/src/pages/timeline.vue | 6 ++---- packages/frontend/src/scripts/get-note-menu.ts | 6 ++---- packages/frontend/src/ui/deck/channel-column.vue | 13 ++++++------- 5 files changed, 14 insertions(+), 15 deletions(-) (limited to 'packages/frontend/src/scripts/get-note-menu.ts') diff --git a/packages/frontend/src/cache.ts b/packages/frontend/src/cache.ts index b286528de6..bfe8fbe0e4 100644 --- a/packages/frontend/src/cache.ts +++ b/packages/frontend/src/cache.ts @@ -11,3 +11,4 @@ export const clipsCache = new Cache(1000 * 60 * 30, () export const rolesCache = new Cache(1000 * 60 * 30, () => misskeyApi('admin/roles/list')); export const userListsCache = new Cache(1000 * 60 * 30, () => misskeyApi('users/lists/list')); export const antennasCache = new Cache(1000 * 60 * 30, () => misskeyApi('antennas/list')); +export const favoritedChannelsCache = new Cache(1000 * 60 * 30, () => misskeyApi('channels/my-favorites', { limit: 100 })); diff --git a/packages/frontend/src/pages/channel.vue b/packages/frontend/src/pages/channel.vue index 611ae6feca..a895df76e8 100644 --- a/packages/frontend/src/pages/channel.vue +++ b/packages/frontend/src/pages/channel.vue @@ -83,6 +83,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; import { deviceKind } from '@/scripts/device-kind.js'; import MkNotes from '@/components/MkNotes.vue'; import { url } from '@/config.js'; +import { favoritedChannelsCache } from '@/cache.js'; import MkButton from '@/components/MkButton.vue'; import MkInput from '@/components/MkInput.vue'; import { defaultStore } from '@/store.js'; @@ -153,6 +154,7 @@ function favorite() { channelId: channel.value.id, }).then(() => { favorited.value = true; + favoritedChannelsCache.delete(); }); } @@ -168,6 +170,7 @@ async function unfavorite() { channelId: channel.value.id, }).then(() => { favorited.value = false; + favoritedChannelsCache.delete(); }); } diff --git a/packages/frontend/src/pages/timeline.vue b/packages/frontend/src/pages/timeline.vue index 48dfc1fd44..98744c6318 100644 --- a/packages/frontend/src/pages/timeline.vue +++ b/packages/frontend/src/pages/timeline.vue @@ -48,7 +48,7 @@ import { i18n } from '@/i18n.js'; import { instance } from '@/instance.js'; import { $i } from '@/account.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; -import { antennasCache, userListsCache } from '@/cache.js'; +import { antennasCache, userListsCache, favoritedChannelsCache } from '@/cache.js'; import { deviceKind } from '@/scripts/device-kind.js'; import { deepMerge } from '@/scripts/merge.js'; import { MenuItem } from '@/types/menu.js'; @@ -173,9 +173,7 @@ async function chooseAntenna(ev: MouseEvent): Promise { } async function chooseChannel(ev: MouseEvent): Promise { - const channels = await misskeyApi('channels/my-favorites', { - limit: 100, - }); + const channels = await favoritedChannelsCache.fetch(); const items: MenuItem[] = [ ...channels.map(channel => { const lastReadedAt = miLocalStorage.getItemAsJson(`channelLastReadedAt:${channel.id}`) ?? null; diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index e7c9a848e0..71ad299f50 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -16,7 +16,7 @@ import { url } from '@/config.js'; import { defaultStore, noteActions } from '@/store.js'; import { miLocalStorage } from '@/local-storage.js'; import { getUserMenu } from '@/scripts/get-user-menu.js'; -import { clipsCache } from '@/cache.js'; +import { clipsCache, favoritedChannelsCache } from '@/cache.js'; import { MenuItem } from '@/types/menu.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; import { isSupportShare } from '@/scripts/navigator.js'; @@ -603,9 +603,7 @@ export function getRenoteMenu(props: { icon: 'ti ti-repeat', text: appearNote.channel ? i18n.ts.renoteToOtherChannel : i18n.ts.renoteToChannel, children: async () => { - const channels = await misskeyApi('channels/my-favorites', { - limit: 30, - }); + const channels = await favoritedChannelsCache.fetch(); return channels.filter((channel) => { if (!appearNote.channelId) return true; return channel.id !== appearNote.channelId; diff --git a/packages/frontend/src/ui/deck/channel-column.vue b/packages/frontend/src/ui/deck/channel-column.vue index bd3b059497..28c741bba2 100644 --- a/packages/frontend/src/ui/deck/channel-column.vue +++ b/packages/frontend/src/ui/deck/channel-column.vue @@ -26,6 +26,7 @@ import { updateColumn, Column } from './deck-store.js'; import MkTimeline from '@/components/MkTimeline.vue'; import MkButton from '@/components/MkButton.vue'; import * as os from '@/os.js'; +import { favoritedChannelsCache } from '@/cache.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; @@ -42,20 +43,18 @@ if (props.column.channelId == null) { } async function setChannel() { - const channels = await misskeyApi('channels/my-favorites', { - limit: 100, - }); - const { canceled, result: channel } = await os.select({ + const channels = await favoritedChannelsCache.fetch(); + const { canceled, result: chosenChannel } = await os.select({ title: i18n.ts.selectChannel, items: channels.map(x => ({ value: x, text: x.name, })), default: props.column.channelId, }); - if (canceled) return; + if (canceled || chosenChannel == null) return; updateColumn(props.column.id, { - channelId: channel.id, - name: channel.name, + channelId: chosenChannel.id, + name: chosenChannel.name, }); } -- cgit v1.2.3-freya