mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-30 20:29:13 +01:00
enhance(frontend): お気に入りチャンネルをキャッシュするように (#13881)
This commit is contained in:
parent
805a11aadb
commit
d013e4516d
5 changed files with 14 additions and 15 deletions
|
@ -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 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 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 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 { deviceKind } from '@/scripts/device-kind.js';
|
||||||
import MkNotes from '@/components/MkNotes.vue';
|
import MkNotes from '@/components/MkNotes.vue';
|
||||||
import { url } from '@/config.js';
|
import { url } from '@/config.js';
|
||||||
|
import { favoritedChannelsCache } from '@/cache.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkInput from '@/components/MkInput.vue';
|
import MkInput from '@/components/MkInput.vue';
|
||||||
import { defaultStore } from '@/store.js';
|
import { defaultStore } from '@/store.js';
|
||||||
|
@ -153,6 +154,7 @@ function favorite() {
|
||||||
channelId: channel.value.id,
|
channelId: channel.value.id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
favorited.value = true;
|
favorited.value = true;
|
||||||
|
favoritedChannelsCache.delete();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +170,7 @@ async function unfavorite() {
|
||||||
channelId: channel.value.id,
|
channelId: channel.value.id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
favorited.value = false;
|
favorited.value = false;
|
||||||
|
favoritedChannelsCache.delete();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ import { i18n } from '@/i18n.js';
|
||||||
import { instance } from '@/instance.js';
|
import { instance } from '@/instance.js';
|
||||||
import { $i } from '@/account.js';
|
import { $i } from '@/account.js';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata.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 { deviceKind } from '@/scripts/device-kind.js';
|
||||||
import { deepMerge } from '@/scripts/merge.js';
|
import { deepMerge } from '@/scripts/merge.js';
|
||||||
import { MenuItem } from '@/types/menu.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> {
|
async function chooseChannel(ev: MouseEvent): Promise<void> {
|
||||||
const channels = await misskeyApi('channels/my-favorites', {
|
const channels = await favoritedChannelsCache.fetch();
|
||||||
limit: 100,
|
|
||||||
});
|
|
||||||
const items: MenuItem[] = [
|
const items: MenuItem[] = [
|
||||||
...channels.map(channel => {
|
...channels.map(channel => {
|
||||||
const lastReadedAt = miLocalStorage.getItemAsJson(`channelLastReadedAt:${channel.id}`) ?? null;
|
const lastReadedAt = miLocalStorage.getItemAsJson(`channelLastReadedAt:${channel.id}`) ?? null;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { url } from '@/config.js';
|
||||||
import { defaultStore, noteActions } from '@/store.js';
|
import { defaultStore, noteActions } from '@/store.js';
|
||||||
import { miLocalStorage } from '@/local-storage.js';
|
import { miLocalStorage } from '@/local-storage.js';
|
||||||
import { getUserMenu } from '@/scripts/get-user-menu.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 { MenuItem } from '@/types/menu.js';
|
||||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||||
import { isSupportShare } from '@/scripts/navigator.js';
|
import { isSupportShare } from '@/scripts/navigator.js';
|
||||||
|
@ -603,9 +603,7 @@ export function getRenoteMenu(props: {
|
||||||
icon: 'ti ti-repeat',
|
icon: 'ti ti-repeat',
|
||||||
text: appearNote.channel ? i18n.ts.renoteToOtherChannel : i18n.ts.renoteToChannel,
|
text: appearNote.channel ? i18n.ts.renoteToOtherChannel : i18n.ts.renoteToChannel,
|
||||||
children: async () => {
|
children: async () => {
|
||||||
const channels = await misskeyApi('channels/my-favorites', {
|
const channels = await favoritedChannelsCache.fetch();
|
||||||
limit: 30,
|
|
||||||
});
|
|
||||||
return channels.filter((channel) => {
|
return channels.filter((channel) => {
|
||||||
if (!appearNote.channelId) return true;
|
if (!appearNote.channelId) return true;
|
||||||
return channel.id !== appearNote.channelId;
|
return channel.id !== appearNote.channelId;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { updateColumn, Column } from './deck-store.js';
|
||||||
import MkTimeline from '@/components/MkTimeline.vue';
|
import MkTimeline from '@/components/MkTimeline.vue';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
import { favoritedChannelsCache } from '@/cache.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
|
|
||||||
|
@ -42,20 +43,18 @@ if (props.column.channelId == null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setChannel() {
|
async function setChannel() {
|
||||||
const channels = await misskeyApi('channels/my-favorites', {
|
const channels = await favoritedChannelsCache.fetch();
|
||||||
limit: 100,
|
const { canceled, result: chosenChannel } = await os.select({
|
||||||
});
|
|
||||||
const { canceled, result: channel } = await os.select({
|
|
||||||
title: i18n.ts.selectChannel,
|
title: i18n.ts.selectChannel,
|
||||||
items: channels.map(x => ({
|
items: channels.map(x => ({
|
||||||
value: x, text: x.name,
|
value: x, text: x.name,
|
||||||
})),
|
})),
|
||||||
default: props.column.channelId,
|
default: props.column.channelId,
|
||||||
});
|
});
|
||||||
if (canceled) return;
|
if (canceled || chosenChannel == null) return;
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
channelId: channel.id,
|
channelId: chosenChannel.id,
|
||||||
name: channel.name,
|
name: chosenChannel.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue