fuck
This commit is contained in:
@@ -16,7 +16,7 @@ export const resolveApiPath = (path = '') => path;
|
||||
const makeRowKey = (type, id) =>
|
||||
id ? `${type}${ROW_KEY_SEPARATOR}${id}` : `${type}${ROW_KEY_SEPARATOR}`;
|
||||
|
||||
const normalizeRowKey = (key: string | number | null | undefined) => String(key ?? '');
|
||||
const normalizeRowKey = (key: string | number | null) => String(key ?? '');
|
||||
|
||||
const getRowType = (key) => normalizeRowKey(key).split(ROW_KEY_SEPARATOR, 1)[0] ?? '';
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ type PreviewEntry = {
|
||||
canGoNext?: boolean;
|
||||
goPrev?: () => void;
|
||||
goNext?: () => void;
|
||||
} | null;
|
||||
};
|
||||
|
||||
interface AssetManagerLike {
|
||||
hydrateDetail: (payload: unknown) => { document?: DocumentLike } | null | undefined;
|
||||
hydrateDocument: (payload: unknown) => DocumentLike | null | undefined;
|
||||
hydrateDetail: (payload: unknown) => { document?: DocumentLike } | null;
|
||||
hydrateDocument: (payload: unknown) => DocumentLike | null;
|
||||
}
|
||||
|
||||
interface ApiClient {
|
||||
@@ -60,10 +60,10 @@ interface UseDocumentPreviewArgs {
|
||||
interface UseDocumentPreviewResult {
|
||||
previewEntries: Map<DocumentId, PreviewEntry>;
|
||||
previewDocuments: Map<DocumentId, DocumentLike>;
|
||||
ensurePreviewUrl: (documentId: DocumentId | null, options?: { force?: boolean }) => Promise<PreviewEntry | null>;
|
||||
ensurePreviewData: (documentId: DocumentId | null) => Promise<DocumentLike | null>;
|
||||
openDocumentPreview: (documentId: DocumentId | null, options?: { replace?: boolean }) => void;
|
||||
closeDocumentPreview: (folderId?: FolderId | null) => void;
|
||||
ensurePreviewUrl: (documentId: DocumentId, options?: { force?: boolean }) => Promise<PreviewEntry | null>;
|
||||
ensurePreviewData: (documentId: DocumentId) => Promise<DocumentLike | null>;
|
||||
openDocumentPreview: (documentId: DocumentId, options?: { replace?: boolean }) => void;
|
||||
closeDocumentPreview: (folderId?: FolderId) => void;
|
||||
resetPreviewState: () => void;
|
||||
removePreviewEntries: (ids: DocumentId[]) => void;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ const useDocumentPreview = ({
|
||||
});
|
||||
}, []);
|
||||
|
||||
const cachePreviewDocument = useCallback((doc: DocumentLike | null | undefined) => {
|
||||
const cachePreviewDocument = useCallback((doc: DocumentLike) => {
|
||||
if (!doc?.id) {
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ const useDocumentPreview = ({
|
||||
});
|
||||
}, []);
|
||||
|
||||
const removeCachedPreviewDocument = useCallback((documentId?: DocumentId | null) => {
|
||||
const removeCachedPreviewDocument = useCallback((documentId: DocumentId) => {
|
||||
if (!documentId) {
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ const useDocumentPreview = ({
|
||||
}, []);
|
||||
|
||||
const ensurePreviewUrl = useCallback(
|
||||
async (documentId: DocumentId | null, { force = false }: { force?: boolean } = {}): Promise<PreviewEntry | null> => {
|
||||
async (documentId: DocumentId, { force = false }: { force?: boolean } = {}): Promise<PreviewEntry | null> => {
|
||||
if (!documentId) return null;
|
||||
|
||||
const existing = previewEntries.get(documentId) || null;
|
||||
@@ -194,7 +194,7 @@ const useDocumentPreview = ({
|
||||
);
|
||||
|
||||
const ensurePreviewData = useCallback(
|
||||
async (documentId: DocumentId | null): Promise<DocumentLike | null> => {
|
||||
async (documentId: DocumentId): Promise<DocumentLike | null> => {
|
||||
if (!documentId) return null;
|
||||
|
||||
const findInCache = () => {
|
||||
@@ -248,7 +248,7 @@ const useDocumentPreview = ({
|
||||
);
|
||||
|
||||
const openDocumentPreview = useCallback(
|
||||
(documentId: DocumentId | null, { replace = false }: { replace?: boolean } = {}) => {
|
||||
(documentId: DocumentId, { replace = false }: { replace?: boolean } = {}) => {
|
||||
if (!documentId) return;
|
||||
detailPanelControlRef.current?.close?.();
|
||||
previewReturnPathRef.current = `${locationPathname}${locationSearch}`;
|
||||
@@ -258,7 +258,7 @@ const useDocumentPreview = ({
|
||||
);
|
||||
|
||||
const closeDocumentPreview = useCallback(
|
||||
(folderId: FolderId | null = null) => {
|
||||
(folderId?: FolderId) => {
|
||||
const fallbackPath = previewReturnPathRef.current;
|
||||
previewReturnPathRef.current = null;
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ interface SelectionEventLike {
|
||||
}
|
||||
|
||||
interface UseDocumentSelectionOptions {
|
||||
resolveDocumentRowKey: (id: DocumentId | null | undefined) => RowKey | null | undefined;
|
||||
resolveFolderRowKey: (id: DocumentId | null | undefined) => RowKey | null | undefined;
|
||||
resolveDocumentRowKey: (id: DocumentId | null) => RowKey | null;
|
||||
resolveFolderRowKey: (id: DocumentId | null) => RowKey | null;
|
||||
isDocumentRowKey: (key?: RowKey | null) => boolean;
|
||||
isFolderRowKey: (key?: RowKey | null) => boolean;
|
||||
getRowId: (key?: RowKey | null) => DocumentId | null | undefined;
|
||||
getRowId: (key?: RowKey | null) => DocumentId | null;
|
||||
initialEntries?: RowKey[];
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ export const useDocumentSelection = ({
|
||||
|
||||
const applySelection = useCallback(
|
||||
(
|
||||
rowKeys: Array<RowKey | null | undefined>,
|
||||
rowKeys: Array<RowKey | null>,
|
||||
{ anchor, interactedKeys = [] }: ApplySelectionOptions = {},
|
||||
) => {
|
||||
const visibleRowKeySet = visibleRowKeySetRef.current;
|
||||
@@ -101,7 +101,7 @@ export const useDocumentSelection = ({
|
||||
|
||||
(rowKeys || []).forEach((key) => {
|
||||
if (!key) return;
|
||||
let canonicalKey: RowKey | null | undefined = null;
|
||||
let canonicalKey: RowKey | null = null;
|
||||
if (visibleRowKeySet.has(key)) {
|
||||
canonicalKey = key;
|
||||
} else if (isDocumentRowKey(key)) {
|
||||
@@ -174,7 +174,7 @@ export const useDocumentSelection = ({
|
||||
}, [applySelection]);
|
||||
|
||||
const handleEntrySelection = useCallback(
|
||||
(rowKey: RowKey | null | undefined, event?: SelectionEventLike) => {
|
||||
(rowKey: RowKey | null, event?: SelectionEventLike) => {
|
||||
const visibleRowKeySet = visibleRowKeySetRef.current;
|
||||
const navigableRowKeys = navigableRowKeysRef.current;
|
||||
if (!rowKey || !visibleRowKeySet.has(rowKey)) {
|
||||
|
||||
@@ -9,8 +9,8 @@ interface SelectionEntry {
|
||||
}
|
||||
|
||||
interface WorkspaceSelectionOptions {
|
||||
resolveDocumentRowKey?: (id: string | number) => RowKey | null | undefined;
|
||||
resolveFolderRowKey?: (id: string | number) => RowKey | null | undefined;
|
||||
resolveDocumentRowKey?: (id: string | number) => RowKey | null;
|
||||
resolveFolderRowKey?: (id: string | number) => RowKey | null;
|
||||
isDocumentRowKey?: (key: RowKey | SelectionEntry) => boolean;
|
||||
isFolderRowKey?: (key: RowKey | SelectionEntry) => boolean;
|
||||
getRowId?: (key: RowKey | SelectionEntry) => string | number | null;
|
||||
|
||||
Reference in New Issue
Block a user