This commit is contained in:
2025-11-14 02:35:17 +01:00
parent 6f4ff68062
commit a3c5494bf7
53 changed files with 269 additions and 340 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ const DocumentsRouteContent: React.FC = () => {
} = usePanelManager();
const safeSidebarProps = useMemo<Record<string, unknown>>(
() => (sidebarProps && typeof sidebarProps === 'object' ? sidebarProps : {}),
() => (sidebarProps && Object(sidebarProps) === sidebarProps ? sidebarProps : {}),
[sidebarProps],
);
+1 -1
View File
@@ -112,7 +112,7 @@ const UploadQueueOverlay = ({ queue = [], onClearQueue }: UploadQueueOverlayProp
<button
type="button"
className="icon-button ghost"
onClick={() => setCollapsed((value) => !value)}
onClick={() => setCollapsed(!collapsed)}
aria-label={collapsed ? 'Expand upload queue' : 'Collapse upload queue'}
>
{collapsed ? <BottombarExpandIcon size={16} /> : <BottombarCollapseIcon size={16} />}
+7 -7
View File
@@ -16,15 +16,15 @@ export const resolveApiPath = (path = '') => path;
const makeRowKey = (type, id) =>
id ? `${type}${ROW_KEY_SEPARATOR}${id}` : `${type}${ROW_KEY_SEPARATOR}`;
const getRowType = (key) => (
typeof key?.split === 'function' ? key.split(ROW_KEY_SEPARATOR, 1)[0] : ''
);
const normalizeRowKey = (key: string | number | null | undefined) => String(key ?? '');
const getRowType = (key) => normalizeRowKey(key).split(ROW_KEY_SEPARATOR, 1)[0] ?? '';
export const getRowId = (key) => {
if (typeof key?.indexOf !== 'function' || typeof key?.slice !== 'function') return '';
const separatorIndex = key.indexOf(ROW_KEY_SEPARATOR);
if (separatorIndex === -1) return key;
return key.slice(separatorIndex + 1);
const normalized = normalizeRowKey(key);
const separatorIndex = normalized.indexOf(ROW_KEY_SEPARATOR);
if (separatorIndex === -1) return normalized;
return normalized.slice(separatorIndex + 1);
};
export const isDocumentRowKey = (key) => getRowType(key) === DOCUMENT_ROW_PREFIX;
+1 -1
View File
@@ -43,7 +43,7 @@ type AppAction =
| { type: 'RESET_ERROR' }
| { type: 'SET_TENANTS'; tenants: Tenant[] };
const storage = typeof window !== 'undefined' ? window.sessionStorage : null;
const storage = window.sessionStorage;
const STORED_TOKEN = storage?.getItem('papercrate_token') ?? '';
let STORED_TENANT: Tenant = null;
+1 -1
View File
@@ -149,7 +149,7 @@ const useDocumentPreview = ({
const existing = previewEntries.get(documentId) || null;
const now = Date.now();
const expiresAt = typeof existing?.expiresAt === 'number' ? existing.expiresAt : null;
const expiresAt = Number.isFinite(existing?.expiresAt) ? Number(existing?.expiresAt) : null;
if (!force && existing && (!expiresAt || expiresAt > now)) {
return existing;
}
+3 -3
View File
@@ -137,7 +137,7 @@ export const useManagementModals = ({
const handleCorrespondentCreateSafe = useCallback<CorrespondentsPanelProps['onCreate']>(
async (payload) => {
if (typeof onCorrespondentCreate !== 'function') {
if (!onCorrespondentCreate) {
return undefined;
}
return onCorrespondentCreate(payload) ?? undefined;
@@ -147,7 +147,7 @@ export const useManagementModals = ({
const handleCorrespondentUpdateSafe = useCallback<CorrespondentsPanelProps['onUpdate']>(
async (id, payload) => {
if (typeof onCorrespondentUpdate !== 'function') {
if (!onCorrespondentUpdate) {
return;
}
await onCorrespondentUpdate(id, payload);
@@ -157,7 +157,7 @@ export const useManagementModals = ({
const handleCorrespondentDeleteSafe = useCallback<CorrespondentsPanelProps['onDelete']>(
async (id) => {
if (typeof onCorrespondentDelete !== 'function') {
if (!onCorrespondentDelete) {
return;
}
await onCorrespondentDelete(id);
+3 -3
View File
@@ -76,9 +76,9 @@ export const useWorkspaceSelection = ({
const selectEntry = useCallback(
(entry: SelectionEntry | string | null, event?: unknown) => {
const rowKey = typeof entry === 'string'
? entry
: entry?.rowKey ?? null;
const rowKey = entry && Object(entry) === entry
? (entry as SelectionEntry).rowKey ?? null
: (entry as string | null);
if (!rowKey) return;
handleEntrySelection(rowKey, event);
},