2022-01-05 08:11:35 +01:00
|
|
|
//
|
|
|
|
// MastodonServerRulesViewModel+Diffable.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-1-5.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
extension MastodonServerRulesViewModel {
|
|
|
|
func setupDiffableDataSource(
|
|
|
|
tableView: UITableView
|
|
|
|
) {
|
|
|
|
diffableDataSource = ServerRuleSection.tableViewDiffableDataSource(tableView: tableView)
|
|
|
|
|
|
|
|
var snapshot = NSDiffableDataSourceSnapshot<ServerRuleSection, ServerRuleItem>()
|
2022-12-17 20:14:27 +01:00
|
|
|
snapshot.appendSections([.rules])
|
2023-10-04 18:20:42 +02:00
|
|
|
let ruleItems: [ServerRuleItem] = rules.enumerated().map { index, rule in return ServerRuleItem.rule(index: index, rule: rule) }
|
2022-01-05 08:11:35 +01:00
|
|
|
snapshot.appendItems(ruleItems, toSection: .rules)
|
2022-12-17 21:57:17 +01:00
|
|
|
diffableDataSource?.apply(snapshot, animatingDifferences: false)
|
2022-01-05 08:11:35 +01:00
|
|
|
}
|
|
|
|
}
|