Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Mastodon/Diffable/Report/ReportSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ extension ReportSection {
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item -> UITableViewCell? in
switch item {
case .header(let headerContext):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportHeadlineTableViewCell.self), for: indexPath) as! ReportHeadlineTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportHeadlineTableViewCell.self), for: indexPath) as? ReportHeadlineTableViewCell else { fatalError("WTF?! Wrong cell.") }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid crashing in production, please use assertionFailure("unexpected cell dequeued") and then return nil.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cell.primaryLabel.text = headerContext.primaryLabelText
cell.secondaryLabel.text = headerContext.secondaryLabelText
return cell
case .status(let status):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportStatusTableViewCell.self), for: indexPath) as! ReportStatusTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportStatusTableViewCell.self), for: indexPath) as? ReportStatusTableViewCell else { fatalError("WTF?! Wrong cell.") }
configure(
tableView: tableView,
cell: cell,
Expand All @@ -54,7 +54,7 @@ extension ReportSection {
)
return cell
case .comment(let commentContext):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportCommentTableViewCell.self), for: indexPath) as! ReportCommentTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportCommentTableViewCell.self), for: indexPath) as? ReportCommentTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.commentTextView.text = commentContext.comment
NotificationCenter.default.publisher(for: UITextView.textDidChangeNotification, object: cell.commentTextView)
.receive(on: DispatchQueue.main)
Expand All @@ -71,7 +71,7 @@ extension ReportSection {
.store(in: &cell.disposeBag)
return cell
case .bottomLoader:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as! TimelineBottomLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as? TimelineBottomLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.activityIndicatorView.startAnimating()
return cell
}
Expand Down
10 changes: 5 additions & 5 deletions Mastodon/Diffable/Status/StatusSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension StatusSection {
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item -> UITableViewCell? in
switch item {
case .feed(let feed):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: StatusTableViewCell.self), for: indexPath) as! StatusTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: StatusTableViewCell.self), for: indexPath) as? StatusTableViewCell else { fatalError("WTF?! Wrong cell.") }
let displayItem = StatusTableViewCell.StatusTableViewCellViewModel.DisplayItem.feed(feed)
let contentConcealModel = StatusView.ContentConcealViewModel(status: feed.status, filterBox: StatusFilterService.shared.activeFilterBox, filterContext: configuration.filterContext)
configure(
Expand All @@ -53,15 +53,15 @@ extension StatusSection {
)
return cell
case .feedLoader(let feed):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineMiddleLoaderTableViewCell.self), for: indexPath) as! TimelineMiddleLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineMiddleLoaderTableViewCell.self), for: indexPath) as? TimelineMiddleLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
configure(
cell: cell,
feed: feed,
configuration: configuration
)
return cell
case .status(let status):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: StatusTableViewCell.self), for: indexPath) as! StatusTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: StatusTableViewCell.self), for: indexPath) as? StatusTableViewCell else { fatalError("WTF?! Wrong cell.") }
let displayItem = StatusTableViewCell.StatusTableViewCellViewModel.DisplayItem.status(status)
let contentConcealModel = StatusView.ContentConcealViewModel(status: status, filterBox: StatusFilterService.shared.activeFilterBox, filterContext: configuration.filterContext)
configure(
Expand All @@ -82,11 +82,11 @@ extension StatusSection {
)
return cell
case .topLoader:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as! TimelineBottomLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as? TimelineBottomLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.activityIndicatorView.startAnimating()
return cell
case .bottomLoader:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as! TimelineBottomLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as? TimelineBottomLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.activityIndicatorView.startAnimating()
return cell
}
Expand Down
6 changes: 3 additions & 3 deletions Mastodon/Diffable/User/UserSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension UserSection {
item -> UITableViewCell? in
switch item {
case .account(let account, let relationship):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UserTableViewCell.self), for: indexPath) as! UserTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UserTableViewCell.self), for: indexPath) as? UserTableViewCell else { fatalError("WTF?! Wrong cell.") }

