init
This commit is contained in:
@@ -168,3 +168,20 @@ onGatewayEvent("Category", (payload) => {
|
||||
void useServerStore().fetchServerTree(category.server_id);
|
||||
}
|
||||
});
|
||||
|
||||
onGatewayEvent("ServerTree", (payload) => {
|
||||
if (payload.action !== "refresh") return;
|
||||
const serverId = String(payload.content);
|
||||
if (serverId) void useServerStore().fetchServerTree(serverId);
|
||||
});
|
||||
|
||||
onGatewayEvent("Server", (payload) => {
|
||||
if (payload.action !== "update") return;
|
||||
const updated = payload.content as Server;
|
||||
const store = useServerStore();
|
||||
const index = store.servers.findIndex(server => server.id === updated.id);
|
||||
if (index >= 0) {
|
||||
updated.unread_count ??= store.servers[index].unread_count ?? 0;
|
||||
store.servers[index] = updated;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user