// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. import UIKit import Combine import GRDB import DifferenceKit import SessionUIKit import SessionMessagingKit import SessionUtilitiesKit protocol SessionTableViewModel: AnyObject, SectionedTableData { var dependencies: Dependencies { get } var title: String { get } var subtitle: String? { get } var initialLoadMessage: String? { get } var cellType: SessionTableViewCellType { get } var emptyStateTextPublisher: AnyPublisher { get } var state: TableDataState { get } var footerView: AnyPublisher { get } var footerButtonInfo: AnyPublisher { get } // MARK: - Functions func canEditRow(at indexPath: IndexPath) -> Bool func leadingSwipeActionsConfiguration(forRowAt indexPath: IndexPath, in tableView: UITableView, of viewController: UIViewController) -> UISwipeActionsConfiguration? func trailingSwipeActionsConfiguration(forRowAt indexPath: IndexPath, in tableView: UITableView, of viewController: UIViewController) -> UISwipeActionsConfiguration? } extension SessionTableViewModel { var subtitle: String? { nil } var initialLoadMessage: String? { nil } var cellType: SessionTableViewCellType { .general } var emptyStateTextPublisher: AnyPublisher { Just(nil).eraseToAnyPublisher() } var tableData: [SectionModel] { state.tableData } var footerView: AnyPublisher { Just(nil).eraseToAnyPublisher() } var footerButtonInfo: AnyPublisher { Just(nil).eraseToAnyPublisher() } // MARK: - Functions func updateTableData(_ updatedData: [SectionModel]) { state.updateTableData(updatedData) } func canEditRow(at indexPath: IndexPath) -> Bool { false } func leadingSwipeActionsConfiguration(forRowAt indexPath: IndexPath, in tableView: UITableView, of viewController: UIViewController) -> UISwipeActionsConfiguration? { nil } func trailingSwipeActionsConfiguration(forRowAt indexPath: IndexPath, in tableView: UITableView, of viewController: UIViewController) -> UISwipeActionsConfiguration? { nil } } // MARK: - SessionTableViewCellType enum SessionTableViewCellType: CaseIterable { case general case fullConversation var viewType: UITableViewCell.Type { switch self { case .general: return SessionCell.self case .fullConversation: return FullConversationCell.self } } }