Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

implement StorageApi for browser.storage.StorageArea #396

Merged
merged 26 commits into from
Jan 14, 2023

Conversation

SergNikitin
Copy link
Collaborator

@SergNikitin SergNikitin commented Jan 9, 2023

@SergNikitin
Copy link
Collaborator Author

Just implements 1 method for now, but it's indicative of how the code for other ones might look like

@SergNikitin SergNikitin mentioned this pull request Jan 11, 2023
8 tasks
@SergNikitin
Copy link
Collaborator Author

The basics of this StorageApi implementation do work!

Media1.mp4

To film the above video in addition to the changes in the PR I applied the following diff:

diff --git a/archaeologist/src/background.ts b/archaeologist/src/background.ts
index 341f2df..484248e 100644
--- a/archaeologist/src/background.ts
+++ b/archaeologist/src/background.ts
@@ -27,7 +27,6 @@ import {
   NodeUtil,
   TotalUserActivity,
   ResourceVisit,
-  makeDatacenterStorageApi,
   UserExternalPipelineId,
   NodeCreatedVia,
   UserExternalPipelineIngestionProgress,
@@ -35,6 +34,7 @@ import {
   steroid,
 } from 'smuggler-api'
 
+import { makeBrowserExtStorageApi } from './storage_api_browser_ext'
 import { isReadyToBeAutoSaved } from './background/pageAutoSaving'
 import { suggestAssociations } from './background/suggestAssociations'
 import { isMemorable } from './content/extractor/url/unmemorable'
@@ -878,7 +878,7 @@ browser.contextMenus.onClicked.addListener(
   }
 )
 
-const storage: StorageApi = makeDatacenterStorageApi()
+const storage: StorageApi = makeBrowserExtStorageApi(browser.storage.local)
 
 auth.register()
 browserBookmarks.register(storage)
diff --git a/archaeologist/src/content/App.tsx b/archaeologist/src/content/App.tsx
index e8698f6..0c3caca 100644
--- a/archaeologist/src/content/App.tsx
+++ b/archaeologist/src/content/App.tsx
@@ -5,13 +5,14 @@ import browser from 'webextension-polyfill'
 import { PostHog } from 'posthog-js'
 import { v4 as uuidv4 } from 'uuid'
 
-import { NodeUtil, NodeType, makeDatacenterStorageApi } from 'smuggler-api'
+import { NodeUtil, NodeType } from 'smuggler-api'
 import type { TNode, TNodeJson } from 'smuggler-api'
 import { genOriginId, OriginIdentity, log, productanalytics } from 'armoury'
 import * as truthsayer_archaeologist_communication from 'truthsayer-archaeologist-communication'
 
 import { mazed } from '../util/mazed'
 
+import { makeBrowserExtStorageApi } from './../storage_api_browser_ext'
 import {
   FromContent,
   ToContent,
@@ -392,7 +393,7 @@ const App = () => {
       <ContentContext.Provider
         value={{
           analytics: state.analytics,
-          storage: makeDatacenterStorageApi(),
+          storage: makeBrowserExtStorageApi(browser.storage.local),
         }}
       >
         <BrowserHistoryImportControlPortal
diff --git a/archaeologist/src/popup/PopUpApp.tsx b/archaeologist/src/popup/PopUpApp.tsx
index c656c70..81f2ed1 100644
--- a/archaeologist/src/popup/PopUpApp.tsx
+++ b/archaeologist/src/popup/PopUpApp.tsx
@@ -15,7 +15,7 @@ import { mazed } from '../util/mazed'
 import { MdiLaunch } from 'elementary'
 import { productanalytics } from 'armoury'
 import { PopUpContext } from './context'
-import { makeDatacenterStorageApi } from 'smuggler-api'
+import { makeBrowserExtStorageApi } from './../storage_api_browser_ext'
 
 const AppContainer = styled.div`
   width: 340px;
@@ -74,7 +74,9 @@ export const PopUpApp = () => {
 
   return (
     <AppContainer>
-      <PopUpContext.Provider value={{ storage: makeDatacenterStorageApi() }}>
+      <PopUpContext.Provider
+        value={{ storage: makeBrowserExtStorageApi(browser.storage.local) }}
+      >
         {state.userUid == null ? <LoginPage /> : <ViewActiveTabStatus />}
       </PopUpContext.Provider>
     </AppContainer>

"webNavigation"
"webNavigation",
"storage",
"unlimitedStorage"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dr -Cox-Dancing-For-Elliot-On-Scrubs-Gif

@SergNikitin SergNikitin marked this pull request as ready for review January 14, 2023 16:36
@SergNikitin SergNikitin merged commit b550219 into main Jan 14, 2023
@SergNikitin SergNikitin deleted the offline-storage-api-2 branch January 14, 2023 16:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants