move status specific logic of the application view

This commit is contained in:
Iuri Matias 2020-05-11 13:31:07 -04:00
parent 70c15d9266
commit 03b6209f6b
2 changed files with 26 additions and 22 deletions

View File

@ -1,18 +1,8 @@
import NimQml
import status
import libstatus
# import status
# import libstatus
import json
var signalHandler: SignalCallback = proc(p0: cstring): void =
setupForeignThreadGc()
var jsonSignal = ($p0).parseJson
if $jsonSignal["type"].getStr == "messages.new":
echo $p0
tearDownForeignThreadGc()
# Probably all QT classes will look like this:
QtObject:
type ApplicationLogic* = ref object of QObject
@ -28,15 +18,6 @@ QtObject:
result.callResult = "Use this tool to call JSONRPC methods"
result.setup()
status.setSignalHandler(signalHandler)
status.setupNewAccount()
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
result.accountResult = status.queryAccounts()
status.subscribeToTest()
# ¯\_(ツ)_/¯ dunno what is this
proc setup(self: ApplicationLogic) =
# discard status.onMessage(self.onMessage)
@ -73,7 +54,7 @@ QtObject:
notify = callResultChanged
proc onSend*(self: ApplicationLogic, inputJSON: string) {.slot.} =
self.setCallResult(status.callPrivateRPC(inputJSON))
# self.setCallResult(status.callPrivateRPC(inputJSON))
echo "Done!: ", self.callResult
# proc onMessage*(self: ApplicationLogic, message: string) {.slot.} =

View File

@ -2,6 +2,18 @@ import NimQml
import applicationLogic
import chats
import state
import status
import libstatus
import json
var signalHandler: SignalCallback = proc(p0: cstring): void =
setupForeignThreadGc()
var jsonSignal = ($p0).parseJson
if $jsonSignal["type"].getStr == "messages.new":
echo $p0
tearDownForeignThreadGc()
proc mainProc() =
@ -20,6 +32,17 @@ proc mainProc() =
defer: engine.delete()
status.setSignalHandler(signalHandler)
status.setupNewAccount()
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
# result.accountResult = status.queryAccounts()
status.subscribeToTest()
let logic = newApplicationLogic(app)
defer: logic.delete