diff --git a/src/app/browser/view.nim b/src/app/browser/view.nim index 1248e74eb4..71abce0540 100644 --- a/src/app/browser/view.nim +++ b/src/app/browser/view.nim @@ -1,6 +1,5 @@ import NimQml, json, chronicles -import ../../status/status -import ../../status/libstatus/browser as status_browser +import ../../status/[status, browser] import ../../status/types import views/bookmark_list @@ -25,7 +24,7 @@ QtObject: proc init*(self: BrowserView) = var bookmarks: seq[Bookmark] = @[] try: - let responseResult = status_browser.getBookmarks().parseJson["result"] + let responseResult = self.status.browser.getBookmarks().parseJson["result"] if responseResult.kind != JNull: for bookmark in responseResult: bookmarks.add(Bookmark(url: bookmark["url"].getStr, name: bookmark["name"].getStr, imageUrl: bookmark["imageUrl"].getStr)) @@ -44,7 +43,7 @@ QtObject: notify = bookmarksChanged proc addBookmark*(self: BrowserView, url: string, name: string) {.slot.} = - let bookmark = status_browser.storeBookmark(url, name) + let bookmark = self.status.browser.storeBookmark(url, name) self.bookmarks.addBookmarkItemToList(bookmark) self.bookmarksChanged() @@ -53,7 +52,7 @@ QtObject: if index == -1: return self.bookmarks.removeBookmarkItemFromList(index) - status_browser.deleteBookmark(url) + self.status.browser.deleteBookmark(url) self.bookmarksChanged() proc modifyBookmark*(self: BrowserView, ogUrl: string, newUrl: string, newName: string) {.slot.} = @@ -63,5 +62,5 @@ QtObject: self.addBookmark(newUrl, newName) return self.bookmarks.modifyBookmarkItemFromList(index, newUrl, newName) - status_browser.updateBookmark(ogUrl, newUrl, newName) + self.status.browser.updateBookmark(ogUrl, newUrl, newName) self.bookmarksChanged() diff --git a/src/status/browser.nim b/src/status/browser.nim new file mode 100644 index 0000000000..1af4fcfef0 --- /dev/null +++ b/src/status/browser.nim @@ -0,0 +1,31 @@ +import json, json_serialization + +import + sugar, sequtils, strutils, atomics + +import libstatus/browser as status_browser +import ../eventemitter +import signals/types + +#TODO: temporary? +import types as LibStatusTypes + +type + BrowserModel* = ref object + events*: EventEmitter + +proc newBrowserModel*(events: EventEmitter): BrowserModel = + result = BrowserModel() + result.events = events + +proc storeBookmark*(self: BrowserModel, url: string, name: string): Bookmark = + result = status_browser.storeBookmark(url, name) + +proc updateBookmark*(self: BrowserModel, ogUrl: string, url: string, name: string) = + status_browser.updateBookmark(ogUrl, url, name) + +proc getBookmarks*(self: BrowserModel): string = + result = status_browser.getBookmarks() + +proc deleteBookmark*(self: BrowserModel, url: string) = + status_browser.deleteBookmark(url) diff --git a/src/status/status.nim b/src/status/status.nim index a423b06075..fa39a59813 100644 --- a/src/status/status.nim +++ b/src/status/status.nim @@ -2,7 +2,7 @@ import libstatus/accounts as libstatus_accounts import libstatus/core as libstatus_core import libstatus/settings as libstatus_settings import types as libstatus_types -import chat, accounts, wallet, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers +import chat, accounts, wallet, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers, browser import ../eventemitter import ./tasks/task_runner_impl @@ -24,6 +24,7 @@ type Status* = ref object tasks*: TaskRunner settings*: SettingsModel mailservers*: MailserversModel + browser*: BrowserModel proc newStatusInstance*(fleetConfig: string): Status = result = Status() @@ -43,6 +44,7 @@ proc newStatusInstance*(fleetConfig: string): Status = result.permissions = permissions.newPermissionsModel(result.events) result.settings = settings.newSettingsModel(result.events) result.mailservers = mailservers.newMailserversModel(result.events) + result.browser = browser.newBrowserModel(result.events) proc initNode*(self: Status) = self.tasks.init()