mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
Fix: Icons collapsing in flex.
Feature: Remember what channel was opened last. Channels: ESC to focus message box / cancel editing.
This commit is contained in:
@@ -12,6 +12,7 @@ import { SyncOptions } from "./reducers/sync";
|
||||
import { Settings } from "./reducers/settings";
|
||||
import { QueuedMessage } from "./reducers/queue";
|
||||
import { ExperimentOptions } from "./reducers/experiments";
|
||||
import { LastOpened } from "./reducers/last_opened";
|
||||
|
||||
export type State = {
|
||||
config: Core.RevoltNodeConfiguration,
|
||||
@@ -24,6 +25,7 @@ export type State = {
|
||||
drafts: Drafts;
|
||||
sync: SyncOptions;
|
||||
experiments: ExperimentOptions;
|
||||
lastOpened: LastOpened;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -51,6 +53,7 @@ store.subscribe(() => {
|
||||
drafts,
|
||||
sync,
|
||||
experiments,
|
||||
lastOpened
|
||||
} = store.getState() as State;
|
||||
|
||||
localForage.setItem("state", {
|
||||
@@ -63,5 +66,6 @@ store.subscribe(() => {
|
||||
drafts,
|
||||
sync,
|
||||
experiments,
|
||||
lastOpened
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ import { typing, TypingAction } from "./typing";
|
||||
import { drafts, DraftAction } from "./drafts";
|
||||
import { sync, SyncAction } from "./sync";
|
||||
import { experiments, ExperimentsAction } from "./experiments";
|
||||
import { lastOpened, LastOpenedAction } from "./last_opened";
|
||||
|
||||
export default combineReducers({
|
||||
config,
|
||||
@@ -23,6 +24,7 @@ export default combineReducers({
|
||||
drafts,
|
||||
sync,
|
||||
experiments,
|
||||
lastOpened
|
||||
});
|
||||
|
||||
export type Action =
|
||||
@@ -36,6 +38,7 @@ export type Action =
|
||||
| DraftAction
|
||||
| SyncAction
|
||||
| ExperimentsAction
|
||||
| LastOpenedAction
|
||||
| { type: "__INIT"; state: State };
|
||||
|
||||
export type WithDispatcher = { dispatcher: (action: Action) => void };
|
||||
|
||||
29
src/redux/reducers/last_opened.ts
Normal file
29
src/redux/reducers/last_opened.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export interface LastOpened {
|
||||
[key: string]: string
|
||||
}
|
||||
|
||||
export type LastOpenedAction =
|
||||
| { type: undefined }
|
||||
| {
|
||||
type: "LAST_OPENED_SET";
|
||||
parent: string;
|
||||
child: string;
|
||||
}
|
||||
| {
|
||||
type: "RESET";
|
||||
};
|
||||
|
||||
export function lastOpened(state = {} as LastOpened, action: LastOpenedAction): LastOpened {
|
||||
switch (action.type) {
|
||||
case "LAST_OPENED_SET": {
|
||||
return {
|
||||
...state,
|
||||
[action.parent]: action.child
|
||||
}
|
||||
}
|
||||
case "RESET":
|
||||
return {};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user