refactor: os notification class/type removed

This commit is contained in:
Sale Djenic 2022-02-01 10:27:17 +01:00 committed by saledjenic
parent 45eade2218
commit 0bc0110e9a
4 changed files with 4 additions and 71 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

@ -1,8 +1,7 @@
import statusgo_backend/accounts as statusgo_backend_accounts 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, tokens 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]
@ -29,7 +28,7 @@ type Status* = ref object
permissions*: PermissionsModel permissions*: PermissionsModel
settings*: SettingsModel settings*: SettingsModel
tokens*: TokensModel tokens*: TokensModel
osnotifications*: OsNotifications provider*: ProviderModel
keycard*: KeycardModel keycard*: KeycardModel
proc newStatusInstance*(fleetConfig: string, backendName: string = "statusgo"): Status = proc newStatusInstance*(fleetConfig: string, backendName: string = "statusgo"): Status =
@ -51,7 +50,7 @@ proc newStatusInstance*(fleetConfig: string, backendName: string = "statusgo"):
result.permissions = permissions.newPermissionsModel(result.events) result.permissions = permissions.newPermissionsModel(result.events)
result.settings = settings.newSettingsModel(result.events) result.settings = settings.newSettingsModel(result.events)
result.tokens = tokens.newTokensModel(result.events) result.tokens = tokens.newTokensModel(result.events)
result.osnotifications = newOsNotifications(result.events) result.provider = provider.newProviderModel(result.events, result.permissions, result.wallet)
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
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 2b8b2be1f2cad3c46a46055ee402ea4583c3b764 Subproject commit 6e1eece54560016515e04ca379c57b713ded8435