Fix unreads and mark as read.

This commit is contained in:
Paul
2021-09-14 21:09:42 +01:00
parent 0304be4221
commit 8b4b6832e9
4 changed files with 11 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
import { reaction } from "mobx";
import { Channel } from "revolt.js/dist/maps/Channels";
import { useLayoutEffect } from "preact/hooks";
import { useLayoutEffect, useRef } from "preact/hooks";
import { dispatch } from "../../../redux";
import { Unreads } from "../../../redux/reducers/unreads";
@@ -12,6 +12,7 @@ type UnreadProps = {
};
export function useUnreads({ channel, unreads }: UnreadProps) {
const firstLoad = useRef(true);
useLayoutEffect(() => {
function checkUnread(target: Channel) {
if (!target) return;
@@ -35,7 +36,8 @@ export function useUnreads({ channel, unreads }: UnreadProps) {
message,
});
channel.ack(message);
channel.ack(message, firstLoad.current);
firstLoad.current = false;
}
}
}