diff --git a/package.json b/package.json index bcaeeec8..7f0e12ac 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/navigation/left/common.ts b/src/components/navigation/left/common.ts index 80d304ac..443f0e1c 100644 --- a/src/components/navigation/left/common.ts +++ b/src/components/navigation/left/common.ts @@ -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; } } } diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index f8feeeee..08e77733 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -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": diff --git a/yarn.lock b/yarn.lock index c17eb543..6a3e59bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"