diff --git a/src/main/server/serverAPI.test.js b/src/main/server/serverAPI.test.js index c02f7123..6a4d1cda 100644 --- a/src/main/server/serverAPI.test.js +++ b/src/main/server/serverAPI.test.js @@ -23,6 +23,9 @@ jest.mock('electron', () => ({ if (event === 'data') { responseCallback(url === badDataURL ? '98&H09986t&(*6BV789RhN^t97rb6Ev^*e5v89 re5bg^&' : JSON.stringify(testData)); } + if (event === 'end') { + responseCallback(); + } }), statusCode: (url === validURL || url === badDataURL) ? 200 : 404, }); diff --git a/src/main/server/serverAPI.ts b/src/main/server/serverAPI.ts index a65376cc..25401ca7 100644 --- a/src/main/server/serverAPI.ts +++ b/src/main/server/serverAPI.ts @@ -38,9 +38,12 @@ export async function getServerAPI(url: URL, isAuthenticated: boolean, onSucc req.on('response', (response: Electron.IncomingMessage) => { log.silly('getServerAPI.response', response); if (response.statusCode === 200) { + let raw = ''; response.on('data', (chunk: Buffer) => { log.silly('getServerAPI.response.data', `${chunk}`); - const raw = `${chunk}`; + raw += `${chunk}`; + }); + response.on('end', () => { try { const data = JSON.parse(raw) as T; onSuccess(data); diff --git a/src/main/server/serverInfo.ts b/src/main/server/serverInfo.ts index 01d05831..da8f359a 100644 --- a/src/main/server/serverInfo.ts +++ b/src/main/server/serverInfo.ts @@ -44,12 +44,13 @@ export class ServerInfo { onGetConfig = (data: ClientConfig) => { this.remoteInfo.serverVersion = data.Version; this.remoteInfo.siteURL = data.SiteURL; + this.remoteInfo.hasFocalboard = this.remoteInfo.hasFocalboard || data.BuildBoards === 'true'; this.trySendRemoteInfo(); } onGetPlugins = (data: Array<{id: string; version: string}>) => { - this.remoteInfo.hasFocalboard = data.some((plugin) => plugin.id === 'focalboard'); + this.remoteInfo.hasFocalboard = this.remoteInfo.hasFocalboard || data.some((plugin) => plugin.id === 'focalboard'); this.remoteInfo.hasPlaybooks = data.some((plugin) => plugin.id === 'playbooks'); this.trySendRemoteInfo(); diff --git a/src/types/server.ts b/src/types/server.ts index 5f9e72ef..9f8886e2 100644 --- a/src/types/server.ts +++ b/src/types/server.ts @@ -12,4 +12,5 @@ export type RemoteInfo = { export type ClientConfig = { Version: string; SiteURL: string; + BuildBoards: string; }