From 266d8f26b506a576ca9629fcfe13867d38fa125c Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Wed, 27 Sep 2023 12:40:56 +0200 Subject: [PATCH] fix: storage service injection Store the board config data per sketch and not per IDE installation. The (Theia) default `StorageService` implementation is workspace-scoped when `@theia/workspace` is part of the final application. Closes #2240 Signed-off-by: Akos Kitta --- .../src/browser/boards/boards-data-store.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arduino-ide-extension/src/browser/boards/boards-data-store.ts b/arduino-ide-extension/src/browser/boards/boards-data-store.ts index 52507a577..579f30b7a 100644 --- a/arduino-ide-extension/src/browser/boards/boards-data-store.ts +++ b/arduino-ide-extension/src/browser/boards/boards-data-store.ts @@ -1,5 +1,5 @@ import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application'; -import { LocalStorageService } from '@theia/core/lib/browser/storage-service'; +import { StorageService } from '@theia/core/lib/browser/storage-service'; import { DisposableCollection } from '@theia/core/lib/common/disposable'; import { Emitter, Event } from '@theia/core/lib/common/event'; import { ILogger } from '@theia/core/lib/common/logger'; @@ -23,8 +23,11 @@ export class BoardsDataStore implements FrontendApplicationContribution { private readonly boardsService: BoardsService; @inject(NotificationCenter) private readonly notificationCenter: NotificationCenter; - @inject(LocalStorageService) - private readonly storageService: LocalStorageService; + // When `@theia/workspace` is part of the application, the workspace-scoped storage service is the default implementation, and the `StorageService` symbol must be used for the injection. + // https://github.com/eclipse-theia/theia/blob/ba3722b04ff91eb6a4af6a571c9e263c77cdd8b5/packages/workspace/src/browser/workspace-frontend-module.ts#L97-L98 + // In other words, store the data (such as the board configs) per sketch, not per IDE2 installation. https://github.com/arduino/arduino-ide/issues/2240 + @inject(StorageService) + private readonly storageService: StorageService; private readonly onChangedEmitter = new Emitter(); private readonly toDispose = new DisposableCollection(this.onChangedEmitter);