Skip to content

Commit 529d29c

Browse files
committed
fjern kommentarer og ||
1 parent c3430cd commit 529d29c

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

xp-archive/client/content/Content.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,15 @@ export const Content = () => {
6161
getDefaultView(isWebpage, hasAttachment)
6262
);
6363

64-
// Get cached state or initialize
6564
const [versionSelectorCache, setVersionSelectorCache] = useState(() => {
66-
const cache = getCachedVersionSelector(selectedContentId || '');
65+
const cache = getCachedVersionSelector(selectedContentId ?? '');
6766
return {
6867
component: cache.component,
6968
versions: cache.versions,
7069
isOpen: cache.isOpen,
7170
};
7271
});
7372

74-
// Update cache when content ID changes or new versions arrive
7573
useEffect(() => {
7674
if (prevContentIdRef.current && prevContentIdRef.current !== selectedContentId) {
7775
clearCachedVersionSelector(prevContentIdRef.current);
@@ -81,7 +79,7 @@ export const Content = () => {
8179
setVersionSelectorCache((prev) => ({
8280
component: null,
8381
versions: data.versions,
84-
isOpen: prev.isOpen, // Always preserve open state
82+
isOpen: prev.isOpen,
8583
}));
8684
}
8785

@@ -130,7 +128,6 @@ export const Content = () => {
130128
{getVersionDisplay()}
131129
</Button>
132130

133-
{/* Render either the cached component or a new VersionSelector */}
134131
{versionSelectorCache.component ? (
135132
versionSelectorCache.component
136133
) : (
@@ -148,9 +145,8 @@ export const Content = () => {
148145
}));
149146
}}
150147
onMount={(component) => {
151-
// Cache the rendered component with the content ID
152148
setCachedVersionSelector(
153-
selectedContentId || '',
149+
selectedContentId ?? '',
154150
component,
155151
versionSelectorCache.versions.length > 0
156152
? versionSelectorCache.versions

xp-archive/client/versionSelector/VersionSelector.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export const VersionSelector = ({ versions, isOpen, onClose, onMount }: Props) =
5151
formatTimestamp(version.timestamp).toLowerCase().includes(searchQuery.toLowerCase())
5252
);
5353

54-
// Reset search when versions change completely
5554
useEffect(() => {
5655
if (
5756
versions.length > 0 &&
@@ -91,7 +90,6 @@ export const VersionSelector = ({ versions, isOpen, onClose, onMount }: Props) =
9190
</SlidePanel>
9291
);
9392

94-
// Call onMount with the component
9593
useEffect(() => {
9694
if (onMount) {
9795
onMount(component);

xp-archive/client/versionSelector/VersionSelectorCache.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { VersionReference } from 'shared/types';
33

4-
// Content-specific cache for the version selector component
54
const contentCache: Record<
65
string,
76
{
@@ -17,7 +16,6 @@ export const setCachedVersionSelector = (
1716
versions: VersionReference[],
1817
isOpen: boolean
1918
) => {
20-
// Clear all other caches first to prevent stale data
2119
Object.keys(contentCache).forEach((key) => {
2220
if (key !== contentId) {
2321
delete contentCache[key];

0 commit comments

Comments
 (0)