From b6a5b7e4ed2bf17eae04d54472a1cf4d0605757c Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Wed, 20 Oct 2021 12:11:55 -0400 Subject: [PATCH] refactor: remove bookmarks (#90) --- backends/backend.nim | 5 --- backends/base/bookmarks.nim | 14 --------- backends/statusgo/bookmarks.nim | 37 ----------------------- status/browser.nim | 28 ----------------- status/status.nim | 4 +-- status/statusgo_backend_new/bookmarks.nim | 21 +++++++++++++ types/bookmark.nim | 5 --- vendor/status-go | 2 +- 8 files changed, 23 insertions(+), 93 deletions(-) delete mode 100644 backends/base/bookmarks.nim delete mode 100644 backends/statusgo/bookmarks.nim delete mode 100644 status/browser.nim create mode 100644 status/statusgo_backend_new/bookmarks.nim delete mode 100644 types/bookmark.nim diff --git a/backends/backend.nim b/backends/backend.nim index ba3214d..eb2e5ac 100644 --- a/backends/backend.nim +++ b/backends/backend.nim @@ -1,16 +1,11 @@ from ./types import Backend, StatusGoBackend, MockBackend export Backend, StatusGoBackend, MockBackend -from base/bookmarks as bookmarks_methods import storeBookmark, updateBookmark, getBookmarks, deleteBookmark -export storeBookmark, updateBookmark, getBookmarks, deleteBookmark - from base/keycard as keycard_methods import keycardStart, keycardStop, keycardSelect, keycardPair, keycardOpenSecureChannel, keycardVerifyPin, keycardExportKey export keycardStart, keycardStop, keycardSelect, keycardPair, keycardOpenSecureChannel, keycardVerifyPin, keycardExportKey -import statusgo/bookmarks as statusgo_bookmarks -import mock/bookmarks as mock_bookmarks import statusgo/keycard as statusgo_keycard import mock/keycard as mock_keycard diff --git a/backends/base/bookmarks.nim b/backends/base/bookmarks.nim deleted file mode 100644 index fa2c8cb..0000000 --- a/backends/base/bookmarks.nim +++ /dev/null @@ -1,14 +0,0 @@ -import ../../types/[bookmark] -import ../types - -method storeBookmark*(self: Backend, bookmark: Bookmark): Bookmark = - raise newException(ValueError, "No implementation available") - -method updateBookmark*(self: Backend, originalUrl: string, bookmark: Bookmark) = - raise newException(ValueError, "No implementation available") - -method getBookmarks*(self: Backend): seq[Bookmark] = - raise newException(ValueError, "No implementation available") - -method deleteBookmark*(self: Backend, url: string) = - raise newException(ValueError, "No implementation available") diff --git a/backends/statusgo/bookmarks.nim b/backends/statusgo/bookmarks.nim deleted file mode 100644 index d14b48a..0000000 --- a/backends/statusgo/bookmarks.nim +++ /dev/null @@ -1,37 +0,0 @@ -import json, chronicles - -import ../../types/[bookmark] -import ../types -import ./core - -method storeBookmark*(self: StatusGoBackend, bookmark: Bookmark): Bookmark = - let payload = %* [{"url": bookmark.url, "name": bookmark.name}] - try: - let resp = callPrivateRPC("browsers_storeBookmark", payload).parseJson["result"] - bookmark.imageUrl = resp["imageUrl"].getStr - return bookmark - except Exception as e: - error "Error updating bookmark", msg = e.msg - discard - -method updateBookmark*(self: StatusGoBackend, originalUrl: string, bookmark: Bookmark) = - let payload = %* [originalUrl, {"url": bookmark.url, "name": bookmark.name}] - try: - discard callPrivateRPC("browsers_updateBookmark", payload) - except Exception as e: - error "Error updating bookmark", msg = e.msg - discard - -method getBookmarks*(self: StatusGoBackend): seq[Bookmark] = - let payload = %* [] - try: - let responseResult = callPrivateRPC("browsers_getBookmarks", payload).parseJson["result"] - if responseResult.kind != JNull: - for bookmark in responseResult: - result.add(Bookmark(url: bookmark{"url"}.getStr, name: bookmark{"name"}.getStr, imageUrl: bookmark{"imageUrl"}.getStr)) - except: - discard - -method deleteBookmark*(self: StatusGoBackend, url: string) = - let payload = %* [url] - discard callPrivateRPC("browsers_deleteBookmark", payload) diff --git a/status/browser.nim b/status/browser.nim deleted file mode 100644 index df5bef0..0000000 --- a/status/browser.nim +++ /dev/null @@ -1,28 +0,0 @@ -# import statusgo_backend/browser as status_browser -import ../eventemitter - -import ../../types/[bookmark] - -import ../backends/backend - -type - BrowserModel* = ref object - events*: EventEmitter - backend*: Backend - -proc newBrowserModel*(events: EventEmitter, backend: Backend): BrowserModel = - result = BrowserModel() - result.events = events - result.backend = backend - -proc storeBookmark*(self: BrowserModel, bookmark: Bookmark): Bookmark = - return self.backend.storeBookmark(bookmark) - -proc updateBookmark*(self: BrowserModel, originalUrl: string, bookmark: Bookmark) = - self.backend.updateBookmark(originalUrl, bookmark) - -proc getBookmarks*(self: BrowserModel): seq[Bookmark] = - result = self.backend.getBookmarks() - -proc deleteBookmark*(self: BrowserModel, url: string) = - self.backend.deleteBookmark(url) diff --git a/status/status.nim b/status/status.nim index 5c7c0cd..27e6d7f 100644 --- a/status/status.nim +++ b/status/status.nim @@ -1,7 +1,7 @@ import statusgo_backend/accounts as statusgo_backend_accounts import statusgo_backend/core as statusgo_backend_core import statusgo_backend/settings as statusgo_backend_settings -import chat, accounts, wallet, wallet2, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers, browser, tokens, provider +import chat, accounts, wallet, wallet2, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers, tokens, provider import notifications/os_notifications import ../eventemitter import bitops, stew/byteutils, chronicles @@ -29,7 +29,6 @@ type Status* = ref object permissions*: PermissionsModel settings*: SettingsModel mailservers*: MailserversModel - browser*: BrowserModel tokens*: TokensModel provider*: ProviderModel osnotifications*: OsNotifications @@ -54,7 +53,6 @@ proc newStatusInstance*(fleetConfig: string, backendName: string = "statusgo"): result.permissions = permissions.newPermissionsModel(result.events) result.settings = settings.newSettingsModel(result.events) result.mailservers = mailservers.newMailserversModel(result.events) - result.browser = browser.newBrowserModel(result.events, result.backend) result.tokens = tokens.newTokensModel(result.events) result.provider = provider.newProviderModel(result.events, result.permissions, result.wallet) result.osnotifications = newOsNotifications(result.events) diff --git a/status/statusgo_backend_new/bookmarks.nim b/status/statusgo_backend_new/bookmarks.nim new file mode 100644 index 0000000..7152dfb --- /dev/null +++ b/status/statusgo_backend_new/bookmarks.nim @@ -0,0 +1,21 @@ +import json, strmisc +import core, utils +import response_type + +export response_type + +proc getBookmarks*(): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [] + result = callPrivateRPC("browsers_getBookmarks", payload) + +proc storeBookmark*(url, name: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [{"url": url, "name": name}] + result = callPrivateRPC("browsers_storeBookmark", payload) + +proc deleteBookmark*(url: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [url] + result = callPrivateRPC("browsers_deleteBookmark", payload) + +proc updateBookmark*(originalUrl, newUrl, name: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [originalUrl, {"url": newUrl, "name": name}] + result = callPrivateRPC("browsers_updateBookmark", payload) diff --git a/types/bookmark.nim b/types/bookmark.nim deleted file mode 100644 index c2c9ed4..0000000 --- a/types/bookmark.nim +++ /dev/null @@ -1,5 +0,0 @@ - -type Bookmark* = ref object - name*: string - url*: string - imageUrl*: string diff --git a/vendor/status-go b/vendor/status-go index c3ced09..bade0a2 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit c3ced098390f3d4e8d4850d9c0bf6e7dbd627c20 +Subproject commit bade0a24fff87c8cfbc6ba0e9322c9cccf1a656a