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:
Paul
2021-06-24 16:22:45 +01:00
parent 558ec17726
commit 363789c825
12 changed files with 137 additions and 34 deletions

View File

@@ -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
});
});

View File

@@ -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 };

View 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;
}
}