Skip to content

Commit 8041a2b

Browse files
fix!: duplicating issue of the recent workspaces
1 parent 7702baf commit 8041a2b

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

apps/app/src/lib/operations/workspace/operations.svelte.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,31 @@ async function update_opened_filenode(
103103
}
104104
// NOTE: Just update the last accessed time and nothing else
105105
export async function touch_recent_workspaces(
106-
data: Omit<WorkspaceMetadata, 'last_accessed'>,
106+
workspace: Omit<WorkspaceMetadata, 'last_accessed'>,
107107
{ update_time = true }: { update_time?: boolean } = {}
108108
) {
109109
if (!persistent_states.states) return;
110110
const existing = persistent_states.states.app_config.workspaces_metadata.find(
111-
(v) => v.path === data.path
111+
(v) => v.path === workspace.path
112112
);
113113

114-
const processed = [
114+
const rest_of_the_workspaces =
115+
persistent_states.states.app_config.workspaces_metadata.filter(
116+
(v) => v.path.path !== workspace.path.path
117+
);
118+
119+
const merged_workspaces = [
115120
{
116-
...data,
121+
...workspace,
117122
last_accessed:
118123
existing && !update_time ? existing.last_accessed : new Date(),
119124
},
120-
...persistent_states.states.app_config.workspaces_metadata.filter(
121-
(v) => v.path !== data.path
122-
),
123-
].slice(0, 10);
125+
...rest_of_the_workspaces,
126+
];
127+
128+
const sliced_workspaces = merged_workspaces.slice(0, 10);
124129

125-
persistent_states.states.app_config.workspaces_metadata = processed;
130+
persistent_states.states.app_config.workspaces_metadata = sliced_workspaces;
126131
await persistent_states.save();
127132

128133
// await user_activity.set('recent_paths', processed);

0 commit comments

Comments
 (0)