diff options
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/lib/session.svelte.js | 5 | ||||
| -rw-r--r-- | ui/lib/state/local/channels.svelte.js | 3 | ||||
| -rw-r--r-- | ui/lib/state/remote/channels.svelte.js | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/ui/lib/session.svelte.js b/ui/lib/session.svelte.js index 2dae3c4..432fad2 100644 --- a/ui/lib/session.svelte.js +++ b/ui/lib/session.svelte.js @@ -7,14 +7,13 @@ import * as r from './state/remote/state.svelte.js'; import * as l from './state/local/channels.svelte.js'; import { Watchdog } from './watchdog.js'; import { DateTime } from 'luxon'; -import { render } from '$lib/markdown.js'; class Channel { static fromRemote({ at, id, name }, messages, meta) { const sentAt = messages .filter((message) => message.channel === id) .map((message) => message.at); - const lastEventAt = Math.max(at, ...sentAt); + const lastEventAt = DateTime.max(at, ...sentAt); const lastReadAt = meta.get(id)?.lastReadAt; const hasUnreads = lastReadAt === undefined || lastEventAt > lastReadAt; @@ -114,7 +113,7 @@ class Session { onMessage(message) { const event = JSON.parse(message.data); this.remote.onEvent(event); - this.local.retainChannels(this.remote.channels.all.keys()); + this.local.retainChannels(this.remote.channels.all); this.watchdog.reset(this.heartbeatMillis()); } diff --git a/ui/lib/state/local/channels.svelte.js b/ui/lib/state/local/channels.svelte.js index d86d028..e3ee8df 100644 --- a/ui/lib/state/local/channels.svelte.js +++ b/ui/lib/state/local/channels.svelte.js @@ -82,7 +82,8 @@ export class Channels { } } - retainChannels(channelIds) { + retainChannels(channels) { + const channelIds = channels.map((channel) => channel.id); const retain = new Set(channelIds); for (const channelId of Array.from(this.all.keys())) { if (!retain.has(channelId)) { diff --git a/ui/lib/state/remote/channels.svelte.js b/ui/lib/state/remote/channels.svelte.js index 8b190dd..19946f2 100644 --- a/ui/lib/state/remote/channels.svelte.js +++ b/ui/lib/state/remote/channels.svelte.js @@ -29,10 +29,10 @@ export class Channels { } add({ at, id, name }) { - this.all.set(id, Channel.boot({ at, id, name })); + this.all.push(Channel.boot({ at, id, name })); } remove(id) { - this.all.delete(id); + this.all = this.all.filter((channel) => channel.id !== id); } } |
