remove libstatus browser references

This commit is contained in:
Iuri Matias 2021-06-08 12:44:55 -04:00
parent eab9d68aff
commit 6e99b769be
3 changed files with 39 additions and 7 deletions

View File

@ -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()

31
src/status/browser.nim Normal file
View File

@ -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)

View File

@ -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()