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

add StorageApi impl which works via msgs #401

Merged
merged 8 commits into from
Jan 15, 2023
Merged

add StorageApi impl which works via msgs #401

merged 8 commits into from
Jan 15, 2023

Conversation

SergNikitin
Copy link
Collaborator

@SergNikitin SergNikitin commented Jan 14, 2023

@SergNikitin
Copy link
Collaborator Author

Test with

From 25003863080f9951858be9d4ebfbdbd9927c017d Mon Sep 17 00:00:00 2001
From: Sergey Nikitin <snikitin@outlook.com>
Date: Sat, 14 Jan 2023 20:48:47 +0000
Subject: [PATCH] test

---
 archaeologist/src/background.ts      | 4 ++--
 archaeologist/src/content/App.tsx    | 5 +++--
 archaeologist/src/popup/PopUpApp.tsx | 6 ++++--
 truthsayer/src/lib/global.tsx        | 4 ++--
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/archaeologist/src/background.ts b/archaeologist/src/background.ts
index 9958472..176570e 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'
@@ -891,7 +891,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>
diff --git a/truthsayer/src/lib/global.tsx b/truthsayer/src/lib/global.tsx
index 75f8924..08792eb 100644
--- a/truthsayer/src/lib/global.tsx
+++ b/truthsayer/src/lib/global.tsx
@@ -9,9 +9,9 @@ import { jcss } from 'elementary'
 import {
   createUserAccount,
   AccountInterface,
-  makeDatacenterStorageApi,
   makeAlwaysThrowingStorageApi,
 } from 'smuggler-api'
+import { makeMsgProxyStorageApi } from 'truthsayer-archaeologist-communication'
 import type { StorageApi } from 'smuggler-api'
 
 import styles from './global.module.css'
@@ -116,7 +116,7 @@ export class MzdGlobal extends React.Component<MzdGlobalProps, MzdGlobalState> {
       },
       account: null,
       analytics: props.analytics,
-      storage: makeDatacenterStorageApi(),
+      storage: makeMsgProxyStorageApi(),
     }
   }
 
-- 
2.25.1

@SergNikitin
Copy link
Collaborator Author

Media1.mp4

@akindyakov
Copy link
Contributor

Look fantastic!

In demo, newly added fragment appeared not on top of existing fragments. Is that on purpose or search results sort has been accidentally broken?

@SergNikitin
Copy link
Collaborator Author

In demo, newly added fragment appeared not on top of existing fragments. Is that on purpose or search results sort has been accidentally broken?

It's one of the things that are broken -- unfortunately there are plenty of those. Since this is a big overhaul I'll need to spend more time on testing and bug fixes once the big bits are in place.

@SergNikitin SergNikitin marked this pull request as ready for review January 15, 2023 10:39
@SergNikitin SergNikitin merged commit 80b55d6 into main Jan 15, 2023
@SergNikitin SergNikitin deleted the storage-api-3 branch January 15, 2023 12:19
This was referenced Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants