chore: make home server internal feature

This commit is contained in:
Mo
2023-07-03 13:53:03 -05:00
parent 1f144e062e
commit ccc9d73b3b
7 changed files with 30 additions and 28 deletions

View File

@@ -23,11 +23,9 @@ export class HomeServerManager implements HomeServerManagerInterface {
private readonly LOGS_BUFFER_SIZE = 1000
constructor(
private homeServer: HomeServerInterface,
private webContents: WebContents,
private filesManager: FilesManagerInterface,
) {}
private homeServer?: HomeServerInterface
constructor(private webContents: WebContents, private filesManager: FilesManagerInterface) {}
async getHomeServerUrl(): Promise<string | undefined> {
const homeServerConfiguration = await this.getHomeServerConfigurationObject()
@@ -39,7 +37,7 @@ export class HomeServerManager implements HomeServerManagerInterface {
}
async isHomeServerRunning(): Promise<boolean> {
return this.homeServer.isRunning()
return this.homeServer?.isRunning() ?? false
}
async getHomeServerLastErrorMessage(): Promise<string | undefined> {
@@ -47,6 +45,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
}
async activatePremiumFeatures(username: string): Promise<string | undefined> {
if (!this.homeServer) {
return
}
const result = await this.homeServer.activatePremiumFeatures(username)
if (result.isFailed()) {
@@ -111,6 +113,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
}
async stopHomeServer(): Promise<string | undefined> {
if (!this.homeServer) {
return
}
const result = await this.homeServer.stop()
if (result.isFailed()) {
return result.getError()
@@ -120,6 +126,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
}
async startHomeServer(): Promise<string | undefined> {
if (!this.homeServer) {
return
}
try {
this.lastErrorMessage = undefined
this.logs = []

View File

@@ -25,7 +25,6 @@ import { handleTestMessage, send } from './Utils/Testing'
import { isTesting, lowercaseDriveLetter } from './Utils/Utils'
import { initializeZoomManager } from './ZoomManager'
import { HomeServerManager } from './HomeServer/HomeServerManager'
import { HomeServer } from '@standardnotes/home-server'
import { FilesManager } from './File/FilesManager'
import { DirectoryManager } from './Directory/DirectoryManager'
@@ -206,11 +205,11 @@ async function createWindowServices(window: Electron.BrowserWindow, appState: Ap
const trayManager = createTrayManager(window, appState.store)
const spellcheckerManager = createSpellcheckerManager(appState.store, window.webContents, appLocale)
const mediaManager = new MediaManager()
const homeServer = new HomeServer()
const filesManager = new FilesManager()
const directoryManager = new DirectoryManager(filesManager)
const homeServerManager = new HomeServerManager(homeServer, window.webContents, filesManager)
const homeServerManager = new HomeServerManager(window.webContents, filesManager)
if (isTesting()) {
handleTestMessage(MessageType.SpellCheckerManager, () => spellcheckerManager)