Skip to content

Commit 80ade4c

Browse files
committed
updated pseudo code
1 parent 355dec8 commit 80ade4c

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

arduino-ide-extension/src/node/monitor-settings/monitor-settings-provider-impl.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,40 @@ import {
77

88
@injectable()
99
export class MonitorSettingsProviderImpl implements MonitorSettingsProvider {
10+
// this is populated with all settings coming from the CLI. This should never get modified
11+
// as it is used to double actual values set by the user
12+
private monitorSettings: MonitorSettings;
13+
14+
// this contains values for setting of the monitorSettings
15+
// the key is MonitorSetting.id, the value should be one of the MonitorSetting.values
16+
private monitorSettingsValues: Record<string, any>;
17+
1018
init(
1119
id: string,
1220
coreClientProvider: CoreClientProvider
1321
): Promise<MonitorSettings> {
1422
throw new Error('Method not implemented.');
1523

16-
// query the CLI (via coreClientProvider) and return all available settings for the pluggable monitor.
17-
// store these for later checkings
18-
19-
// check for the settings file in the user's home directory
20-
// if it doesn't exist, create it
21-
22-
// if it does exist, start searching for the longest prefix matching the id
24+
// 1. query the CLI (via coreClientProvider) and return all available settings for the pluggable monitor.
25+
// store these in `monitorSettings` for later checkings
2326

24-
// at the end of the search you can have a hit or a miss
25-
26-
// if you have a miss, create a new entry with the id and all default settings coming from the CLI
27-
28-
// if you have a hit, check if the existing settings are present in the settings from the CLI
29-
// if they are not present in the CLI, remove from the settings file
30-
// if there are settings in the CLI that are not in the file, add to the file with the default from the CLI
31-
// save the updated settings file
27+
// 2. check for the settings file in the user's home directory
28+
// a. if it doesn't exist, create it as an empty json file
29+
// 3. search the file, looking for the longest prefix matching the id
30+
// a. miss: populate `monitorSettingsValues` with all default settings from `monitorSettings`
31+
// b. hit: populate `monitorSettingsValues` with the result for the search
32+
// i. purge the `monitorSettingsValues` removing keys that are not defined in `monitorSettings`
33+
// and adding those that are missing
34+
// ii. save the `monitorSettingsValues` in the file, using the id as the key
3235
}
3336
get(): Promise<MonitorSettings> {
3437
throw new Error('Method not implemented.');
3538
}
3639
set(settings: MonitorSettings): Promise<MonitorSettings> {
3740
throw new Error('Method not implemented.');
41+
42+
// 1. parse the settings parameter and remove any setting that is not defined in `monitorSettings`
43+
// 2. update `monitorSettingsValues` accordingly
44+
// 3. save it to the file
3845
}
3946
}

0 commit comments

Comments
 (0)