From 2e7ec48d26fae689dbc4238ad97f906b07c99d5f Mon Sep 17 00:00:00 2001 From: Aron Onak Date: Fri, 2 Aug 2024 05:01:08 +0200 Subject: [PATCH] Some fixes --- .../extension.js | 3 +- .../lib/extension_controller.js | 32 ++++++++++--------- .../lib/file_controller.js | 4 ++- .../lib/status_bar_indicator.js | 1 + .../lib/version.js | 2 +- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/github-actions@arononak.github.io/extension.js b/github-actions@arononak.github.io/extension.js index 0fa85c2..42cfb57 100644 --- a/github-actions@arononak.github.io/extension.js +++ b/github-actions@arononak.github.io/extension.js @@ -72,9 +72,10 @@ export default class GithubActionsExtension extends Extension { onBuildCompleted: (owner, repo, conclusion) => { NotificationController.showCompletedBuild(owner, repo, conclusion) }, - onReloadCallback: () => { + onReloadCallback: async () => { this.extensionController.stopRefreshing() this.disposeExtension() + await new Promise((resolve) => setTimeout(resolve, 2000)) this.initExtension() this.extensionController.startRefreshing() }, diff --git a/github-actions@arononak.github.io/lib/extension_controller.js b/github-actions@arononak.github.io/lib/extension_controller.js index b9de46c..c39d65c 100644 --- a/github-actions@arononak.github.io/lib/extension_controller.js +++ b/github-actions@arononak.github.io/lib/extension_controller.js @@ -168,7 +168,7 @@ export class ExtensionController { } } - refresh() { + async refresh() { if (this.indicator === null || this.indicator === undefined) { return } @@ -176,15 +176,15 @@ export class ExtensionController { this.indicator.initMenu() try { - this._checkErrors() - this._fetchStatus() - this._fetchData() + await this._checkErrors() + await this._fetchStatus() + await this._fetchData() } catch (error) { logError(error) } } - startRefreshing() { + async startRefreshing() { if (this.isStarted === true) { return } @@ -194,11 +194,13 @@ export class ExtensionController { this.observeSettings(this.settingsRepository) try { - const settingsRepository = this.settingsRepository - this.refresh() + await new Promise((resolve) => setTimeout(resolve, 2000)) + await this.refresh() + await new Promise((resolve) => setTimeout(resolve, 5000)) + const settingsRepository = this.settingsRepository this.stateRefreshInterval = setInterval(() => this._checkErrors(), 1 * 1000) - this.githubActionsRefreshInterval = setInterval(() => this._fetchStatus(), settingsRepository.fetchRefreshTime() * 1000) + this.statusRefreshInterval = setInterval(() => this._fetchStatus(), settingsRepository.fetchRefreshTime() * 1000) this.dataRefreshInterval = setInterval(() => this._fetchData(), settingsRepository.fetchRefreshFullUpdateTime() * 60 * 1000) } catch (error) { logError(error) @@ -217,8 +219,8 @@ export class ExtensionController { clearInterval(this.stateRefreshInterval) this.stateRefreshInterval = null - clearInterval(this.githubActionsRefreshInterval) - this.githubActionsRefreshInterval = null + clearInterval(this.statusRefreshInterval) + this.statusRefreshInterval = null clearInterval(this.dataRefreshInterval) this.dataRefreshInterval = null @@ -408,7 +410,7 @@ export class ExtensionController { } } - _checkErrors() { + async _checkErrors() { if (this.indicator == undefined) { return } @@ -422,7 +424,7 @@ export class ExtensionController { return } - this.extensionRepository.checkErrors({ + await this.extensionRepository.checkErrors({ onNotInstalledCli: () => { this.indicator.setState({ state: ExtensionState.NOT_INSTALLED_CLI, forceUpdate: true }) }, @@ -439,7 +441,7 @@ export class ExtensionController { }) } - _fetchStatus() { + async _fetchStatus() { if (this.indicator == undefined) { return } @@ -454,7 +456,7 @@ export class ExtensionController { const { owner, repo } = this.settingsRepository.ownerAndRepo() - this.extensionRepository.fetchStatus({ + await this.extensionRepository.fetchStatus({ owner, repo, onNoInternet: () => { @@ -518,7 +520,7 @@ export class ExtensionController { this.indicator.initMenu() } - this.extensionRepository.fetchData({ + await this.extensionRepository.fetchData({ type, settingsRepository: this.settingsRepository, onUserDownloaded: (userObject) => { diff --git a/github-actions@arononak.github.io/lib/file_controller.js b/github-actions@arononak.github.io/lib/file_controller.js index 570ac9a..46b53fa 100644 --- a/github-actions@arononak.github.io/lib/file_controller.js +++ b/github-actions@arononak.github.io/lib/file_controller.js @@ -27,8 +27,10 @@ export class FileController { try { const [success, content] = GLib.file_get_contents(`${this.extensionDir()}/${filename}`) + if (success) { - return content.toString() + const decoder = new TextDecoder(`utf-8`) + return decoder.decode(content) } return null diff --git a/github-actions@arononak.github.io/lib/status_bar_indicator.js b/github-actions@arononak.github.io/lib/status_bar_indicator.js index 949fd57..32cafd7 100644 --- a/github-actions@arononak.github.io/lib/status_bar_indicator.js +++ b/github-actions@arononak.github.io/lib/status_bar_indicator.js @@ -1018,6 +1018,7 @@ export class StatusBarIndicator extends PanelMenu.Button { "text": e[`name`].slice(0, textLengthLimiter), "callback": () => openUrl(repositoryUrl), "endIconName": e[`protected`] ? `changes-prevent-symbolic` : `network-workgroup-symbolic`, + "endIconCallback": () => {} } } diff --git a/github-actions@arononak.github.io/lib/version.js b/github-actions@arononak.github.io/lib/version.js index e25eb74..1865945 100644 --- a/github-actions@arononak.github.io/lib/version.js +++ b/github-actions@arononak.github.io/lib/version.js @@ -1 +1 @@ -export const VERSION = `3.39.0` +export const VERSION = `3.40.0`