Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Fix account button not update for cache miss
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Dec 28, 2018
1 parent df3f5f4 commit 96e1717
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/controller/image-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ImageStore {
// Remove file if accessed 7 days ago.
const p = path.join(this.dir, f)
const stats = fs.statSync(p)
if (now - stats.atimeMs > 1000)
if (now - stats.atimeMs > 1000 * 3600 * 24 * 7)
fs.unlinkSync(p)
}
} catch (e) {
Expand Down
4 changes: 1 addition & 3 deletions lib/service/slack/slack-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const SlackDirectMessage = require('./slack-direct-messsage')
const SlackReaction = require('./slack-reaction')
const SlackUser = require('./slack-user')

const imageStore = require('../../controller/image-store')

function compareChannel(a, b) {
const nameA = a.name.toUpperCase()
const nameB = b.name.toUpperCase()
Expand Down Expand Up @@ -109,7 +107,7 @@ class SlackAccount extends Account {
async ready(data) {
// Update current team information.
const {team} = await this.rtm.webClient.team.info()
this.icon = await imageStore.fetchImage(team.icon.image_132)
this.icon = team.icon.image_132
this.url = `https://${team.domain}.slack.com`
this.onUpdateInfo.dispatch(this)
// Fetch users.
Expand Down
6 changes: 4 additions & 2 deletions lib/view/account-button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const gui = require('gui')

const imageStore = require('../controller/image-store')

const FOCUS_BAR_COLOR = process.platform === 'darwin' ? '#FFF' : '#938E92'

function RoundedCornerPath(painter, r, radius) {
Expand Down Expand Up @@ -52,9 +54,9 @@ class AccountButton {
this.subscription.onUpdateReadState.detach()
}

updateInfo() {
async updateInfo() {
if (this.account.icon)
this.image = gui.Image.createFromPath(this.account.icon)
this.image = gui.Image.createFromPath(await imageStore.fetchImage(this.account.icon))
this.view.schedulePaint()
}

Expand Down

0 comments on commit 96e1717

Please sign in to comment.