Skip to content

Commit 7702baf

Browse files
refac: make update workpsaces function take the WorkspaceMetadata tupe for the old workspace
1 parent 101b641 commit 7702baf

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

apps/app/src/components/general/workspace_selector/index.svelte

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
}
6666
: undefined;
6767

68-
await init_or_update_workspace(
69-
workspace_root_path.data?.path,
70-
{ path, recent_filenode_path }
71-
);
68+
await init_or_update_workspace(workspace_root_path.data, {
69+
path,
70+
recent_filenode_path,
71+
});
7272
}}
7373
class="
7474
{workspace_root_path.data?.path == path.path && 'bg-base-100'}
@@ -121,14 +121,15 @@
121121
onclick={async () => {
122122
const path = await show_folder_picker();
123123

124+
// Update the prevous workspace
124125
const recent_filenode_path = opened_filenode.data
125126
? {
126127
path: opened_filenode.data.path,
127128
document_top_tree_uri: null,
128129
}
129130
: undefined;
130131

131-
await init_or_update_workspace(workspace_root_path.data?.path, {
132+
await init_or_update_workspace(workspace_root_path.data, {
132133
path,
133134
recent_filenode_path,
134135
});
@@ -148,13 +149,10 @@
148149
}
149150
: undefined;
150151

151-
await init_or_update_workspace(
152-
workspace_root_path.data?.path,
153-
{
154-
path,
155-
recent_filenode_path,
156-
}
157-
);
152+
await init_or_update_workspace(workspace_root_path.data, {
153+
path,
154+
recent_filenode_path,
155+
});
158156
}}
159157
>
160158
<div class="size-6 i-tabler:folder-open"></div>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ import {
2121
persistent_states,
2222
type WorkspaceMetadata,
2323
} from '@/lib/states/persistent/index.svelte';
24+
import type { GenericPath } from '@/lib/types';
2425

2526
// NOTE: Mainly updates only the UI States of the App
2627
export async function init_or_update_workspace(
27-
old_workspace_root_path: string | undefined,
28+
old_workspace: GenericPath | undefined,
2829
new_workspace: Omit<WorkspaceMetadata, 'last_accessed'>
2930
) {
3031
try {
3132
// Prerequisites
3233
workspace_picker_dialog_open_state.data = false;
3334
const { path: workspace_path, recent_filenode_path } = new_workspace;
34-
if (old_workspace_root_path === workspace_path.path) return;
35+
if (old_workspace?.path === workspace_path.path) return;
36+
console.log('Passed the return');
3537
reset_ui_states();
3638

3739
// Actual Workspace Updation

0 commit comments

Comments
 (0)