guard let me = authenticationBox.cachedAccount else { return cell }

Expand All @@ -49,11 +49,11 @@ extension UserSection {

return cell
case .bottomLoader:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as! TimelineBottomLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as? TimelineBottomLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.startAnimating()
return cell
case .bottomHeader(let text):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineFooterTableViewCell.self), for: indexPath) as! TimelineFooterTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineFooterTableViewCell.self), for: indexPath) as? TimelineFooterTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.messageLabel.text = text
return cell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extension UITableViewDelegate where Self: DataSourceProvider & MediaPreviewableV
indexPath: IndexPath, point: CGPoint
) -> UIContextMenuConfiguration? {

guard let cell = tableView.cellForRow(at: indexPath) as? StatusViewContainerTableViewCell else { return nil }
guard let cell = tableView.cellForRow(at: indexPath) as? StatusViewContainerTableViewCell else { fatalError("WTF?! Wrong cell.") }

let mediaViews = cell.statusView.mediaGridContainerView.mediaViews

Expand Down
6 changes: 3 additions & 3 deletions Mastodon/Scene/Account/AccountListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension AccountListViewModel {
diffableDataSource = UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
switch item {
case .authentication(let record):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: AccountListTableViewCell.self), for: indexPath) as! AccountListTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: AccountListTableViewCell.self), for: indexPath) as? AccountListTableViewCell else { fatalError("WTF?! Wrong cell.") }
if let activeAuthentication = AuthenticationServiceProvider.shared.currentActiveUser.value
{
AccountListViewModel.configure(
Expand All @@ -84,10 +84,10 @@ extension AccountListViewModel {
}
return cell
case .addAccount:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: AddAccountTableViewCell.self), for: indexPath) as! AddAccountTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: AddAccountTableViewCell.self), for: indexPath) as? AddAccountTableViewCell else { fatalError("WTF?! Wrong cell.") }
return cell
case .logoutOfAllAccounts:
let cell = tableView.dequeueReusableCell(withIdentifier: LogoutOfAllAccountsCell.reuseIdentifier, for: indexPath) as! LogoutOfAllAccountsCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: LogoutOfAllAccountsCell.reuseIdentifier, for: indexPath) as? LogoutOfAllAccountsCell else { fatalError("WTF?! Wrong cell.") }
return cell
}
}
Expand Down
9 changes: 5 additions & 4 deletions Mastodon/Scene/Discovery/DiscoverySection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ extension DiscoverySection {
item in
switch item {
case .hashtag(let tag):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TrendTableViewCell.self), for: indexPath) as! TrendTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TrendTableViewCell.self), for: indexPath) as? TrendTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.trendView.configure(tag: tag)
return cell
case .link(let link):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: NewsTableViewCell.self), for: indexPath) as! NewsTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: NewsTableViewCell.self), for: indexPath) as? NewsTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.newsView.configure(link: link)
return cell
case .account(let account, relationship: let relationship):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ProfileCardTableViewCell.self), for: indexPath) as! ProfileCardTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ProfileCardTableViewCell.self), for: indexPath) as?
ProfileCardTableViewCell else { fatalError("WTF?! Wrong cell.") }

cell.configure(
tableView: tableView,
Expand All @@ -80,7 +81,7 @@ extension DiscoverySection {

return cell
case .bottomLoader:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as! TimelineBottomLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as? TimelineBottomLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.activityIndicatorView.startAnimating()
return cell
}
Expand Down
14 changes: 9 additions & 5 deletions Mastodon/Scene/Notification/NotificationSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ extension NotificationSection {
switch item {
case .feed(let feed):
if let notification = feed.notification, let accountWarning = notification.accountWarning {
let cell = tableView.dequeueReusableCell(withIdentifier: AccountWarningNotificationCell.reuseIdentifier, for: indexPath) as! AccountWarningNotificationCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: AccountWarningNotificationCell.reuseIdentifier, for: indexPath) as?
AccountWarningNotificationCell else { fatalError("WTF?! Wrong cell.") }
cell.configure(with: accountWarning)
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: NotificationTableViewCell.self), for: indexPath) as! NotificationTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: NotificationTableViewCell.self), for: indexPath) as?
NotificationTableViewCell else { fatalError("WTF?! Wrong cell.") }
configure(
tableView: tableView,
cell: cell,
Expand All @@ -58,16 +60,18 @@ extension NotificationSection {
}

case .feedLoader:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as! TimelineBottomLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as?
TimelineBottomLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.activityIndicatorView.startAnimating()
return cell
case .bottomLoader:
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as! TimelineBottomLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self), for: indexPath) as?
TimelineBottomLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.activityIndicatorView.startAnimating()
return cell

