mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-10 10:58:33 +00:00
Get the default sketchbook path from backend
Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
@@ -46,6 +46,7 @@ import { BoardsConfigDialog } from './boards/boards-config-dialog';
|
||||
import { BoardsToolBarItem } from './boards/boards-toolbar-item';
|
||||
import { BoardsConfig } from './boards/boards-config';
|
||||
import { MonitorService } from '../common/protocol/monitor-service';
|
||||
import { ConfigService } from '../common/protocol/config-service';
|
||||
|
||||
export namespace ArduinoMenus {
|
||||
export const SKETCH = [...MAIN_MENU_BAR, '3_sketch'];
|
||||
@@ -140,6 +141,9 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
||||
@inject(WorkspaceService)
|
||||
protected readonly workspaceService: WorkspaceService;
|
||||
|
||||
@inject(ConfigService)
|
||||
protected readonly configService: ConfigService;
|
||||
|
||||
protected boardsToolbarItem: BoardsToolBarItem | null;
|
||||
protected wsSketchCount: number = 0;
|
||||
|
||||
@@ -452,11 +456,9 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
||||
protected async getWorkspaceSketches(): Promise<Sketch[]> {
|
||||
|
||||
let sketches: Sketch[] = [];
|
||||
const userHome = await this.fileSystem.getCurrentUserHome();
|
||||
console.log('userHome', userHome);
|
||||
if (!!userHome) {
|
||||
// TODO: get this from the backend
|
||||
const result = new URI(userHome.uri).resolve('Arduino-PoC').resolve('Sketches').toString();
|
||||
const config = await this.configService.getConfiguration();
|
||||
const result = config.sketchDirPath;
|
||||
if (!!result) {
|
||||
const stat = await this.fileSystem.getFileStat(result);
|
||||
if (!!stat) {
|
||||
sketches = await this.sketches.getSketches(stat);
|
||||
|
||||
@@ -56,6 +56,7 @@ import { LibraryItemRenderer } from './library/library-item-renderer';
|
||||
import { BoardItemRenderer } from './boards/boards-item-renderer';
|
||||
import { MonitorServiceClientImpl } from './monitor/monitor-service-client-impl';
|
||||
import { MonitorServicePath, MonitorService, MonitorServiceClient } from '../common/protocol/monitor-service';
|
||||
import { ConfigService, ConfigServicePath } from '../common/protocol/config-service';
|
||||
const ElementQueries = require('css-element-queries/src/ElementQueries');
|
||||
|
||||
if (!ARDUINO_PRO_MODE) {
|
||||
@@ -96,6 +97,9 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
||||
// Sketch list service
|
||||
bind(SketchesService).toDynamicValue(context => WebSocketConnectionProvider.createProxy(context.container, SketchesServicePath)).inSingletonScope();
|
||||
|
||||
// Config service
|
||||
bind(ConfigService).toDynamicValue(context => WebSocketConnectionProvider.createProxy(context.container, ConfigServicePath)).inSingletonScope();
|
||||
|
||||
// Boards service
|
||||
bind(BoardsService).toDynamicValue(context => {
|
||||
const connection = context.container.get(WebSocketConnectionProvider);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { WorkspaceServer } from "@theia/workspace/lib/common";
|
||||
import { FileSystem, FileStat } from "@theia/filesystem/lib/common";
|
||||
import URI from "@theia/core/lib/common/uri";
|
||||
import { SketchFactory } from "./sketch-factory";
|
||||
import { ConfigService } from "../common/protocol/config-service";
|
||||
|
||||
/**
|
||||
* This is workaround to have custom frontend binding for the default workspace, although we
|
||||
@@ -21,16 +22,14 @@ export class AWorkspaceService extends WorkspaceService {
|
||||
@inject(SketchFactory)
|
||||
protected readonly sketchFactory: SketchFactory;
|
||||
|
||||
@inject(ConfigService)
|
||||
protected readonly configService: ConfigService;
|
||||
|
||||
protected async getDefaultWorkspacePath(): Promise<string | undefined> {
|
||||
let result = await super.getDefaultWorkspacePath();
|
||||
if (!result) {
|
||||
const userHome = await this.fileSystem.getCurrentUserHome();
|
||||
if (!userHome) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The backend has created this location if it was missing.
|
||||
result = new URI(userHome.uri).resolve('Arduino-PoC').resolve('Sketches').toString();
|
||||
const config = await this.configService.getConfiguration();
|
||||
result = config.sketchDirPath;
|
||||
}
|
||||
|
||||
const stat = await this.fileSystem.getFileStat(result);
|
||||
|
||||
Reference in New Issue
Block a user