enhance(frontend): お気に入りチャンネルをキャッシュするように (#13881)
This commit is contained in:
parent
805a11aadb
commit
d013e4516d
@ -11,3 +11,4 @@ export const clipsCache = new Cache<Misskey.entities.Clip[]>(1000 * 60 * 30, ()
|
||||
export const rolesCache = new Cache(1000 * 60 * 30, () => misskeyApi('admin/roles/list'));
|
||||
export const userListsCache = new Cache<Misskey.entities.UserList[]>(1000 * 60 * 30, () => misskeyApi('users/lists/list'));
|
||||
export const antennasCache = new Cache<Misskey.entities.Antenna[]>(1000 * 60 * 30, () => misskeyApi('antennas/list'));
|
||||
export const favoritedChannelsCache = new Cache<Misskey.entities.Channel[]>(1000 * 60 * 30, () => misskeyApi('channels/my-favorites', { limit: 100 }));
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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<void> {
|
||||
}
|
||||
|
||||
async function chooseChannel(ev: MouseEvent): Promise<void> {
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user