Fix unreads and mark as read.
parent
0304be4221
commit
8b4b6832e9
|
|
@ -121,7 +121,7 @@
|
||||||
"react-virtuoso": "^1.10.4",
|
"react-virtuoso": "^1.10.4",
|
||||||
"redux": "^4.1.0",
|
"redux": "^4.1.0",
|
||||||
"revolt-api": "0.5.3-alpha.0-patch.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",
|
"rimraf": "^3.0.2",
|
||||||
"sass": "^1.35.1",
|
"sass": "^1.35.1",
|
||||||
"shade-blend-color": "^1.0.0",
|
"shade-blend-color": "^1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||||
|
|
||||||
import { useLayoutEffect } from "preact/hooks";
|
import { useLayoutEffect, useRef } from "preact/hooks";
|
||||||
|
|
||||||
import { dispatch } from "../../../redux";
|
import { dispatch } from "../../../redux";
|
||||||
import { Unreads } from "../../../redux/reducers/unreads";
|
import { Unreads } from "../../../redux/reducers/unreads";
|
||||||
|
|
@ -12,6 +12,7 @@ type UnreadProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useUnreads({ channel, unreads }: UnreadProps) {
|
export function useUnreads({ channel, unreads }: UnreadProps) {
|
||||||
|
const firstLoad = useRef(true);
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
function checkUnread(target: Channel) {
|
function checkUnread(target: Channel) {
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
|
|
@ -35,7 +36,8 @@ export function useUnreads({ channel, unreads }: UnreadProps) {
|
||||||
message,
|
message,
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.ack(message);
|
channel.ack(message, firstLoad.current);
|
||||||
|
firstLoad.current = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,18 +170,13 @@ function ContextMenus(props: Props) {
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const message =
|
|
||||||
typeof data.channel.last_message === "string"
|
|
||||||
? data.channel.last_message
|
|
||||||
: data.channel.last_message!._id;
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "UNREADS_MARK_READ",
|
type: "UNREADS_MARK_READ",
|
||||||
channel: data.channel._id,
|
channel: data.channel._id,
|
||||||
message,
|
message: data.channel.last_message_id!,
|
||||||
});
|
});
|
||||||
|
|
||||||
data.channel.ack(message);
|
data.channel.ack(undefined, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "mark_server_as_read":
|
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"
|
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.0-patch.0.tgz#158556832843bb06cb06a4df50ffca24ab64be3b"
|
||||||
integrity sha512-76l+kGyrUy6uGMSIziyAHE27r9gD97OEh5gSzb2OJRsQM55TN0NurAsfFIEiB9hUzDDlwsXchtJiqdS4UVAwQw==
|
integrity sha512-76l+kGyrUy6uGMSIziyAHE27r9gD97OEh5gSzb2OJRsQM55TN0NurAsfFIEiB9hUzDDlwsXchtJiqdS4UVAwQw==
|
||||||
|
|
||||||
revolt.js@5.1.0-alpha.3:
|
revolt.js@5.1.0-alpha.4:
|
||||||
version "5.1.0-alpha.3"
|
version "5.1.0-alpha.4"
|
||||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.1.0-alpha.3.tgz#67ecc2165a0a3b87d329f92857133eaec7607b47"
|
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.1.0-alpha.4.tgz#a42ea910352dd475adfed74e18f63b046cc152d4"
|
||||||
integrity sha512-dDvNDtbc8tSyzJLLSCzQ62yof5SdFWllX5jFLY+xh+e3l6cgzIhQanf9go/32HycmG9pSTbDkXGRes+ByBxA1g==
|
integrity sha512-Hxeu748qBOUkYV5oENMqpzZndJizMLwEWl9w/ahxLaxQrGVM1R1P1eKc5VU1h+4MfXbWe+Q5TS0wFZAM5Um6EA==
|
||||||
dependencies:
|
dependencies:
|
||||||
axios "^0.19.2"
|
axios "^0.19.2"
|
||||||
eventemitter3 "^4.0.7"
|
eventemitter3 "^4.0.7"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue