fix
This commit is contained in:
@@ -583,6 +583,7 @@ const DesktopWorkspace = ({
|
|||||||
helpOpen = false,
|
helpOpen = false,
|
||||||
onHelpClose = null,
|
onHelpClose = null,
|
||||||
tenantId = null,
|
tenantId = null,
|
||||||
|
viewId = 'default',
|
||||||
}) => {
|
}) => {
|
||||||
const items = useMemo(() => (searchResults ? searchResults : documents), [documents, searchResults]);
|
const items = useMemo(() => (searchResults ? searchResults : documents), [documents, searchResults]);
|
||||||
|
|
||||||
@@ -628,11 +629,12 @@ const DesktopWorkspace = ({
|
|||||||
}, [documentLookup]);
|
}, [documentLookup]);
|
||||||
|
|
||||||
const storageKey = useMemo(() => {
|
const storageKey = useMemo(() => {
|
||||||
if (!tenantId) {
|
if (!tenantId || !viewId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return `papercrate.desk-layout.${tenantId}`;
|
const normalizedViewId = encodeURIComponent(String(viewId));
|
||||||
}, [tenantId]);
|
return `papercrate.desk-layout.${tenantId}.${normalizedViewId}`;
|
||||||
|
}, [tenantId, viewId]);
|
||||||
|
|
||||||
const initialPersistedLayout = useMemo(() => {
|
const initialPersistedLayout = useMemo(() => {
|
||||||
if (!storageKey || typeof window === 'undefined') {
|
if (!storageKey || typeof window === 'undefined') {
|
||||||
@@ -1173,7 +1175,7 @@ const recalcVisibleDocIds = useCallback(() => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
layoutDirtyRef.current = false;
|
layoutDirtyRef.current = false;
|
||||||
const payload = {};
|
const merged = new Map(persistedLayoutRef.current);
|
||||||
snapshot.forEach((entry, docId) => {
|
snapshot.forEach((entry, docId) => {
|
||||||
if (!docId || !entry) {
|
if (!docId || !entry) {
|
||||||
return;
|
return;
|
||||||
@@ -1183,18 +1185,21 @@ const recalcVisibleDocIds = useCallback(() => {
|
|||||||
if (!Number.isFinite(centerX) || !Number.isFinite(centerY)) {
|
if (!Number.isFinite(centerX) || !Number.isFinite(centerY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
payload[docId] = {
|
const rotation = Number.isFinite(Number(entry.rotation)) ? Number(entry.rotation) : 0;
|
||||||
centerX,
|
const z = Number.isFinite(Number(entry.z)) ? Number(entry.z) : undefined;
|
||||||
centerY,
|
merged.set(docId, { centerX, centerY, rotation, z });
|
||||||
rotation: Number.isFinite(Number(entry.rotation)) ? Number(entry.rotation) : 0,
|
});
|
||||||
z: Number.isFinite(Number(entry.z)) ? Number(entry.z) : undefined,
|
|
||||||
};
|
const payload = {};
|
||||||
|
merged.forEach((entry, docId) => {
|
||||||
|
if (!docId || !entry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
payload[docId] = entry;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
window.localStorage.setItem(storageKey, JSON.stringify(payload));
|
window.localStorage.setItem(storageKey, JSON.stringify(payload));
|
||||||
persistedLayoutRef.current = new Map(
|
persistedLayoutRef.current = merged;
|
||||||
Object.entries(payload).map(([id, value]) => [id, value]),
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('[desk] Failed to persist desk layout', error);
|
console.warn('[desk] Failed to persist desk layout', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4865,6 +4865,23 @@ const AppLayout = () => {
|
|||||||
setDeskHelpOpen(false);
|
setDeskHelpOpen(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const deskViewId = useMemo(() => {
|
||||||
|
if (showingSearchResults) {
|
||||||
|
const trimmedQuery = searchQuery.trim();
|
||||||
|
const tagsKey = [...activeTagFilters].sort().join(',');
|
||||||
|
const correspondentsKey = [...activeCorrespondentFilters].sort().join(',');
|
||||||
|
return `search:${trimmedQuery}|tags:${tagsKey}|corr:${correspondentsKey}`;
|
||||||
|
}
|
||||||
|
const folderKey = selectedFolder && selectedFolder !== '' ? selectedFolder : 'root';
|
||||||
|
return `folder:${folderKey}`;
|
||||||
|
}, [
|
||||||
|
showingSearchResults,
|
||||||
|
searchQuery,
|
||||||
|
activeTagFilters,
|
||||||
|
activeCorrespondentFilters,
|
||||||
|
selectedFolder,
|
||||||
|
]);
|
||||||
|
|
||||||
const deskWorkspaceProps = useMemo(
|
const deskWorkspaceProps = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
documents,
|
documents,
|
||||||
@@ -4883,6 +4900,7 @@ const AppLayout = () => {
|
|||||||
helpOpen: deskHelpOpen,
|
helpOpen: deskHelpOpen,
|
||||||
onHelpClose: handleDeskHelpClose,
|
onHelpClose: handleDeskHelpClose,
|
||||||
tenantId: currentTenantId,
|
tenantId: currentTenantId,
|
||||||
|
viewId: deskViewId,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
onClearSelection: clearDocumentSelection,
|
onClearSelection: clearDocumentSelection,
|
||||||
detailPanelOpen,
|
detailPanelOpen,
|
||||||
@@ -4910,6 +4928,7 @@ const AppLayout = () => {
|
|||||||
handleDeskHelpOpen,
|
handleDeskHelpOpen,
|
||||||
handleDeskHelpClose,
|
handleDeskHelpClose,
|
||||||
currentTenantId,
|
currentTenantId,
|
||||||
|
deskViewId,
|
||||||
deskHelpOpen,
|
deskHelpOpen,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
clearDocumentSelection,
|
clearDocumentSelection,
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ const useDocumentDrag = () => {
|
|||||||
|
|
||||||
const rotation = simulationState.rotation;
|
const rotation = simulationState.rotation;
|
||||||
layoutRef.current.set(docId, { ...entry, rotation });
|
layoutRef.current.set(docId, { ...entry, rotation });
|
||||||
|
markLayoutDirty?.();
|
||||||
|
|
||||||
const node = itemRefs.current.get(docId);
|
const node = itemRefs.current.get(docId);
|
||||||
if (node) {
|
if (node) {
|
||||||
@@ -185,7 +186,7 @@ const useDocumentDrag = () => {
|
|||||||
const isSettled = Math.abs(angularVelocity) < SETTLE_ANGULAR_VELOCITY;
|
const isSettled = Math.abs(angularVelocity) < SETTLE_ANGULAR_VELOCITY;
|
||||||
return isSettled;
|
return isSettled;
|
||||||
},
|
},
|
||||||
[itemRefs, layoutRef],
|
[itemRefs, layoutRef, markLayoutDirty],
|
||||||
);
|
);
|
||||||
|
|
||||||
const startInertiaAnimation = useCallback(
|
const startInertiaAnimation = useCallback(
|
||||||
@@ -627,6 +628,8 @@ const useDocumentDrag = () => {
|
|||||||
item.displayRotation += (item.targetRotation - item.displayRotation) * rotationBlend;
|
item.displayRotation += (item.targetRotation - item.displayRotation) * rotationBlend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
markLayoutDirty?.();
|
||||||
|
|
||||||
const entryItem = layoutRef.current.get(item.docId) || {};
|
const entryItem = layoutRef.current.get(item.docId) || {};
|
||||||
layoutRef.current.set(item.docId, {
|
layoutRef.current.set(item.docId, {
|
||||||
...entryItem,
|
...entryItem,
|
||||||
@@ -780,6 +783,8 @@ const useDocumentDrag = () => {
|
|||||||
const pointerInsideCard =
|
const pointerInsideCard =
|
||||||
Math.abs(pointerLocalX) <= halfWidth && Math.abs(pointerLocalY) <= halfHeight;
|
Math.abs(pointerLocalX) <= halfWidth && Math.abs(pointerLocalY) <= halfHeight;
|
||||||
|
|
||||||
|
markLayoutDirty?.();
|
||||||
|
|
||||||
const currentTimestamp =
|
const currentTimestamp =
|
||||||
typeof event.timeStamp === 'number' && Number.isFinite(event.timeStamp)
|
typeof event.timeStamp === 'number' && Number.isFinite(event.timeStamp)
|
||||||
? event.timeStamp
|
? event.timeStamp
|
||||||
@@ -829,6 +834,7 @@ const useDocumentDrag = () => {
|
|||||||
recalcVisibleDocIds,
|
recalcVisibleDocIds,
|
||||||
debugDrag,
|
debugDrag,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
|
markLayoutDirty,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user