mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
refactor: 🎨 Refactor notes, event system and timelines
This commit is contained in:
parent
7461478170
commit
0f214b6a17
18 changed files with 266 additions and 188 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<TimelinesTimeline :timeline="timeline" :load-next="loadNext" :load-prev="loadPrev" @delete="noteDelete" />
|
||||
<TimelinesTimeline :timeline="timeline" :load-next="loadNext" :load-prev="loadPrev" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
|
@ -15,7 +15,7 @@ const { timeline, loadNext, loadPrev } = useAccountTimeline(
|
|||
timelineParameters,
|
||||
);
|
||||
|
||||
const noteDelete = async (id: string) => {
|
||||
useListen("note:delete", ({ id }) => {
|
||||
timeline.value = timeline.value.filter((note) => note.id !== id);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<TimelinesTimeline :timeline="timeline" :load-next="loadNext" :load-prev="loadPrev" @delete="noteDelete" />
|
||||
<TimelinesTimeline :timeline="timeline" :load-next="loadNext" :load-prev="loadPrev" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
|
@ -10,7 +10,7 @@ const { timeline, loadNext, loadPrev } = useLocalTimeline(
|
|||
timelineParameters,
|
||||
);
|
||||
|
||||
const noteDelete = async (id: string) => {
|
||||
useListen("note:delete", ({ id }) => {
|
||||
timeline.value = timeline.value.filter((note) => note.id !== id);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<TimelinesTimeline :timeline="timeline" :load-next="loadNext" :load-prev="loadPrev" @delete="noteDelete" />
|
||||
<TimelinesTimeline :timeline="timeline" :load-next="loadNext" :load-prev="loadPrev" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
|
@ -10,7 +10,7 @@ const { timeline, loadNext, loadPrev } = usePublicTimeline(
|
|||
timelineParameters,
|
||||
);
|
||||
|
||||
const noteDelete = async (id: string) => {
|
||||
useListen("note:delete", ({ id }) => {
|
||||
timeline.value = timeline.value.filter((note) => note.id !== id);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
<ClientOnly>
|
||||
<TransitionGroup leave-active-class="ease-in duration-200" leave-from-class="scale-100 opacity-100"
|
||||
leave-to-class="opacity-0 scale-90">
|
||||
<SocialElementsNotesNote @delete="emits('delete', note.id)" v-for="note of timeline" :key="note.id"
|
||||
:note="note" />
|
||||
<SocialElementsNotesNote v-for="note of timeline" :key="note.id" :note="note" />
|
||||
</TransitionGroup>
|
||||
<span ref="skeleton"></span>
|
||||
<SocialElementsNotesNote v-for="index of 5" v-if="!hasReachedEnd" :skeleton="true" />
|
||||
|
|
@ -25,10 +24,6 @@ const props = defineProps<{
|
|||
loadPrev: () => Promise<void>;
|
||||
}>();
|
||||
|
||||
const emits = defineEmits<{
|
||||
delete: [id: string];
|
||||
}>();
|
||||
|
||||
const isLoading = ref(true);
|
||||
|
||||
const hasReachedEnd = ref(false);
|
||||
|
|
@ -47,10 +42,14 @@ onMounted(() => {
|
|||
});
|
||||
});
|
||||
|
||||
useListen("composer:send", () => {
|
||||
props.loadPrev();
|
||||
});
|
||||
|
||||
// Every 5 seconds, load newer posts (prev)
|
||||
useIntervalFn(() => {
|
||||
props.loadPrev();
|
||||
}, 5000);
|
||||
}, 10000);
|
||||
|
||||
watch(
|
||||
() => props.timeline,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue