// // NotificationsPresenter.swift // PrivadoVPN // // Created by Zhandos Bolatbekov on 11.01.2021. // Copyright © 2021 Privado LLC. All rights reserved. // import Foundation final class NotificationsPresenter: NotificationsControllerOutput, NavigationBarViewModuleOutput, NotificationNavBarOutput { weak var viewInput: NotificationsControllerInput? private weak var output: NotificationsModuleOutput? private let notificationsStorage: NotificationsStorage private let cellType: NotificationCellType init(output: NotificationsModuleOutput?, cellType: NotificationCellType, notificationsStorage: NotificationsStorage) { self.cellType = cellType self.output = output self.notificationsStorage = notificationsStorage } // MARK: - NotificationsControllerOutput func viewIsReady() { let linkAction: NotificationCellLinkAction = { [weak self] _ in let extradata = CTAClick(screenType: CTAScreenType.messages).jsonString CometLogger.shared.event(name: PrivadoConstants.Event.Statistic.Application.CTAClick, attributes: [PrivadoConstants.Event.Attributes.extradata: extradata], secured: nil) // Route all messages to purchases list. Since appstore doesn't allow marketing urls. self?.output?.navigate(to: .preference(tab: .upgrade)) } let cells = self.notificationsStorage.notifications.map { NotificationCellAdapter(with: self.cellType, notification: $0, linkAction: linkAction) } self.viewInput?.display(notificationCells: cells) } func backClick() { self.output?.navigate(to: .back) } // MARK: - NavigationBarViewModuleOutput func openPreviousScreen() { self.output?.navigate(to: .back) } // MARK: - NotificationNavBarOutput func didTapCloseButton() { self.output?.navigate(to: .notifications) } }