removed unused files, unnecessary exports and renamed ownProps (#1225)

* remove unused files and rename ownProps

* restore unused icons
This commit is contained in:
Weiko
2023-08-15 17:02:02 -07:00
committed by GitHub
parent c9549c3833
commit aa1f9bcab3
41 changed files with 117 additions and 543 deletions

View File

@ -2,13 +2,6 @@ import { AppHotkeyScope } from '../types/AppHotkeyScope';
import { CustomHotkeyScopes } from '../types/CustomHotkeyScope';
import { HotkeyScope } from '../types/HotkeyScope';
export const INITIAL_HOTKEYS_SCOPES: string[] = [AppHotkeyScope.App];
export const ALWAYS_ON_HOTKEYS_SCOPES: string[] = [
AppHotkeyScope.CommandMenu,
AppHotkeyScope.App,
];
export const DEFAULT_HOTKEYS_SCOPE_CUSTOM_SCOPES: CustomHotkeyScopes = {
commandMenu: true,
goto: false,

View File

@ -1,103 +0,0 @@
import { useHotkeysContext } from 'react-hotkeys-hook';
import { useRecoilCallback } from 'recoil';
import { internalHotkeysEnabledScopesState } from '../../states/internal/internalHotkeysEnabledScopesState';
export function useHotkeyScopes() {
const { disableScope, enableScope } = useHotkeysContext();
const disableAllHotkeyScopes = useRecoilCallback(
({ set, snapshot }) => {
return async () => {
const enabledScopes = await snapshot.getPromise(
internalHotkeysEnabledScopesState,
);
for (const enabledScope of enabledScopes) {
disableScope(enabledScope);
}
set(internalHotkeysEnabledScopesState, []);
};
},
[disableScope],
);
const enableHotkeyScope = useRecoilCallback(
({ set, snapshot }) => {
return async (scopeToEnable: string) => {
const enabledScopes = await snapshot.getPromise(
internalHotkeysEnabledScopesState,
);
if (!enabledScopes.includes(scopeToEnable)) {
enableScope(scopeToEnable);
set(internalHotkeysEnabledScopesState, [
...enabledScopes,
scopeToEnable,
]);
}
};
},
[enableScope],
);
const disableHotkeyScope = useRecoilCallback(
({ set, snapshot }) => {
return async (scopeToDisable: string) => {
const enabledScopes = await snapshot.getPromise(
internalHotkeysEnabledScopesState,
);
const scopeToRemoveIndex = enabledScopes.findIndex(
(scope) => scope === scopeToDisable,
);
if (scopeToRemoveIndex > -1) {
disableScope(scopeToDisable);
enabledScopes.splice(scopeToRemoveIndex);
set(internalHotkeysEnabledScopesState, enabledScopes);
}
};
},
[disableScope],
);
const setHotkeyScopes = useRecoilCallback(
({ set, snapshot }) => {
return async (scopesToSet: string[]) => {
const enabledScopes = await snapshot.getPromise(
internalHotkeysEnabledScopesState,
);
const scopesToDisable = enabledScopes.filter(
(enabledScope) => !scopesToSet.includes(enabledScope),
);
const scopesToEnable = scopesToSet.filter(
(scopeToSet) => !enabledScopes.includes(scopeToSet),
);
for (const scopeToDisable of scopesToDisable) {
disableScope(scopeToDisable);
}
for (const scopeToEnable of scopesToEnable) {
enableScope(scopeToEnable);
}
set(internalHotkeysEnabledScopesState, scopesToSet);
};
},
[disableScope, enableScope],
);
return {
disableAllHotkeyScopes,
enableHotkeyScope,
disableHotkeyScope,
setHotkeyScopes,
};
}

View File

@ -1,8 +0,0 @@
import { HotkeyScope } from '../types/HotkeyScope';
export function isSameHotkeyScope(
hotkeyScope1: HotkeyScope | undefined | null,
hotkeyScope2: HotkeyScope | undefined | null,
): boolean {
return JSON.stringify(hotkeyScope1) === JSON.stringify(hotkeyScope2);
}

View File

@ -1,12 +0,0 @@
import { useLocation } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { currentPageLocationState } from '../states/currentPageLocationState';
export function useIsPageLoading() {
const currentLocation = useLocation().pathname;
const currentPageLocation = useRecoilValue(currentPageLocationState);
return currentLocation !== currentPageLocation;
}

View File

@ -1,13 +0,0 @@
import { RecoilState, Snapshot } from 'recoil';
export function getSnapshotScopedState<T>({
snapshot,
state,
contextScopeId,
}: {
snapshot: Snapshot;
state: (scopeId: string) => RecoilState<T>;
contextScopeId: string;
}) {
return snapshot.getLoadable(state(contextScopeId)).valueOrThrow();
}

View File

@ -1,11 +0,0 @@
import { RecoilState, Snapshot } from 'recoil';
export function getSnapshotState<T>({
snapshot,
state,
}: {
snapshot: Snapshot;
state: RecoilState<T>;
}) {
return snapshot.getLoadable(state).valueOrThrow();
}