@@ -4,11 +4,16 @@ import { useIntervalFn } from "@vueuse/core";
44import { inject , ref , watchEffect } from " vue" ;
55
66import { ApplicationNamespace , GlobalStatesContextKey } from " @/constants/application.ts" ;
7+ import { FileStructure } from " @/constants/file-structure.ts" ;
78import Configs from " @/lib/configs" ;
89import Errors from " @/lib/errors" ;
10+ import General from " @/lib/general" ;
911import GlobalStateHelpers from " @/lib/global-state-helpers" ;
1012import { log } from " @/lib/logging/scopes/log.ts" ;
11- import type { ContextGlobalStatesType } from " @/types/application/global-states.type.ts" ;
13+ import type {
14+ ContextGlobalStatesType ,
15+ GlobalStatesType ,
16+ } from " @/types/application/global-states.type.ts" ;
1217import type { ConfigType } from " @/types/configs/config.type.ts" ;
1318
1419const globalStates = inject <ContextGlobalStatesType >(GlobalStatesContextKey );
@@ -21,31 +26,38 @@ async function handleConfigSync(): Promise<void> {
2126 syncing .value = true ;
2227
2328 log .debug (" Getting current global states" );
24- const currentGlobalStates = GlobalStateHelpers .get ();
25- const configPath = currentGlobalStates .fileSystem ?.files ?.config ;
26-
27- if (! configPath ) {
28- log .warn (" No config path was found in global states. Aborting config sync" );
29- syncing .value = false ;
30-
31- return ;
32- }
29+ const currentGlobalStatesDetached: ConfigType & Partial <GlobalStatesType > = {
30+ // Spread the global states to re-create one-level deep properties
31+ ... GlobalStateHelpers .get (),
32+ };
33+ const configPath = General .cachedJoin (
34+ General .getCachedBaseDirectory (),
35+ FileStructure .Files .Config ,
36+ );
3337
3438 log .debug (" Getting current user config" );
3539 const config = await Configs .getSafe ();
3640
41+ // Remove all non-config properties
42+ delete currentGlobalStatesDetached .translations ;
43+ delete currentGlobalStatesDetached .sidebarItems ;
44+ delete currentGlobalStatesDetached .contextMenuItems ;
45+ delete currentGlobalStatesDetached .pages ;
46+
3747 log .debug (" Creating a 'ConfigType' typed object with the global states contents" );
3848 const configOnlyGlobalStates: ConfigType = {
49+ // Spread the global states since there might be additional properties by extensions
50+ ... globalStates ,
3951 // Arrange these properties in a way that the config itself arranges them
40- " development" : currentGlobalStates .development ,
41- " extensions" : currentGlobalStates .extensions ,
42- " layout" : currentGlobalStates .layout ,
52+ " development" : currentGlobalStatesDetached .development ,
53+ " extensions" : currentGlobalStatesDetached .extensions ,
54+ " layout" : currentGlobalStatesDetached .layout ,
4355 " logs" : {
44- ... currentGlobalStates .logs ,
56+ ... currentGlobalStatesDetached .logs ,
4557 " show" : false ,
4658 },
47- " minecraft" : currentGlobalStates .minecraft ,
48- " misc" : currentGlobalStates .misc ,
59+ " minecraft" : currentGlobalStatesDetached .minecraft ,
60+ " misc" : currentGlobalStatesDetached .misc ,
4961 };
5062 const stringyConfig = JSON .stringify (config );
5163 const stringyGlobalStates = JSON .stringify (configOnlyGlobalStates );
0 commit comments