mirror of
https://github.com/He4eT/tabswitcher.git
synced 2026-05-05 01:17:23 +00:00
pages/search: simplify labels logic
This commit is contained in:
parent
45cf56e255
commit
9c24d16071
2 changed files with 12 additions and 41 deletions
|
|
@ -14,8 +14,8 @@ export const init = ({
|
|||
|
||||
/* */
|
||||
|
||||
const addLabel = (tabs) => (tab) => ({
|
||||
label: labels.id2label(tab.id, tabs),
|
||||
const addLabel = (tab, i, tabs) => ({
|
||||
label: labels.fromNumber(i, tabs.length),
|
||||
...tab,
|
||||
})
|
||||
|
||||
|
|
@ -28,13 +28,13 @@ export const init = ({
|
|||
].reduce((acc, x) => (acc[x] = tab[x], acc), {})
|
||||
|
||||
const shapeTabs = (tabs) => tabs
|
||||
.map(addLabel(tabs))
|
||||
.map(addLabel)
|
||||
.map(pickFields)
|
||||
.reverse()
|
||||
|
||||
const fetchTabs = () =>
|
||||
browserTabs.query({ currentWindow: true, active: false })
|
||||
.then(shapeTabs)
|
||||
.then((tabs) => tabs.reverse())
|
||||
.then((tabs) => void (state.tabs = tabs))
|
||||
|
||||
/* */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue