mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-04-28 08:10:36 +00:00
Move typing indicator into revolt.js
This commit is contained in:
@@ -14,7 +14,6 @@ import { QueuedMessage } from "./reducers/queue";
|
||||
import { SectionToggle } from "./reducers/section_toggle";
|
||||
import { Settings } from "./reducers/settings";
|
||||
import { SyncOptions } from "./reducers/sync";
|
||||
import { Typing } from "./reducers/typing";
|
||||
import { Unreads } from "./reducers/unreads";
|
||||
|
||||
export type State = {
|
||||
@@ -24,7 +23,6 @@ export type State = {
|
||||
settings: Settings;
|
||||
unreads: Unreads;
|
||||
queue: QueuedMessage[];
|
||||
typing: Typing;
|
||||
drafts: Drafts;
|
||||
sync: SyncOptions;
|
||||
experiments: ExperimentOptions;
|
||||
|
||||
@@ -12,7 +12,6 @@ import { sectionToggle, SectionToggleAction } from "./section_toggle";
|
||||
import { config, ConfigAction } from "./server_config";
|
||||
import { settings, SettingsAction } from "./settings";
|
||||
import { sync, SyncAction } from "./sync";
|
||||
import { typing, TypingAction } from "./typing";
|
||||
import { unreads, UnreadsAction } from "./unreads";
|
||||
|
||||
export default combineReducers({
|
||||
@@ -22,7 +21,6 @@ export default combineReducers({
|
||||
settings,
|
||||
unreads,
|
||||
queue,
|
||||
typing,
|
||||
drafts,
|
||||
sync,
|
||||
experiments,
|
||||
@@ -38,7 +36,6 @@ export type Action =
|
||||
| SettingsAction
|
||||
| UnreadsAction
|
||||
| QueueAction
|
||||
| TypingAction
|
||||
| DraftAction
|
||||
| SyncAction
|
||||
| ExperimentsAction
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
export type TypingUser = { id: string; started: number };
|
||||
export type Typing = { [key: string]: TypingUser[] };
|
||||
|
||||
export type TypingAction =
|
||||
| { type: undefined }
|
||||
| {
|
||||
type: "TYPING_START";
|
||||
channel: string;
|
||||
user: string;
|
||||
}
|
||||
| {
|
||||
type: "TYPING_STOP";
|
||||
channel: string;
|
||||
user: string;
|
||||
}
|
||||
| {
|
||||
type: "RESET";
|
||||
};
|
||||
|
||||
export function typing(state: Typing = {}, action: TypingAction): Typing {
|
||||
switch (action.type) {
|
||||
case "TYPING_START":
|
||||
return {
|
||||
...state,
|
||||
[action.channel]: [
|
||||
...(state[action.channel] ?? []).filter(
|
||||
(x) => x.id !== action.user,
|
||||
),
|
||||
{
|
||||
id: action.user,
|
||||
started: +new Date(),
|
||||
},
|
||||
],
|
||||
};
|
||||
case "TYPING_STOP":
|
||||
return {
|
||||
...state,
|
||||
[action.channel]:
|
||||
state[action.channel]?.filter(
|
||||
(x) => x.id !== action.user,
|
||||
) ?? [],
|
||||
};
|
||||
case "RESET":
|
||||
return {};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user