mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-25 23:22:06 -05:00
Fix unreads and mark as read.
This commit is contained in:
parent
fc03336ea3
commit
4b8ad44aa9
4 changed files with 11 additions and 14 deletions
|
@ -121,7 +121,7 @@
|
|||
"react-virtuoso": "^1.10.4",
|
||||
"redux": "^4.1.0",
|
||||
"revolt-api": "0.5.3-alpha.0-patch.0",
|
||||
"revolt.js": "5.1.0-alpha.3",
|
||||
"revolt.js": "5.1.0-alpha.4",
|
||||
"rimraf": "^3.0.2",
|
||||
"sass": "^1.35.1",
|
||||
"shade-blend-color": "^1.0.0",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,18 +170,13 @@ function ContextMenus(props: Props) {
|
|||
)
|
||||
return;
|
||||
|
||||
const message =
|
||||
typeof data.channel.last_message === "string"
|
||||
? data.channel.last_message
|
||||
: data.channel.last_message!._id;
|
||||
|
||||
dispatch({
|
||||
type: "UNREADS_MARK_READ",
|
||||
channel: data.channel._id,
|
||||
message,
|
||||
message: data.channel.last_message_id!,
|
||||
});
|
||||
|
||||
data.channel.ack(message);
|
||||
data.channel.ack(undefined, true);
|
||||
}
|
||||
break;
|
||||
case "mark_server_as_read":
|
||||
|
|
|
@ -3659,10 +3659,10 @@ revolt-api@0.5.3-alpha.0-patch.0:
|
|||
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.0-patch.0.tgz#158556832843bb06cb06a4df50ffca24ab64be3b"
|
||||
integrity sha512-76l+kGyrUy6uGMSIziyAHE27r9gD97OEh5gSzb2OJRsQM55TN0NurAsfFIEiB9hUzDDlwsXchtJiqdS4UVAwQw==
|
||||
|
||||
revolt.js@5.1.0-alpha.3:
|
||||
version "5.1.0-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.1.0-alpha.3.tgz#67ecc2165a0a3b87d329f92857133eaec7607b47"
|
||||
integrity sha512-dDvNDtbc8tSyzJLLSCzQ62yof5SdFWllX5jFLY+xh+e3l6cgzIhQanf9go/32HycmG9pSTbDkXGRes+ByBxA1g==
|
||||
revolt.js@5.1.0-alpha.4:
|
||||
version "5.1.0-alpha.4"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.1.0-alpha.4.tgz#a42ea910352dd475adfed74e18f63b046cc152d4"
|
||||
integrity sha512-Hxeu748qBOUkYV5oENMqpzZndJizMLwEWl9w/ahxLaxQrGVM1R1P1eKc5VU1h+4MfXbWe+Q5TS0wFZAM5Um6EA==
|
||||
dependencies:
|
||||
axios "^0.19.2"
|
||||
eventemitter3 "^4.0.7"
|
||||
|
|
Loading…
Reference in a new issue