const updateQueue = [];
function processQueue() {
while (updateQueue.length > 0) {
const { events, payload } = updateQueue.shift();
if (events.includes("databases.default.collections.rss_articles.documents.*.delete")) {
$posts = $posts.filter(post => post.$id !== payload.$id);
} else if (events.includes("databases.*.collections.rss_articles.documents.*.create")) {
const existingPostIndex = $posts.findIndex(post => post.$id === payload.$id);
if (existingPostIndex === -1) {
$posts = [payload, ...$posts];
} else {
$posts[existingPostIndex] = payload;
}
}
}
}
function onArticleChange(response) {
updateQueue.push(response);
processQueue();
}
``` tried to come up with a queue solution, but got the same result. Got to think here..