Import assets and add PWA.

This commit is contained in:
Paul
2021-06-18 19:25:33 +01:00
parent 27eeb3acd2
commit e7d1ada13d
59 changed files with 1958 additions and 182 deletions

View File

@@ -1,31 +1,31 @@
import { Sync } from "revolt.js/dist/api/objects";
export interface Unreads {
[key: string]: Partial<Omit<Sync.ChannelUnread, '_id'>>;
[key: string]: Partial<Omit<Sync.ChannelUnread, "_id">>;
}
export type UnreadsAction =
| { type: undefined }
| {
type: "UNREADS_MARK_READ";
channel: string;
message: string;
request: boolean;
type: "UNREADS_MARK_READ";
channel: string;
message: string;
request: boolean;
}
| {
type: "UNREADS_SET";
unreads: Sync.ChannelUnread[];
}
type: "UNREADS_SET";
unreads: Sync.ChannelUnread[];
}
| {
type: "UNREADS_MENTION";
channel: string;
message: string;
}
type: "UNREADS_MENTION";
channel: string;
message: string;
}
| {
type: "RESET";
type: "RESET";
};
export function unreads(state = {}, action: UnreadsAction): Unreads {
export function unreads(state = {} as Unreads, action: UnreadsAction): Unreads {
switch (action.type) {
case "UNREADS_MARK_READ":
if (action.request) {
@@ -35,31 +35,29 @@ export function unreads(state = {}, action: UnreadsAction): Unreads {
return {
...state,
[action.channel]: {
last_id: action.message
}
last_id: action.message,
},
};
case "UNREADS_SET":
{
const obj: Unreads = {};
for (const entry of action.unreads) {
const { _id, ...v } = entry;
obj[_id.channel] = v;
}
return obj;
case "UNREADS_SET": {
const obj: Unreads = {};
for (const entry of action.unreads) {
const { _id, ...v } = entry;
obj[_id.channel] = v;
}
case "UNREADS_MENTION":
{
const obj = (state as any)[action.channel];
return {
...state,
[action.channel]: {
...obj,
mentions: [ ...(obj?.mentions ?? []), action.message ]
}
}
}
return obj;
}
case "UNREADS_MENTION": {
const obj = state[action.channel];
return {
...state,
[action.channel]: {
...obj,
mentions: [...(obj?.mentions ?? []), action.message],
},
};
}
case "RESET":
return {};
default: