mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-09 18:15:28 +00:00
Servers are also marked as read when joining them. You can now also mark DMs as read.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { ChannelUnread } from "revolt-api/types/Sync";
|
||||
import { ulid } from "ulid";
|
||||
|
||||
export interface Unreads {
|
||||
[key: string]: Partial<Omit<ChannelUnread, "_id">>;
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user