From 7239b67b8a907213b9548019fa670281b95232de Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Wed, 17 Nov 2021 10:09:32 +0100 Subject: [PATCH] refactor: os notification class/type removed --- status/notifications/os_notifications.nim | 20 ---------- status/status.nim | 3 -- status/types/os_notification.nim | 46 ----------------------- 3 files changed, 69 deletions(-) delete mode 100644 status/notifications/os_notifications.nim delete mode 100644 status/types/os_notification.nim diff --git a/status/notifications/os_notifications.nim b/status/notifications/os_notifications.nim deleted file mode 100644 index a379134..0000000 --- a/status/notifications/os_notifications.nim +++ /dev/null @@ -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)) \ No newline at end of file diff --git a/status/status.nim b/status/status.nim index 27e6d7f..a2b6f09 100644 --- a/status/status.nim +++ b/status/status.nim @@ -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) = diff --git a/status/types/os_notification.nim b/status/types/os_notification.nim deleted file mode 100644 index e9eda5e..0000000 --- a/status/types/os_notification.nim +++ /dev/null @@ -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 - } \ No newline at end of file