diff --git a/src/analytics.ts b/src/analytics.ts index 2d9a6cb..341a71e 100644 --- a/src/analytics.ts +++ b/src/analytics.ts @@ -2,6 +2,7 @@ import * as Sentry from '@sentry/browser' import { Middleware } from 'driver/connect.js' import { IN_PRODUCTION_MODE, VERSION } from 'env' import { platform } from 'platforms' +import { forOf } from 'utils/general' const PUBLIC_KEY = 'd22ec5c9cc874539a51c78388c12e3b0' const PROJECT_ID = '1406497' @@ -69,12 +70,7 @@ export const withErrorLog: Middleware = function withErrorLog(method, args) { ] } -export function raiseError( - error: Error, - extra?: { - [key: string]: any - }, -) { +export function raiseError(error: Error, extra?: unknown) { if (!IN_PRODUCTION_MODE || platform.isEnterprise()) { // ignore errors from enterprise to get less noise on Sentry console.error(error) @@ -83,10 +79,8 @@ export function raiseError( } Sentry.withScope(scope => { - if (extra) { - Object.keys(extra).forEach(key => { - scope.setExtra(key, extra[key]) - }) + if (typeof extra === 'object' && extra) { + forOf(extra, (key, value) => scope.setExtra(key, value)) } Sentry.captureException(error) }) diff --git a/src/components/SideBarBodyWrapper.tsx b/src/components/SideBarBodyWrapper.tsx index 78e502b..92bb720 100644 --- a/src/components/SideBarBodyWrapper.tsx +++ b/src/components/SideBarBodyWrapper.tsx @@ -7,6 +7,7 @@ import { cx } from 'utils/cx' import { setCSSVariable } from 'utils/DOMHelper' import * as features from 'utils/features' import { detectBrowser } from 'utils/general' +import { ResizeState } from 'utils/hooks/useResizeHandler' import { useConditionalHook } from '../utils/hooks/useConditionalHook' type Size = number @@ -107,6 +108,10 @@ export function SideBarBodyWrapper({ ) const dummySize: [number, number] = React.useMemo(() => [size, size], [size]) + const onResizeStateChange = React.useCallback((state: ResizeState) => { + blockLeaveRef.current = state === 'resizing' + }, []) + return (
(props: P) { const lastPropsRef = React.useRef
(props)
React.useEffect(() => {
if (IN_PRODUCTION_MODE) return
- let output: unknown[][] = []
+ const output: ([string, keyof P, P[keyof P]] | [string, keyof P, P[keyof P], P[keyof P]])[] = []
for (const key of Object.keys(props)) {
if (key === 'children') continue
const $key = key as keyof P
- if (!(key in lastPropsRef.current)) output.push([`[Added]`, key, props[$key]])
+ if (!(key in lastPropsRef.current)) output.push([`[Added]`, $key, props[$key]])
if (lastPropsRef.current[$key] !== props[$key])
- output.push([`[Updated]`, key, lastPropsRef.current[$key], props[$key]])
+ output.push([`[Updated]`, $key, lastPropsRef.current[$key], props[$key]])
}
for (const key of Object.keys(lastPropsRef.current)) {
if (key === 'children') continue
const $key = key as keyof P
- if (!(key in props)) output.push([`[Removed]`, key, props[$key]])
+ if (!(key in props)) output.push([`[Removed]`, $key, props[$key]])
}
if (output.length) {
diff --git a/src/utils/keyHelper.ts b/src/utils/keyHelper.ts
index 407d513..91f3f84 100644
--- a/src/utils/keyHelper.ts
+++ b/src/utils/keyHelper.ts
@@ -46,8 +46,8 @@ export function parseEvent(e: KeyboardEvent | React.KeyboardEvent) {
const keys = { meta, ctrl, shift, alt, [code]: true }
const combination = parse(
Object.entries(keys)
- .filter(([key, pressed]) => pressed)
- .map(([key, pressed]) => key)
+ .filter(([, pressed]) => pressed)
+ .map(([key]) => key)
.join('+'),
)
return combination
diff --git a/src/utils/parseIconMapCSV.ts b/src/utils/parseIconMapCSV.ts
index a820307..979442c 100644
--- a/src/utils/parseIconMapCSV.ts
+++ b/src/utils/parseIconMapCSV.ts
@@ -71,7 +71,7 @@ export function getFileIconURL(node: TreeNode) {
// 1. swap time with space
// 2. prevent app crash on when extension context invalidates
const extensionURL = browser.runtime.getURL('').replace(/\/$/, '')
-export function getIconURL(type: 'folder' | 'file', name: string = 'default', open?: boolean) {
+export function getIconURL(type: 'folder' | 'file', name = 'default', open?: boolean) {
const filename =
(name === 'default' ? 'default_' + type : type + '_type_' + name) +
(open ? '_opened' : '') +
diff --git a/src/utils/storageHelper.ts b/src/utils/storageHelper.ts
index e3dc40a..e393f9f 100644
--- a/src/utils/storageHelper.ts
+++ b/src/utils/storageHelper.ts
@@ -9,20 +9,12 @@ export type Storage = {
// ['platform_github.com']?: Config
}
-async function get<
- T extends {
- [key: string]: any
- }
->(mapping: string | string[] | null = null): Promise