Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: click on notification after import of files #1853

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
// load again: minimize visual jitter on windows
if (path) 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