diff --git a/Nynja/DatabaseManager.swift b/Nynja/DatabaseManager.swift index 17a16503b7f132fc113d1549eb07bab435c7d37e..bae92e216bbf9f6ed2ce90ad3510d2d59a926518 100644 --- a/Nynja/DatabaseManager.swift +++ b/Nynja/DatabaseManager.swift @@ -94,9 +94,7 @@ final class DatabaseManager: DBManagerProtocol { private func makeConfiguration(with passphrase: String?) -> Configuration { var configuration = Configuration() configuration.passphrase = passphrase - configuration.trace = nil //{ info in -// LogService.log(topic: .db) { return "DB Path: \(self.dbPool?.path ?? "")" + "\n" + info } -// } + configuration.trace = nil return configuration } diff --git a/Nynja/Library/UI/AlertManager.swift b/Nynja/Library/UI/AlertManager.swift index cbea0456e7d852de3b2a90442b63ec89a2d7bace..dd5a6d51908b8d0d814045ad7f321d062a2dd4a2 100644 --- a/Nynja/Library/UI/AlertManager.swift +++ b/Nynja/Library/UI/AlertManager.swift @@ -29,6 +29,14 @@ class AlertManager { presentingController?.present(alert, animated: true, completion: nil) } + func showAlert(title: String, dismissInterval: TimeInterval) { + let alert = UIAlertController(title: "\n\(title)\n ", message: "", preferredStyle: .alert) + dispatchAsyncMainAfter(dismissInterval) { + alert.dismiss(animated: true, completion: nil) + } + presentingController?.present(alert, animated: true, completion: nil) + } + func showAlertOk(message: String, completion:(()->Void)? = nil) { showAlertOk(title: "", message: message, completion: completion) } diff --git a/Nynja/LogService/LogService.swift b/Nynja/LogService/LogService.swift index 56708486ec422827f15f84b827923b9e7d0806a1..d25ebea873864801256b771bf8839aa3b0387610 100644 --- a/Nynja/LogService/LogService.swift +++ b/Nynja/LogService/LogService.swift @@ -50,7 +50,6 @@ class LogService { } static func log(topic: LogServiceTopic, block: () -> String) { - return #if !RELEASE if !enable.contains(topic) { return } LogService.executeLogs(topic: topic, text: block(), thread: Thread.current.debugDescription) diff --git a/Nynja/Modules/ChannelsList/Interactor/ChannelsListInteractor.swift b/Nynja/Modules/ChannelsList/Interactor/ChannelsListInteractor.swift index af4fdb8d118cd24a85192560ed0ca851fd3a2d0a..69b2c0e4f4ff0360c59e16746469af58ef17a9b2 100644 --- a/Nynja/Modules/ChannelsList/Interactor/ChannelsListInteractor.swift +++ b/Nynja/Modules/ChannelsList/Interactor/ChannelsListInteractor.swift @@ -55,15 +55,22 @@ final class ChannelsListInteractor: BaseInteractor, ChannelsListInteractorInputP // MARK: - StorageSubscriber override func update(with changes: [StorageChange], type: SubscribeType) { - guard let dbRoom = changes.first?.entity as? DBRoom else { + guard case .room = type else { return } - let room = Room(room: dbRoom) - if room.kind == .channel { - if mode == .mine && ![.owner, .admin].contains(room.role) { - return + + if changes.count == 1, let dbRoom = changes.first?.entity as? DBRoom { + let room = Room(room: dbRoom) + if room.kind == .channel { + if mode == .mine && ![.owner, .admin].contains(room.role) { + return + } + + channels = updateChatsList(with: room) + applyFilter(with: searchText) } - channels = updateChatsList(with: room) + } else { + loadChannels() applyFilter(with: searchText) } } @@ -71,13 +78,16 @@ final class ChannelsListInteractor: BaseInteractor, ChannelsListInteractorInputP //MARK: - Private - private func fetchChannels() { + private func loadChannels() { if mode == .all { channels = conversationsProvider.fetchChannels() } else { channels = conversationsProvider.fetchMyChannels() } - + } + + private func fetchChannels() { + loadChannels() presenter.channelsFetched(channels) } diff --git a/Nynja/Modules/ChatsList/Interactor/ChatsListInteractor.swift b/Nynja/Modules/ChatsList/Interactor/ChatsListInteractor.swift index c40b768de14a39c37cab30f8e33ce1e684c8de63..02aa173111d987dda1e4f5fa6d1a242e6bee4f26 100644 --- a/Nynja/Modules/ChatsList/Interactor/ChatsListInteractor.swift +++ b/Nynja/Modules/ChatsList/Interactor/ChatsListInteractor.swift @@ -53,13 +53,18 @@ class ChatsListInteractor: BaseInteractor, ChatsListInteractorInputProtocol, Ini // MARK: - StorageSubscriber override func update(with changes: [StorageChange], type: SubscribeType) { - if case .contact = type { - if let dbContact = changes.first?.entity as? DBContact { - let contact = Contact(contact: dbContact) - chats = updateChatsList(with: contact) - applyFilter(with: searchText) - } + guard case .contact = type else { + return + } + + if changes.count == 1, let dbContact = changes.first?.entity as? DBContact { + let contact = Contact(contact: dbContact) + chats = updateChatsList(with: contact) + } else { + chats = conversationsProvider.fetchChats() } + + applyFilter(with: searchText) } diff --git a/Nynja/Modules/GroupsList/Interactor/GroupsListInteractor.swift b/Nynja/Modules/GroupsList/Interactor/GroupsListInteractor.swift index 438b2c88ae18017a6a335fc157e3623c11e6111c..c16ee18b592dc3cf72bec06869f27034189d6902 100644 --- a/Nynja/Modules/GroupsList/Interactor/GroupsListInteractor.swift +++ b/Nynja/Modules/GroupsList/Interactor/GroupsListInteractor.swift @@ -56,12 +56,19 @@ class GroupsListInteractor: BaseInteractor, GroupsListInteractorInputProtocol, I // MARK: - StorageSubscriber override func update(with changes: [StorageChange], type: SubscribeType) { - if let dbRoom = changes.first?.entity as? DBRoom { + guard case .room = type else { + return + } + + if changes.count == 1, let dbRoom = changes.first?.entity as? DBRoom { let room = Room(room: dbRoom) if room.kind == .group { chats = updateChatsList(with: room) applyFilter(with: searchText) } + } else { + chats = conversationsProvider.fetchGroups() + applyFilter(with: searchText) } } diff --git a/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift b/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift index 80311b819eb7d3941a8ad0722d79e2529c23d9ff..8ccbf35d32d7799059c132f4abb37df8e9e61a23 100644 --- a/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift +++ b/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift @@ -11,7 +11,7 @@ import Photos extension MainViewController: NavigateProtocol { func unavailableFunctionality() { - AlertManager.sharedInstance.showAlertOk(message: "coming_soon".localized) + AlertManager.sharedInstance.showAlert(title: "coming_soon".localized, dismissInterval: 3) } //MARK: - First lvl diff --git a/Nynja/OptionsItemsFactory.swift b/Nynja/OptionsItemsFactory.swift index 4f28559b6c98ab77083a9f4f4446ff1e9df8918e..5d261d632b4981dbcd3987465655072df6fde5f9 100644 --- a/Nynja/OptionsItemsFactory.swift +++ b/Nynja/OptionsItemsFactory.swift @@ -17,7 +17,16 @@ class OptionsItemsFactory: WCBaseItemsFactory { // MARK: - Second lvl override var secondLevelItems: ItemModels { - return [logout, notifications, changeNumber, wheelPosition, buildNumber, support, languageSettings, theme, dataAndStorage, security, privacy] + var items = [ + logout, notifications, changeNumber, wheelPosition, buildNumber, + support, languageSettings, theme, dataAndStorage, security, privacy + ] + + #if DEBUG + items.append(deleteAccount) + #endif + + return items } // MARK: - Items @@ -82,8 +91,11 @@ class OptionsItemsFactory: WCBaseItemsFactory { var deleteAccount: ImageActionItemModel { let item = ImageActionItemModel(navItem: .deleteAccount, action: { [weak navigateDelegate] (item, indexPath) in -// navigateDelegate?.deleteAccount(indexPath: indexPath) + #if DEBUG + navigateDelegate?.deleteAccount(indexPath: indexPath) + #else navigateDelegate?.unavailableFunctionality() + #endif }) return item }