diff --git a/package.json b/package.json index 937c6046..de932dc9 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "react-scroll": "^1.8.2", "redux": "^4.1.0", "revolt-api": "0.5.1-alpha.10-patch.0", - "revolt.js": "5.0.0-alpha.19", + "revolt.js": "5.0.0-alpha.20", "rimraf": "^3.0.2", "sass": "^1.35.1", "shade-blend-color": "^1.0.0", diff --git a/src/components/navigation/items/ButtonItem.tsx b/src/components/navigation/items/ButtonItem.tsx index f6d64a48..51267801 100644 --- a/src/components/navigation/items/ButtonItem.tsx +++ b/src/components/navigation/items/ButtonItem.tsx @@ -114,7 +114,7 @@ export const UserButton = observer((props: UserProps) => { }); type ChannelProps = CommonProps & { - channel: Channel & { unread?: string }; + channel: Channel; user?: User; compact?: boolean; }; @@ -140,7 +140,7 @@ export const ChannelButton = observer((props: ChannelProps) => { className={classNames(styles.item, { [styles.compact]: compact })} onContextMenu={attachContextMenu("Menu", { channel: channel._id, - unread: typeof channel.unread !== "undefined", + unread: typeof alert !== "undefined", })}> { active={active} onContextMenu={attachContextMenu("Menu", { server: entry.server._id, + unread: entry.unread, })}> { if (server) { + dispatch({ + type: "UNREADS_MARK_MULTIPLE_READ", + channels: + server.channel_ids, + }); + history.push( `/server/${server._id}/channel/${invite.channel_id}`, ); diff --git a/src/redux/reducers/unreads.ts b/src/redux/reducers/unreads.ts index 8f97301e..e7f57886 100644 --- a/src/redux/reducers/unreads.ts +++ b/src/redux/reducers/unreads.ts @@ -1,4 +1,5 @@ import type { ChannelUnread } from "revolt-api/types/Sync"; +import { ulid } from "ulid"; export interface Unreads { [key: string]: Partial>; @@ -11,6 +12,10 @@ export type UnreadsAction = channel: string; message: string; } + | { + type: "UNREADS_MARK_MULTIPLE_READ"; + channels: string[]; + } | { type: "UNREADS_SET"; unreads: ChannelUnread[]; @@ -33,6 +38,17 @@ export function unreads(state = {} as Unreads, action: UnreadsAction): Unreads { last_id: action.message, }, }; + case "UNREADS_MARK_MULTIPLE_READ": { + const newState = { ...state }; + const last_id = ulid(); + for (const channel of action.channels) { + newState[channel] = { + last_id, + }; + } + + return newState; + } case "UNREADS_SET": { const obj: Unreads = {}; for (const entry of action.unreads) { diff --git a/yarn.lock b/yarn.lock index 90c3b743..553497ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3572,10 +3572,10 @@ revolt-api@0.5.1-alpha.10-patch.0: resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.1-alpha.10-patch.0.tgz#97d31bec7dfa4573567097443acb059c4feaac20" integrity sha512-UyM890HkGlYNQOxpHuEpUsJHLt8Ujnjg9/zPEDGpbvS4iy0jmHX23Hh8tOCfb/ewxbNrtT3G1HpSWKOneW/vYg== -revolt.js@5.0.0-alpha.19: - version "5.0.0-alpha.19" - resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.19.tgz#51f75d02d173e6f6de1b10fae22ba31a99785f76" - integrity sha512-D4HWszUozO4ss252GZw1k0m8p2yjnFtzAARUGo2bJsBYlC00l61hg2xsAvXcemfFParh9x6hAK9xq7olcAt6KA== +revolt.js@5.0.0-alpha.20: + version "5.0.0-alpha.20" + resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.20.tgz#c9e80c2ea71f4d5d9e33733644a49d66b7d4d164" + integrity sha512-yZwzBsgT7yXpwftdDtDh6BTVXOPF1OiMsfz2TNsgle/Ab3SXsdR7sCNu0hbhQgjPwxmWYApZLD4RoDnvvr6TRg== dependencies: axios "^0.19.2" eventemitter3 "^4.0.7"