e9f08c3da9
* If focus was set to document.body during archive, focus left pane * Shortcut Guide: Add space between text and shortcut highlight * Ensure that draft attachment can be closed with click on X button * Move to keyDown event for user idle checking * Additional resiliency around avatars; check for them on on-disk * Increase timeouts to preserve websocket connection * On startup, be resilient to malformed JSON in log files * Don't crash if shell.openExternal returns an error * Whenever we request a contact/group sync, also request block list * Avatar popup: Ensure styling is mouse- and keyboard-appropriate * MainHeader: Create popperRoot on demand, not on mount * CompositionInput: Disable default Ctrl-/ shortcut * Update libphonenumber
79 lines
1.4 KiB
TypeScript
79 lines
1.4 KiB
TypeScript
import { LocalizerType } from '../../types/Util';
|
|
|
|
// State
|
|
|
|
export type UserStateType = {
|
|
attachmentsPath: string;
|
|
stickersPath: string;
|
|
tempPath: string;
|
|
ourNumber: string;
|
|
platform: string;
|
|
regionCode: string;
|
|
i18n: LocalizerType;
|
|
interactionMode: 'mouse' | 'keyboard';
|
|
};
|
|
|
|
// Actions
|
|
|
|
type UserChangedActionType = {
|
|
type: 'USER_CHANGED';
|
|
payload: {
|
|
ourNumber?: string;
|
|
regionCode?: string;
|
|
interactionMode?: 'mouse' | 'keyboard';
|
|
};
|
|
};
|
|
|
|
export type UserActionType = UserChangedActionType;
|
|
|
|
// Action Creators
|
|
|
|
export const actions = {
|
|
userChanged,
|
|
};
|
|
|
|
function userChanged(attributes: {
|
|
interactionMode?: 'mouse' | 'keyboard';
|
|
ourNumber: string;
|
|
regionCode: string;
|
|
}): UserChangedActionType {
|
|
return {
|
|
type: 'USER_CHANGED',
|
|
payload: attributes,
|
|
};
|
|
}
|
|
|
|
// Reducer
|
|
|
|
function getEmptyState(): UserStateType {
|
|
return {
|
|
attachmentsPath: 'missing',
|
|
stickersPath: 'missing',
|
|
tempPath: 'missing',
|
|
ourNumber: 'missing',
|
|
regionCode: 'missing',
|
|
platform: 'missing',
|
|
interactionMode: 'mouse',
|
|
i18n: () => 'missing',
|
|
};
|
|
}
|
|
|
|
export function reducer(
|
|
state: UserStateType = getEmptyState(),
|
|
action: UserActionType
|
|
): UserStateType {
|
|
if (!state) {
|
|
return getEmptyState();
|
|
}
|
|
|
|
if (action.type === 'USER_CHANGED') {
|
|
const { payload } = action;
|
|
|
|
return {
|
|
...state,
|
|
...payload,
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|