case .filteredNotifications(let policy):
let cell = tableView.dequeueReusableCell(withIdentifier: NotificationFilteringBannerTableViewCell.reuseIdentifier, for: indexPath) as! NotificationFilteringBannerTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: NotificationFilteringBannerTableViewCell.reuseIdentifier, for: indexPath) as? NotificationFilteringBannerTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.configure(with: policy)

return cell
Expand Down
4 changes: 2 additions & 2 deletions Mastodon/Scene/Onboarding/PickServer/PickServerSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ extension PickServerSection {
guard let _ = dependency else { return nil }
switch item {
case .server(let server, let attribute):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: PickServerCell.self), for: indexPath) as! PickServerCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: PickServerCell.self), for: indexPath) as? PickServerCell else { fatalError("WTF?! Wrong cell.") }
PickServerSection.configure(cell: cell, server: server, attribute: attribute)
return cell
case .loader(let attribute):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: PickServerLoaderTableViewCell.self), for: indexPath) as! PickServerLoaderTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: PickServerLoaderTableViewCell.self), for: indexPath) as? PickServerLoaderTableViewCell else { fatalError("WTF?! Wrong cell.") }
PickServerSection.configure(cell: cell, attribute: attribute)
return cell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension ServerRuleSection {
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
switch item {
case .rule(let index, let rule):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ServerRulesTableViewCell.self), for: indexPath) as! ServerRulesTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ServerRulesTableViewCell.self), for: indexPath) as? ServerRulesTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.indexImageView.image = UIImage(systemName: "\(index + 1).circle") ?? UIImage(systemName: "questionmark.circle")
cell.indexImageView.tintColor = Asset.Colors.Brand.lightBlurple.color
cell.ruleLabel.text = rule.text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension SearchResultSection {
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item -> UITableViewCell? in
switch item {
case .account(let account, let relationship):
let cell = tableView.dequeueReusableCell(withIdentifier: UserTableViewCell.reuseIdentifier, for: indexPath) as! UserTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: UserTableViewCell.reuseIdentifier, for: indexPath) as? UserTableViewCell else { fatalError("WTF?! Wrong cell.") }

guard let me = authenticationBox.cachedAccount else { return cell }

Expand All @@ -55,7 +55,8 @@ extension SearchResultSection {
)
return cell
case .status(let status):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: StatusTableViewCell.self), for: indexPath) as! StatusTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: StatusTableViewCell.self), for: indexPath) as?
StatusTableViewCell else { fatalError("WTF?! Wrong cell.") }
let displayItem = StatusTableViewCell.StatusTableViewCellViewModel.DisplayItem.status(status)
let contentConcealModel = StatusView.ContentConcealViewModel(status: status, filterBox: StatusFilterService.shared.activeFilterBox, filterContext: nil) // no filters in search results
configure(
Expand All @@ -66,7 +67,7 @@ extension SearchResultSection {
)
return cell
case .hashtag(let tag):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: HashtagTableViewCell.self)) as! HashtagTableViewCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: HashtagTableViewCell.self)) as? HashtagTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.primaryLabel.configure(content: PlaintextMetaContent(string: "#" + tag.name))
return cell
case .bottomLoader(let attribute):
Expand Down
Loading