Skip to content

Commit

Permalink
fix: icons not loading after app uninstalled
Browse files Browse the repository at this point in the history
  • Loading branch information
will-stone committed Aug 12, 2022
1 parent edd30b8 commit a23b646
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/utils/get-app-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ import { dispatch } from '../state/store'

export async function getAppIcons(apps: Storage['apps']): Promise<void> {
try {
const buffers: Buffer[] = await fileIcon.buffer(
apps.map((app) => app.id),
{ size: 64 },
)
const buffers: (Buffer | null)[] = []

for await (const app of apps) {
try {
const buffer = await fileIcon.buffer(app.id, { size: 64 })
buffers.push(buffer)
} catch {
buffers.push(null)
}
}

const icons: Partial<Record<AppId, string>> = {}

for (const [index, buffer] of Object.entries(buffers)) {
icons[apps[Number(index)].id] = `data:image/png;base64,${buffer.toString(
'base64',
)}`
icons[apps[Number(index)].id] = buffer
? `data:image/png;base64,${buffer.toString('base64')}`
: ''
}

dispatch(gotAppIcons(icons))
Expand Down

0 comments on commit a23b646

Please sign in to comment.