Skip to content

Commit 70321fd

Browse files
committed
When connection is made, make sure connection storage is unique
Signed-off-by: worksofliam <[email protected]>
1 parent 88074fa commit 70321fd

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/api/configuration/storage/BaseStorage.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
export abstract class BaseStorage {
22
protected readonly globalState: any;
33

4+
private uniqueKeyPrefix: string|undefined;
45
constructor(globalState: any) {
5-
this.globalState = globalState;
6+
this.globalState = globalState;
67
}
78

89

910
keys(): readonly string[] {
1011
return Array.from(this.globalState.keys());
1112
}
1213

14+
setUniqueKeyPrefix(prefix: string) {
15+
this.uniqueKeyPrefix = prefix;
16+
}
17+
1318
get<T>(key: string): T | undefined {
1419
return this.globalState.get(this.getStorageKey(key)) as T | undefined;
1520
}
@@ -19,7 +24,7 @@ export abstract class BaseStorage {
1924
}
2025

2126
getStorageKey(key: string): string {
22-
return key;
27+
return `${this.uniqueKeyPrefix ? this.uniqueKeyPrefix + '.' : ''}${key}`;
2328
}
2429
}
2530

src/api/configuration/storage/CodeForIStorage.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ export type CachedServerSettings = {
3434
export class CodeForIStorage {
3535
constructor(private internalStorage: BaseStorage) {}
3636

37-
protected getStorageKey(key: string): string {
38-
return key;
39-
}
40-
4137
getLastConnections() {
4238
return this.internalStorage.get<LastConnection[]>("lastConnections");
4339
}

src/api/configuration/storage/ConnectionStorage.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ type AuthorisedExtension = {
2020

2121
export class ConnectionStorage {
2222
private connectionName: string = "";
23-
constructor(private internalStorage: BaseStorage) {}
23+
constructor(private internalStorage: BaseStorage) {
24+
}
2425

2526
get ready(): boolean {
2627
if (this.connectionName) {
@@ -33,10 +34,7 @@ export class ConnectionStorage {
3334

3435
setConnectionName(connectionName: string) {
3536
this.connectionName = connectionName;
36-
}
37-
38-
protected getStorageKey(key: string): string {
39-
return `${this.connectionName}.${key}`;
37+
this.internalStorage.setUniqueKeyPrefix(`settings-${connectionName}`);
4038
}
4139

4240
getSourceList() {

0 commit comments

Comments
 (0)