mirror of
https://github.com/status-im/status-lib.git
synced 2025-02-02 15:43:57 +00:00
refactor: os notification class/type removed
This commit is contained in:
parent
605a1cd8a1
commit
7239b67b8a
@ -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))
|
@ -2,7 +2,6 @@ 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, tokens, provider
|
||||
import notifications/os_notifications
|
||||
import ../eventemitter
|
||||
import bitops, stew/byteutils, chronicles
|
||||
import ./types/[setting]
|
||||
@ -31,7 +30,6 @@ type Status* = ref object
|
||||
mailservers*: MailserversModel
|
||||
tokens*: TokensModel
|
||||
provider*: ProviderModel
|
||||
osnotifications*: OsNotifications
|
||||
keycard*: KeycardModel
|
||||
|
||||
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.tokens = tokens.newTokensModel(result.events)
|
||||
result.provider = provider.newProviderModel(result.events, result.permissions, result.wallet)
|
||||
result.osnotifications = newOsNotifications(result.events)
|
||||
result.keycard = newKeycardModel(result.backend)
|
||||
|
||||
proc initNode*(self: Status, statusGoDir, keystoreDir: string) =
|
||||
|
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user