Simplify mark/scroll function

This commit is contained in:
Oliver Blanthorn 2020-10-30 15:18:49 +00:00
parent 630159eedc
commit dff6e1aa84
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -1136,21 +1136,19 @@ export async function markjumpglobal(key: string) {
const matchingTabs = await browserBg.tabs.query({url: mark.url})
// If there are no matching tabs, open a new one and update the mark's tabId for future use in this session
if (!matchingTabs.length) {
return openInNewTab(mark.url).then(updateMarkAndScroll())
return openInNewTab(mark.url).then(updateMarkAndScroll)
}
// If there are multiple tabs open with the same url, just pick the first one and update the mark's tabId
// for future use in this session
return goToTab(matchingTabs[0].id).then(updateMarkAndScroll())
return goToTab(matchingTabs[0].id).then(updateMarkAndScroll)
}
function updateMarkAndScroll() {
return (tab) => {
function updateMarkAndScroll(tab) {
mark.tabId = tab.id
state.globalMarks = globalMarks
scrolltab(tab.id, mark.scrollX, mark.scrollY, `Jumped to mark '${key}'`)
}
}
}
/**
* Jumps to a location saved before the last mark jump as long as the tab it's located in exists and its url didn't change.