Skip to content

Commit

Permalink
Don't double post items
Browse files Browse the repository at this point in the history
  • Loading branch information
phazonoverload committed Oct 20, 2023
1 parent c5b7382 commit 8ab8ed9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/leapweek.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ onMounted(async () => {
async function subscribe() {
const { subscription } = await directus.subscribe('timeline', {
query: { fields: ['*'], },
query: { fields: ['*'], limit: -1 },
uid: 'timeline'
});
for await (const item of subscription) {
Expand All @@ -57,7 +57,10 @@ onMounted(async () => {
loadedResources.value = true
}
if(item.event == 'update' && item.uid == 'timeline') {
const newItems = item.data.map(it => ({...it, isNew: true }))
const newItems = item.data
.filter(it => !resources.value.find(r => r.id == it.id))
.map(it => ({...it, isNew: true }))
console.log({newItems})
resources.value = [...newItems, ...resources.value]
}
}
Expand Down Expand Up @@ -129,6 +132,7 @@ iframe#video {
border-radius: var(--rounded-lg);
}
iframe#chat {
border-radius: var(--rounded-lg);
height: 488px;
}
Expand Down

0 comments on commit 8ab8ed9

Please sign in to comment.