diff --git a/frontend/app/src/components/home/ProposalGroupFilters.svelte b/frontend/app/src/components/home/ProposalGroupFilters.svelte index 854643a4bd..7f652dae90 100644 --- a/frontend/app/src/components/home/ProposalGroupFilters.svelte +++ b/frontend/app/src/components/home/ProposalGroupFilters.svelte @@ -14,7 +14,7 @@ export let selectedChat: ChatSummary; - const OC_PROPOSALS_NAME = "OpenChat Proposals"; + const OC_GOVERNANCE_CANISTER_ID = "2jvtu-yqaaa-aaaaq-aaama-cai"; type SectionLabels = Record; @@ -38,7 +38,7 @@ $: topics = [...$proposalTopicsStore]; $: groupTopics = selectedChat.kind !== "direct_chat" && - selectedChat.name === OC_PROPOSALS_NAME; + selectedChat.subtype?.governanceCanisterId === OC_GOVERNANCE_CANISTER_ID; $: grouped = [ ...client.groupBy(topics, ([id, _]) => { diff --git a/frontend/app/src/components/home/thread/Thread.svelte b/frontend/app/src/components/home/thread/Thread.svelte index 9ca2b09fd8..eaa2ee9c6c 100644 --- a/frontend/app/src/components/home/thread/Thread.svelte +++ b/frontend/app/src/components/home/thread/Thread.svelte @@ -79,6 +79,7 @@ $: readonly = client.isChatReadOnly(chat.id); $: thread = rootEvent.event.thread; $: loading = !initialised && $threadEvents.length === 0 && thread !== undefined; + $: isFollowedByMe = thread !== undefined && (thread.followedByMe || thread.participantIds.has(user.userId)); function createTestMessages(ev: CustomEvent): void { if (process.env.NODE_ENV === "production") return; @@ -271,8 +272,11 @@ me={evt.event.sender === user.userId} confirmed={isConfirmed($unconfirmed, evt)} failed={isFailed($failedMessagesStore, evt)} - readByMe={evt.event.messageId === rootEvent.event.messageId || - isReadByMe($messagesRead, evt)} + readByMe={ + evt.event.messageId === rootEvent.event.messageId || + !isFollowedByMe || + isReadByMe($messagesRead, evt) + } readByThem observer={messageObserver} focused={evt.event.kind === "message" && diff --git a/frontend/openchat-client/src/openchat.ts b/frontend/openchat-client/src/openchat.ts index 7ce1b16def..2dcdc0ffea 100644 --- a/frontend/openchat-client/src/openchat.ts +++ b/frontend/openchat-client/src/openchat.ts @@ -2174,15 +2174,6 @@ export class OpenChat extends OpenChatAgentWorker { this.config.meteredApiKey, ); - const isFollowedByMe = - this._liveState.threadsFollowedByMe.get(chat.id)?.has(threadRootMessageIndex) ?? - false; - if (isFollowedByMe) { - const lastLoadedMessageIdx = this.lastMessageIndex(this._liveState.threadEvents); - if (lastLoadedMessageIdx !== undefined) { - this.markThreadRead(chat.id, threadRootMessageIndex, lastLoadedMessageIdx); - } - } if (ascending) { this.dispatchEvent(new LoadedNewThreadMessages()); } else { @@ -2217,16 +2208,6 @@ export class OpenChat extends OpenChatAgentWorker { return [resp.events, userIds]; } - private lastMessageIndex(events: EventWrapper[]): number | undefined { - for (let i = events.length - 1; i >= 0; i--) { - const evt = events[i].event; - if (evt.kind === "message") { - return evt.messageIndex; - } - } - return undefined; - } - removeChat(chatId: ChatIdentifier): void { if (this._liveState.uninitializedDirectChats.has(chatId)) { removeUninitializedDirectChat(chatId); diff --git a/frontend/openchat-client/src/stores/markRead.ts b/frontend/openchat-client/src/stores/markRead.ts index 7c52384df5..337ddb4897 100644 --- a/frontend/openchat-client/src/stores/markRead.ts +++ b/frontend/openchat-client/src/stores/markRead.ts @@ -53,7 +53,10 @@ export class MessagesRead { } updateThread(rootIndex: number, readUpTo: number): void { - this.threads[rootIndex] = readUpTo; + const current = this.threads[rootIndex]; + if (current === undefined || current < readUpTo) { + this.threads[rootIndex] = readUpTo; + } } setThreads(threads: ThreadRead[]): void { @@ -378,7 +381,7 @@ export class MessageReadTracker { return this.waiting.get(context)?.has(messageId) ?? false; } else if (context.threadRootMessageIndex !== undefined) { const serverState = this.serverState.get(context.chatId); - if ((serverState?.threads[context.threadRootMessageIndex] ?? -1) > messageIndex) + if ((serverState?.threads[context.threadRootMessageIndex] ?? -1) >= messageIndex) return true; const localState = this.state.get(context.chatId); if ((localState?.threads[context.threadRootMessageIndex] ?? -1) >= messageIndex)