Skip to content

Commit

Permalink
fix: show Files after import on windows
Browse files Browse the repository at this point in the history
this aims to fix issue from
#1815
  • Loading branch information
lidel committed Jun 24, 2021
1 parent 2a0268d commit a75d3ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/add-to-ipfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ function sendNotification (failures, successes, launchWebUI, path) {
}

fn({ title, body }, () => {
// force refresh for Files screen to pick up newly added items
// https://github.com/ipfs/ipfs-desktop/issues/1763
launchWebUI(link, { forceRefresh: true })
})
}
Expand Down
5 changes: 3 additions & 2 deletions src/webui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,16 @@ module.exports = async function (ctx) {
logger.info('[web ui] launching web ui')
} else {
logger.info(`[web ui] navigate to ${path}`)
window.webContents.send('updatedPage', path)
url.hash = path
window.webContents.loadURL(url.toString())
}

if (focus) {
window.show()
window.focus()
dock.show()
}
// quick fix for visual jitter on windows
window.webContents.loadURL(url.toString())
}

function updateLanguage () {
Expand Down
13 changes: 8 additions & 5 deletions src/webui/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const urlParams = new URLSearchParams(window.location.search)

function checkIfVisible () {
if (document.hidden) {
if (window.location.hash === '#/blank') return // skip, already blank
previousHash = window.location.hash
window.location.hash = '/blank'
} else {
if (previousHash === '#/blank') return // skip
window.location.hash = previousHash
}
}
Expand All @@ -28,11 +30,6 @@ window.localStorage.setItem = function () {

let previousHash = null

ipcRenderer.on('updatedPage', (_, url) => {
previousHash = url
window.location.hash = url
})

document.addEventListener('visibilitychange', () => {
checkIfVisible()
})
Expand All @@ -41,6 +38,12 @@ document.addEventListener('DOMContentReady', () => {
checkIfVisible()
})

// track hash changes, so checkIfVisible always has the right previousHash
document.addEventListener('hashchange', () => {
if (window.location.hash === '#/blank') return // skip
previousHash = window.location.hash
})

window.ipfsDesktop = {
countlyAppKey: COUNTLY_KEY,

Expand Down

0 comments on commit a75d3ee

Please sign in to comment.