From 176060183eebf48fafccaee63a8d999c0b965aa7 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Sun, 25 Aug 2019 20:53:20 +0200 Subject: [PATCH] Select the proper turbo list --- lib/api.ts | 12 ++++++++---- lib/item.ts | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/api.ts b/lib/api.ts index 50e2375..d81d924 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -91,10 +91,14 @@ export const API = new class { if (!this.sanity(links, media)) { return false; } - const selected = makeUniqueItems([ - await API.filter(links, TYPE_LINK), - await API.filter(media, TYPE_MEDIA), - ]); + const type = await Prefs.get("last-type", "links"); + const items = await (async () => { + if (type === "links") { + return await API.filter(links, TYPE_LINK); + } + return await API.filter(media, TYPE_MEDIA); + })(); + const selected = makeUniqueItems([items]); if (!selected.length) { return await this.regular(links, media); } diff --git a/lib/item.ts b/lib/item.ts index b198994..a8b6abc 100644 --- a/lib/item.ts +++ b/lib/item.ts @@ -99,7 +99,7 @@ function transfer(e: any, other: any) { } -export function makeUniqueItems(items: any, mapping?: Function) { +export function makeUniqueItems(items: any[][], mapping?: Function) { const known = new Map(); const unique = []; for (const itemlist of items) {