reduce requests to retrieve timeline name
This commit is contained in:
parent
f105bd51ce
commit
a64ed05453
|
@ -62,6 +62,8 @@ export type Column = {
|
||||||
withSensitive?: boolean;
|
withSensitive?: boolean;
|
||||||
onlyFiles?: boolean;
|
onlyFiles?: boolean;
|
||||||
soundSetting?: SoundStore;
|
soundSetting?: SoundStore;
|
||||||
|
// The cache for the name of the antenna, channel, list, or role
|
||||||
|
timelineNameCache?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const _currentProfile = prefer.s['deck.profiles'].find(p => p.name === prefer.s['deck.profile']);
|
const _currentProfile = prefer.s['deck.profiles'].find(p => p.name === prefer.s['deck.profile']);
|
||||||
|
|
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
||||||
<template #header>
|
<template #header>
|
||||||
<i class="ti ti-antenna"></i><span style="margin-left: 8px;">{{ column.name || antennaName || i18n.ts._deck._columns.antenna }}</span>
|
<i class="ti ti-antenna"></i><span style="margin-left: 8px;">{{ column.name || column.timelineNameCache || i18n.ts._deck._columns.antenna }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<MkTimeline v-if="column.antennaId" ref="timeline" src="antenna" :antenna="column.antennaId" @note="onNote"/>
|
<MkTimeline v-if="column.antennaId" ref="timeline" src="antenna" :antenna="column.antennaId" @note="onNote"/>
|
||||||
|
@ -36,21 +36,16 @@ const props = defineProps<{
|
||||||
|
|
||||||
const timeline = useTemplateRef('timeline');
|
const timeline = useTemplateRef('timeline');
|
||||||
const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null, volume: 1 });
|
const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null, volume: 1 });
|
||||||
const antennaName = ref<string | null>(null);
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.column.antennaId == null) {
|
if (props.column.antennaId == null) {
|
||||||
setAntenna();
|
setAntenna();
|
||||||
|
} else if (props.column.timelineNameCache == null) {
|
||||||
|
misskeyApi('antennas/show', { antennaId: props.column.antennaId })
|
||||||
|
.then(value => updateColumn(props.column.id, { timelineNameCache: value.name }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch([() => props.column.name, () => props.column.antennaId], () => {
|
|
||||||
if (!props.column.name && props.column.antennaId) {
|
|
||||||
misskeyApi('antennas/show', { antennaId: props.column.antennaId })
|
|
||||||
.then(value => antennaName.value = value.name);
|
|
||||||
}
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
watch(soundSetting, v => {
|
watch(soundSetting, v => {
|
||||||
updateColumn(props.column.id, { soundSetting: v });
|
updateColumn(props.column.id, { soundSetting: v });
|
||||||
});
|
});
|
||||||
|
@ -78,6 +73,7 @@ async function setAntenna() {
|
||||||
antennasCache.delete();
|
antennasCache.delete();
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
antennaId: newAntenna.id,
|
antennaId: newAntenna.id,
|
||||||
|
timelineNameCache: newAntenna.name,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
closed: () => {
|
closed: () => {
|
||||||
|
@ -89,6 +85,7 @@ async function setAntenna() {
|
||||||
|
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
antennaId: antenna.id,
|
antennaId: antenna.id,
|
||||||
|
timelineNameCache: antenna.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
||||||
<template #header>
|
<template #header>
|
||||||
<i class="ti ti-device-tv"></i><span style="margin-left: 8px;">{{ column.name || channel?.name || i18n.ts._deck._columns.channel }}</span>
|
<i class="ti ti-device-tv"></i><span style="margin-left: 8px;">{{ column.name || column.timelineNameCache || i18n.ts._deck._columns.channel }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="column.channelId">
|
<template v-if="column.channelId">
|
||||||
|
@ -47,16 +47,12 @@ const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null,
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.column.channelId == null) {
|
if (props.column.channelId == null) {
|
||||||
setChannel();
|
setChannel();
|
||||||
|
} else if (!props.column.name && props.column.channelId) {
|
||||||
|
misskeyApi('channels/show', { channelId: props.column.channelId })
|
||||||
|
.then(value => updateColumn(props.column.id, { timelineNameCache: value.name }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch([() => props.column.name, () => props.column.channelId], () => {
|
|
||||||
if (!props.column.name && props.column.channelId) {
|
|
||||||
misskeyApi('channels/show', { channelId: props.column.channelId })
|
|
||||||
.then(value => channel.value = value);
|
|
||||||
}
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
watch(soundSetting, v => {
|
watch(soundSetting, v => {
|
||||||
updateColumn(props.column.id, { soundSetting: v });
|
updateColumn(props.column.id, { soundSetting: v });
|
||||||
});
|
});
|
||||||
|
@ -73,7 +69,7 @@ async function setChannel() {
|
||||||
if (canceled || chosenChannel == null) return;
|
if (canceled || chosenChannel == null) return;
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
channelId: chosenChannel.id,
|
channelId: chosenChannel.id,
|
||||||
name: chosenChannel.name,
|
timelineNameCache: chosenChannel.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
||||||
<template #header>
|
<template #header>
|
||||||
<i class="ti ti-list"></i><span style="margin-left: 8px;">{{ (column.name || listName) ?? i18n.ts._deck._columns.list }}</span>
|
<i class="ti ti-list"></i><span style="margin-left: 8px;">{{ column.name || column.timelineNameCache || i18n.ts._deck._columns.list }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<MkTimeline v-if="column.listId" ref="timeline" src="list" :list="column.listId" :withRenotes="withRenotes" @note="onNote"/>
|
<MkTimeline v-if="column.listId" ref="timeline" src="list" :list="column.listId" :withRenotes="withRenotes" @note="onNote"/>
|
||||||
|
@ -37,21 +37,16 @@ const props = defineProps<{
|
||||||
const timeline = useTemplateRef('timeline');
|
const timeline = useTemplateRef('timeline');
|
||||||
const withRenotes = ref(props.column.withRenotes ?? true);
|
const withRenotes = ref(props.column.withRenotes ?? true);
|
||||||
const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null, volume: 1 });
|
const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null, volume: 1 });
|
||||||
const listName = ref<string | null>(null);
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.column.listId == null) {
|
if (props.column.listId == null) {
|
||||||
setList();
|
setList();
|
||||||
|
} else if (props.column.timelineNameCache == null) {
|
||||||
|
misskeyApi('users/lists/show', { listId: props.column.listId })
|
||||||
|
.then(value => updateColumn(props.column.id, { timelineNameCache: value.name }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch([() => props.column.name, () => props.column.listId], () => {
|
|
||||||
if (!props.column.name && props.column.listId) {
|
|
||||||
misskeyApi('users/lists/show', { listId: props.column.listId })
|
|
||||||
.then(value => listName.value = value.name);
|
|
||||||
}
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
watch(withRenotes, v => {
|
watch(withRenotes, v => {
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
withRenotes: v,
|
withRenotes: v,
|
||||||
|
@ -90,10 +85,12 @@ async function setList() {
|
||||||
|
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
listId: res.id,
|
listId: res.id,
|
||||||
|
timelineNameCache: res.name,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
listId: list.id,
|
listId: list.id,
|
||||||
|
timelineNameCache: list.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="async () => { await timeline?.reloadTimeline() }">
|
||||||
<template #header>
|
<template #header>
|
||||||
<i class="ti ti-badge"></i><span style="margin-left: 8px;">{{ column.name || roleName || i18n.ts._deck._columns.roleTimeline }}</span>
|
<i class="ti ti-badge"></i><span style="margin-left: 8px;">{{ column.name || column.timelineNameCache || i18n.ts._deck._columns.roleTimeline }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<MkTimeline v-if="column.roleId" ref="timeline" src="role" :role="column.roleId" @note="onNote"/>
|
<MkTimeline v-if="column.roleId" ref="timeline" src="role" :role="column.roleId" @note="onNote"/>
|
||||||
|
@ -34,21 +34,16 @@ const props = defineProps<{
|
||||||
|
|
||||||
const timeline = useTemplateRef('timeline');
|
const timeline = useTemplateRef('timeline');
|
||||||
const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null, volume: 1 });
|
const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null, volume: 1 });
|
||||||
const roleName = ref<string | null>(null);
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.column.roleId == null) {
|
if (props.column.roleId == null) {
|
||||||
setRole();
|
setRole();
|
||||||
|
} else if (props.column.timelineNameCache == null) {
|
||||||
|
misskeyApi('roles/show', { roleId: props.column.roleId })
|
||||||
|
.then(value => updateColumn(props.column.id, { timelineNameCache: value.name }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch([() => props.column.name, () => props.column.roleId], () => {
|
|
||||||
if (!props.column.name && props.column.roleId) {
|
|
||||||
misskeyApi('roles/show', { roleId: props.column.roleId })
|
|
||||||
.then(value => roleName.value = value.name);
|
|
||||||
}
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
watch(soundSetting, v => {
|
watch(soundSetting, v => {
|
||||||
updateColumn(props.column.id, { soundSetting: v });
|
updateColumn(props.column.id, { soundSetting: v });
|
||||||
});
|
});
|
||||||
|
@ -65,6 +60,7 @@ async function setRole() {
|
||||||
if (canceled || role == null) return;
|
if (canceled || role == null) return;
|
||||||
updateColumn(props.column.id, {
|
updateColumn(props.column.id, {
|
||||||
roleId: role.id,
|
roleId: role.id,
|
||||||
|
timelineNameCache: role.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue