refactor: os notification class/type removed

This commit is contained in:
Sale Djenic 2021-11-17 10:09:32 +01:00
parent 605a1cd8a1
commit 7239b67b8a
3 changed files with 0 additions and 69 deletions

View File

@ -1,20 +0,0 @@
import json
import ../types/[os_notification]
import ../../eventemitter
type OsNotifications* = ref object
events: EventEmitter
proc delete*(self: OsNotifications) =
discard
proc newOsNotifications*(events: EventEmitter): OsNotifications =
result = OsNotifications()
result.events = events
proc onNotificationClicked*(self: OsNotifications, identifier: string) =
## This slot is called once user clicks a notificaiton bubble, "identifier"
## contains data which uniquely define that notification.
let details = toOsNotificationDetails(parseJson(identifier))
self.events.emit("osNotificationClicked", OsNotificationsArgs(details: details))

View File

@ -2,7 +2,6 @@ import statusgo_backend/accounts as statusgo_backend_accounts
import statusgo_backend/core as statusgo_backend_core import statusgo_backend/core as statusgo_backend_core
import statusgo_backend/settings as statusgo_backend_settings import statusgo_backend/settings as statusgo_backend_settings
import chat, accounts, wallet, wallet2, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers, 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 ../eventemitter
import bitops, stew/byteutils, chronicles import bitops, stew/byteutils, chronicles
import ./types/[setting] import ./types/[setting]
@ -31,7 +30,6 @@ type Status* = ref object
mailservers*: MailserversModel mailservers*: MailserversModel
tokens*: TokensModel tokens*: TokensModel
provider*: ProviderModel provider*: ProviderModel
osnotifications*: OsNotifications
keycard*: KeycardModel keycard*: KeycardModel
proc newStatusInstance*(fleetConfig: string, backendName: string = "statusgo"): Status = proc newStatusInstance*(fleetConfig: string, backendName: string = "statusgo"): Status =
@ -55,7 +53,6 @@ proc newStatusInstance*(fleetConfig: string, backendName: string = "statusgo"):
result.mailservers = mailservers.newMailserversModel(result.events) result.mailservers = mailservers.newMailserversModel(result.events)
result.tokens = tokens.newTokensModel(result.events) result.tokens = tokens.newTokensModel(result.events)
result.provider = provider.newProviderModel(result.events, result.permissions, result.wallet) result.provider = provider.newProviderModel(result.events, result.permissions, result.wallet)
result.osnotifications = newOsNotifications(result.events)
result.keycard = newKeycardModel(result.backend) result.keycard = newKeycardModel(result.backend)
proc initNode*(self: Status, statusGoDir, keystoreDir: string) = proc initNode*(self: Status, statusGoDir, keystoreDir: string) =

View File

@ -1,46 +0,0 @@
{.used.}
import json
import ../../eventemitter
type
OsNotificationType* {.pure.} = enum
NewContactRequest = 1,
AcceptedContactRequest,
JoinCommunityRequest,
AcceptedIntoCommunity,
RejectedByCommunity,
NewMessage
OsNotificationDetails* = object
notificationType*: OsNotificationType
communityId*: string
channelId*: string
messageId*: string
type
OsNotificationsArgs* = ref object of Args
details*: OsNotificationDetails
proc toOsNotificationDetails*(json: JsonNode): OsNotificationDetails =
if (not (json.contains("notificationType") and
json.contains("communityId") and
json.contains("channelId") and
json.contains("messageId"))):
return OsNotificationDetails()
return OsNotificationDetails(
notificationType: json{"notificationType"}.getInt.OsNotificationType,
communityId: json{"communityId"}.getStr,
channelId: json{"channelId"}.getStr,
messageId: json{"messageId"}.getStr
)
proc toJsonNode*(self: OsNotificationDetails): JsonNode =
result = %* {
"notificationType": self.notificationType.int,
"communityId": self.communityId,
"channelId": self.channelId,
"messageId": self.messageId
}