Skip to content

Commit

Permalink
Merge pull request #3785 from tloncorp/hm/thread-marking
Browse files Browse the repository at this point in the history
activity: fix thread marking
  • Loading branch information
arthyn authored Jul 22, 2024
2 parents 40d9a15 + c008cc6 commit 8a4d867
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 0 additions & 1 deletion apps/tlon-web/src/chat/ChatThread/ChatThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export default function ChatThread() {
);

const onAtBottom = useCallback((atBottom: boolean) => {
console.log('thread bottom called', atBottom);
const { threadBottom } = useChatStore.getState();
threadBottom(atBottom);
}, []);
Expand Down
2 changes: 1 addition & 1 deletion apps/tlon-web/src/diary/DiaryChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function DiaryChannel({ title }: ViewProps) {
hasNextPage,
fetchNextPage,
} = useInfinitePosts(nest);
const { markRead } = useMarkChannelRead(nest);
const { markRead } = useMarkChannelRead(nest, undefined, true);
const loadOlderNotes = useCallback(
(atBottom: boolean) => {
if (atBottom && hasNextPage) {
Expand Down
24 changes: 23 additions & 1 deletion apps/tlon-web/src/state/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ function activityVolumeUpdates(events: ActivityVolumeUpdate[]) {

function optimisticActivityUpdate(d: Activity, source: string): Activity {
const old = d[source];
if (old === undefined) {
return d;
}

return {
...d,
[source]: {
Expand Down Expand Up @@ -384,7 +388,25 @@ export function useMarkReadMutation(recursive = false) {
variables.action = variables.action || {
all: { time: null, deep: recursive },
};
queryClient.setQueryData<Activity>(unreadsKey(), (d) => {

let key = unreadsKey();

if ('thread' in variables.source || 'dm-thread' in variables.source) {
const parent =
'thread' in variables.source
? {
channel: {
group: variables.source.thread.group,
nest: variables.source.thread.channel,
},
}
: {
dm: variables.source['dm-thread'].whom,
};
key = unreadsKey('threads', sourceToString(parent));
}

queryClient.setQueryData<Activity>(key, (d) => {
if (d === undefined) {
return undefined;
}
Expand Down

0 comments on commit 8a4d867

Please sign in to comment.