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

Commit 96e1717

Browse files
committed
Fix account button not update for cache miss
1 parent df3f5f4 commit 96e1717

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/controller/image-store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ImageStore {
7171
// Remove file if accessed 7 days ago.
7272
const p = path.join(this.dir, f)
7373
const stats = fs.statSync(p)
74-
if (now - stats.atimeMs > 1000)
74+
if (now - stats.atimeMs > 1000 * 3600 * 24 * 7)
7575
fs.unlinkSync(p)
7676
}
7777
} catch (e) {

lib/service/slack/slack-account.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const SlackDirectMessage = require('./slack-direct-messsage')
88
const SlackReaction = require('./slack-reaction')
99
const SlackUser = require('./slack-user')
1010

11-
const imageStore = require('../../controller/image-store')
12-
1311
function compareChannel(a, b) {
1412
const nameA = a.name.toUpperCase()
1513
const nameB = b.name.toUpperCase()
@@ -109,7 +107,7 @@ class SlackAccount extends Account {
109107
async ready(data) {
110108
// Update current team information.
111109
const {team} = await this.rtm.webClient.team.info()
112-
this.icon = await imageStore.fetchImage(team.icon.image_132)
110+
this.icon = team.icon.image_132
113111
this.url = `https://${team.domain}.slack.com`
114112
this.onUpdateInfo.dispatch(this)
115113
// Fetch users.

lib/view/account-button.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const gui = require('gui')
22

3+
const imageStore = require('../controller/image-store')
4+
35
const FOCUS_BAR_COLOR = process.platform === 'darwin' ? '#FFF' : '#938E92'
46

57
function RoundedCornerPath(painter, r, radius) {
@@ -52,9 +54,9 @@ class AccountButton {
5254
this.subscription.onUpdateReadState.detach()
5355
}
5456

55-
updateInfo() {
57+
async updateInfo() {
5658
if (this.account.icon)
57-
this.image = gui.Image.createFromPath(this.account.icon)
59+
this.image = gui.Image.createFromPath(await imageStore.fetchImage(this.account.icon))
5860
this.view.schedulePaint()
5961
}
6062

0 commit comments

Comments
 (0)