From be696ad20fbd06415b99414e3423a21c7bd19525 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 8 Jun 2021 11:43:10 -0400 Subject: [PATCH] add mailserver layer to status lib; remove references to libstatus mailservers --- src/app/chat/event_handling.nim | 1 - src/app/chat/view.nim | 5 ++--- src/app/profile/core.nim | 1 - src/status/mailservers.nim | 22 ++++++++++++++++++++++ src/status/status.nim | 4 +++- 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 src/status/mailservers.nim diff --git a/src/app/chat/event_handling.nim b/src/app/chat/event_handling.nim index a150dba706..c18bf0593b 100644 --- a/src/app/chat/event_handling.nim +++ b/src/app/chat/event_handling.nim @@ -6,7 +6,6 @@ import import # status-desktop libs ../../status/chat/chat as status_chat, ./views/communities, - ../../status/libstatus/mailservers as status_mailservers, ../../status/tasks/marathon, ../../status/tasks/marathon/mailserver/worker, ../../status/libstatus/mailservers # TODO: needed for MailserverTopic type, remove? diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index 0264b541c2..2bb17dace6 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -1,8 +1,7 @@ import NimQml, Tables, json, sequtils, chronicles, times, re, sugar, strutils, os, strformat, algorithm -import ../../status/status +import ../../status/[status, mailservers] import ../../status/libstatus/chat as libstatus_chat import ../../status/libstatus/accounts/constants -import ../../status/libstatus/mailservers as status_mailservers import ../../status/libstatus/chat as core_chat import ../../status/libstatus/utils as status_utils import ../../status/accounts as status_accounts @@ -749,7 +748,7 @@ QtObject: proc fillGaps*(self: ChatsView, messageId: string) {.slot.} = self.loadingMessages = true self.loadingMessagesChanged(true) - discard status_mailservers.fillGaps(self.activeChannel.id, @[messageId]) + discard self.status.mailservers.fillGaps(self.activeChannel.id, @[messageId]) proc leaveActiveChat*(self: ChatsView) {.slot.} = self.status.chat.leave(self.activeChannel.id) diff --git a/src/app/profile/core.nim b/src/app/profile/core.nim index 2e8f5a3048..b422005609 100644 --- a/src/app/profile/core.nim +++ b/src/app/profile/core.nim @@ -1,6 +1,5 @@ import NimQml, json, strutils, sugar, sequtils, tables import json_serialization -import ../../status/libstatus/mailservers as status_mailservers import ../../status/signals/types import ../../status/libstatus/accounts/constants import ../../status/libstatus/types as status_types diff --git a/src/status/mailservers.nim b/src/status/mailservers.nim new file mode 100644 index 0000000000..4285ffbf09 --- /dev/null +++ b/src/status/mailservers.nim @@ -0,0 +1,22 @@ +import json, json_serialization + +import + sugar, sequtils, strutils, atomics + +import libstatus/mailservers as status_mailservers +import ../eventemitter +import signals/types + +#TODO: temporary? +import libstatus/types as LibStatusTypes + +type + MailserversModel* = ref object + events*: EventEmitter + +proc newMailserversModel*(events: EventEmitter): MailserversModel = + result = MailserversModel() + result.events = events + +proc fillGaps*(self: MailserversModel, chatId: string, messageIds: seq[string]): string = + result = status_mailservers.fillGaps(chatId, messageIds) diff --git a/src/status/status.nim b/src/status/status.nim index 3b8cfc5548..64e89b66ff 100644 --- a/src/status/status.nim +++ b/src/status/status.nim @@ -2,7 +2,7 @@ import libstatus/accounts as libstatus_accounts import libstatus/core as libstatus_core import libstatus/settings as libstatus_settings import libstatus/types as libstatus_types -import chat, accounts, wallet, node, network, messages, contacts, profile, stickers, permissions, fleet, settings +import chat, accounts, wallet, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers import ../eventemitter import ./tasks/task_runner_impl @@ -23,6 +23,7 @@ type Status* = ref object permissions*: PermissionsModel tasks*: TaskRunner settings*: SettingsModel + mailservers*: MailserversModel proc newStatusInstance*(fleetConfig: string): Status = result = Status() @@ -41,6 +42,7 @@ proc newStatusInstance*(fleetConfig: string): Status = result.stickers = stickers.newStickersModel(result.events) result.permissions = permissions.newPermissionsModel(result.events) result.settings = settings.newSettingsModel(result.events) + result.mailservers = mailservers.newMailserversModel(result.events) proc initNode*(self: Status) = self.tasks.init()