fix
This commit is contained in:
@@ -583,6 +583,7 @@ const DesktopWorkspace = ({
|
||||
helpOpen = false,
|
||||
onHelpClose = null,
|
||||
tenantId = null,
|
||||
viewId = 'default',
|
||||
}) => {
|
||||
const items = useMemo(() => (searchResults ? searchResults : documents), [documents, searchResults]);
|
||||
|
||||
@@ -628,11 +629,12 @@ const DesktopWorkspace = ({
|
||||
}, [documentLookup]);
|
||||
|
||||
const storageKey = useMemo(() => {
|
||||
if (!tenantId) {
|
||||
if (!tenantId || !viewId) {
|
||||
return null;
|
||||
}
|
||||
return `papercrate.desk-layout.${tenantId}`;
|
||||
}, [tenantId]);
|
||||
const normalizedViewId = encodeURIComponent(String(viewId));
|
||||
return `papercrate.desk-layout.${tenantId}.${normalizedViewId}`;
|
||||
}, [tenantId, viewId]);
|
||||
|
||||
const initialPersistedLayout = useMemo(() => {
|
||||
if (!storageKey || typeof window === 'undefined') {
|
||||
@@ -1173,7 +1175,7 @@ const recalcVisibleDocIds = useCallback(() => {
|
||||
return;
|
||||
}
|
||||
layoutDirtyRef.current = false;
|
||||
const payload = {};
|
||||
const merged = new Map(persistedLayoutRef.current);
|
||||
snapshot.forEach((entry, docId) => {
|
||||
if (!docId || !entry) {
|
||||
return;
|
||||
@@ -1183,18 +1185,21 @@ const recalcVisibleDocIds = useCallback(() => {
|
||||
if (!Number.isFinite(centerX) || !Number.isFinite(centerY)) {
|
||||
return;
|
||||
}
|
||||
payload[docId] = {
|
||||
centerX,
|
||||
centerY,
|
||||
rotation: Number.isFinite(Number(entry.rotation)) ? Number(entry.rotation) : 0,
|
||||
z: Number.isFinite(Number(entry.z)) ? Number(entry.z) : undefined,
|
||||
};
|
||||
const rotation = Number.isFinite(Number(entry.rotation)) ? Number(entry.rotation) : 0;
|
||||
const z = Number.isFinite(Number(entry.z)) ? Number(entry.z) : undefined;
|
||||
merged.set(docId, { centerX, centerY, rotation, z });
|
||||
});
|
||||
|
||||
const payload = {};
|
||||
merged.forEach((entry, docId) => {
|
||||
if (!docId || !entry) {
|
||||
return;
|
||||
}
|
||||
payload[docId] = entry;
|
||||
});
|
||||
try {
|
||||
window.localStorage.setItem(storageKey, JSON.stringify(payload));
|
||||
persistedLayoutRef.current = new Map(
|
||||
Object.entries(payload).map(([id, value]) => [id, value]),
|
||||
);
|
||||
persistedLayoutRef.current = merged;
|
||||
} catch (error) {
|
||||
console.warn('[desk] Failed to persist desk layout', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user