Track your online rabbitholes!

refactor: fix function name, remove redundant code

authored by Govind Mohan and committed by Govind Mohan 90f8a2cb 8c3d56a7

Changed files
+5 -19
src
background
lib
storage
+3 -3
src/background/index.ts
··· 11 11 12 12 // this is meant to be called async 13 13 function storeWebsites(tabs: chrome.tabs.Tab[], db: WebsiteStore, sendResponse: any): Promise<void[]> { 14 - // FIXME: delegate this to db 14 + // delegate this to db? 15 15 // FIXME: add some guarantees that this won't randomly crash 16 16 const promiseArray = tabs.map(tab => fetch(`https://cardyb.bsky.app/v1/extract?url=${encodeURIComponent(tab.url)}`, 17 17 { ··· 30 30 }; 31 31 }) 32 32 .then(website => { 33 - db.store([website]) 33 + db.saveWebsiteToProject([website]) 34 34 .then(res => sendResponse(res)) 35 35 .catch(err => { 36 36 console.log(err) ··· 39 39 }) 40 40 .catch(error => { 41 41 // just use info at hand if OG information cannot be retrieved 42 - db.store([{ 42 + db.saveWebsiteToProject([{ 43 43 url: tab.url, 44 44 name: tab.title, 45 45 faviconUrl: tab.favIconUrl,
-15
src/lib/Timeline.svelte
··· 42 42 url: event.detail.url 43 43 }); 44 44 } 45 - 46 - async function updateItems() { 47 - activeProject = await chrome.runtime.sendMessage({ type: MessageRequest.GET_ACTIVE_PROJECT }) 48 - // FIXME: when rabbithole is installed, the first time a session is saved 49 - // the website list is duplicated, so dedup here for now 50 - const possiblyDuplicatedWebsites = await chrome.runtime.sendMessage({ 51 - type: MessageRequest.GET_PROJECT_SAVED_WEBSITES, 52 - projectId: activeProject.id, 53 - }); 54 - websites = possiblyDuplicatedWebsites.filter((value, index, self) => 55 - index === self.findIndex((t) => ( 56 - t.url === value.url 57 - )) 58 - ) 59 - } 60 45 </script> 61 46 62 47 <div class="timeline">
+2 -1
src/storage/db.ts
··· 133 133 }); 134 134 } 135 135 136 - async store(items: Website[]): Promise<Website | { alreadySaved: boolean }[]> { 136 + // also adds website to savedWebsites if it isn't there already 137 + async saveWebsiteToProject(items: Website[]): Promise<Website | { alreadySaved: boolean }[]> { 137 138 return new Promise(async (resolve, reject) => { 138 139 let db: IDBDatabase; 139 140 try {