Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arononak committed Aug 2, 2024
1 parent ae7bb67 commit 2e7ec48
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
3 changes: 2 additions & 1 deletion [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
Expand Down
32 changes: 17 additions & 15 deletions [email protected]/lib/extension_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,23 @@ export class ExtensionController {
}
}

refresh() {
async refresh() {
if (this.indicator === null || this.indicator === undefined) {
return
}

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
}
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -408,7 +410,7 @@ export class ExtensionController {
}
}

_checkErrors() {
async _checkErrors() {
if (this.indicator == undefined) {
return
}
Expand All @@ -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 })
},
Expand All @@ -439,7 +441,7 @@ export class ExtensionController {
})
}

_fetchStatus() {
async _fetchStatus() {
if (this.indicator == undefined) {
return
}
Expand All @@ -454,7 +456,7 @@ export class ExtensionController {

const { owner, repo } = this.settingsRepository.ownerAndRepo()

this.extensionRepository.fetchStatus({
await this.extensionRepository.fetchStatus({
owner,
repo,
onNoInternet: () => {
Expand Down Expand Up @@ -518,7 +520,7 @@ export class ExtensionController {
this.indicator.initMenu()
}

this.extensionRepository.fetchData({
await this.extensionRepository.fetchData({
type,
settingsRepository: this.settingsRepository,
onUserDownloaded: (userObject) => {
Expand Down
4 changes: 3 additions & 1 deletion [email protected]/lib/file_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions [email protected]/lib/status_bar_indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": () => {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion [email protected]/lib/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = `3.39.0`
export const VERSION = `3.40.0`

0 comments on commit 2e7ec48

Please sign in to comment.