summaryrefslogtreecommitdiff
path: root/packages/client/src/components
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-01-10 00:45:20 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-01-10 00:45:20 +0900
commitf9882a0c5cd1364d806d2487fe5f9e4f7e2d8351 (patch)
treebd2feffa22365b320e2a7c03d1c2e93bb543b6c7 /packages/client/src/components
parentwip: migrate paging components to composition api (diff)
downloadmisskey-f9882a0c5cd1364d806d2487fe5f9e4f7e2d8351.tar.gz
misskey-f9882a0c5cd1364d806d2487fe5f9e4f7e2d8351.tar.bz2
misskey-f9882a0c5cd1364d806d2487fe5f9e4f7e2d8351.zip
wip: migrate paging components to composition api
Diffstat (limited to 'packages/client/src/components')
-rw-r--r--packages/client/src/components/notes.vue3
-rw-r--r--packages/client/src/components/notifications.vue13
-rw-r--r--packages/client/src/components/ui/pagination.vue13
3 files changed, 17 insertions, 12 deletions
diff --git a/packages/client/src/components/notes.vue b/packages/client/src/components/notes.vue
index 82703d71c7..d6107216e2 100644
--- a/packages/client/src/components/notes.vue
+++ b/packages/client/src/components/notes.vue
@@ -32,8 +32,7 @@ const props = defineProps<{
const pagingComponent = ref<InstanceType<typeof MkPagination>>();
const updated = (oldValue, newValue) => {
- const i = pagingComponent.value.items.findIndex(n => n === oldValue);
- pagingComponent.value.items[i] = newValue;
+ pagingComponent.value?.updateItem(oldValue.id, () => newValue);
};
defineExpose({
diff --git a/packages/client/src/components/notifications.vue b/packages/client/src/components/notifications.vue
index aa4b480694..31511fb515 100644
--- a/packages/client/src/components/notifications.vue
+++ b/packages/client/src/components/notifications.vue
@@ -9,7 +9,7 @@
<template #default="{ items: notifications }">
<XList v-slot="{ item: notification }" class="elsfgstc" :items="notifications" :no-gap="true">
- <XNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note" @update:note="noteUpdated(notification.note, $event)"/>
+ <XNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note" @update:note="noteUpdated(notification, $event)"/>
<XNotification v-else :key="notification.id" :notification="notification" :with-time="true" :full="true" class="_panel notification"/>
</XList>
</template>
@@ -62,12 +62,11 @@ const onNotification = (notification) => {
}
};
-const noteUpdated = (oldValue, newValue) => {
- const i = pagingComponent.value.items.findIndex(n => n.note === oldValue);
- pagingComponent.value.items[i] = {
- ...pagingComponent.value.items[i],
- note: newValue,
- };
+const noteUpdated = (item, note) => {
+ pagingComponent.value?.updateItem(item.id, old => ({
+ ...old,
+ note: note,
+ }));
};
onMounted(() => {
diff --git a/packages/client/src/components/ui/pagination.vue b/packages/client/src/components/ui/pagination.vue
index ab55b3c5bf..38e1e96041 100644
--- a/packages/client/src/components/ui/pagination.vue
+++ b/packages/client/src/components/ui/pagination.vue
@@ -205,7 +205,6 @@ const prepend = (item) => {
// TODO
} else {
const isTop = isBackTop.value || (document.body.contains(rootEl.value) && isTopVisible(rootEl.value));
- console.log(item, top);
if (isTop) {
// Prepend the item
@@ -236,7 +235,15 @@ const append = (item) => {
items.value.push(item);
};
-watch(props.pagination.params, init, { deep: true });
+const updateItem = (id, replacer: (item: any) => any): void => {
+ const i = items.value.findIndex(item => item.id === id);
+ items.value[i] = replacer(items.value[i]);
+};
+
+if (props.pagination.params && isRef(props.pagination.params)) {
+ watch(props.pagination.params, init, { deep: true });
+}
+
watch(queue, (a, b) => {
if (a.length === 0 && b.length === 0) return;
emit('queue', queue.value.length);
@@ -253,11 +260,11 @@ onDeactivated(() => {
});
defineExpose({
- items,
reload,
fetchMoreAhead,
prepend,
append,
+ updateItem,
});
</script>