Skip to content
Snippets Groups Projects
Commit 6b1a73e5 authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Avoiding some force unwraps and using assertNoFailure

parent 996d2fb9
No related branches found
No related tags found
2 merge requests!40v1.1.2b166,!38Using new database structure
......@@ -326,7 +326,9 @@ extension GroupChatController: UICollectionViewDataSource {
) -> UICollectionViewCell {
let item = sections[indexPath.section].elements[indexPath.item]
let canReply: () -> Bool = { item.status == .sent || item.status == .received }
let canReply: () -> Bool = {
(item.status == .sent || item.status == .received) && item.networkId != nil
}
let performReply: () -> Void = { [weak self] in
self?.viewModel.didRequestReply(item)
......@@ -337,13 +339,13 @@ extension GroupChatController: UICollectionViewDataSource {
let replyContent: (Data) -> (String, String) = viewModel.getReplyContent(for:)
if item.status == .received {
if item.replyMessageId != nil {
if let replyMessageId = item.replyMessageId {
let cell: IncomingGroupReplyCell = collectionView.dequeueReusableCell(forIndexPath: indexPath)
Bubbler.buildReplyGroup(
bubble: cell.leftView,
with: item,
reply: replyContent(item.replyMessageId!),
reply: replyContent(replyMessageId),
sender: name(item.senderId)
)
......@@ -367,13 +369,13 @@ extension GroupChatController: UICollectionViewDataSource {
return cell
}
} else if item.status == .sendingFailed {
if item.replyMessageId != nil {
if let replyMessageId = item.replyMessageId {
let cell: OutgoingFailedGroupReplyCell = collectionView.dequeueReusableCell(forIndexPath: indexPath)
Bubbler.buildReplyGroup(
bubble: cell.rightView,
with: item,
reply: replyContent(item.replyMessageId!),
reply: replyContent(item.replyMessageId),
sender: name(item.senderId)
)
......@@ -396,13 +398,13 @@ extension GroupChatController: UICollectionViewDataSource {
return cell
}
} else {
if item.replyMessageId != nil {
if let replyMessageId = item.replyMessageId {
let cell: OutgoingGroupReplyCell = collectionView.dequeueReusableCell(forIndexPath: indexPath)
Bubbler.buildReplyGroup(
bubble: cell.rightView,
with: item,
reply: replyContent(item.replyMessageId!),
reply: replyContent(item.replyMessageId),
sender: name(item.senderId)
)
......
......@@ -24,8 +24,8 @@ final class ContactListViewModel {
])
return Publishers.CombineLatest(
session.dbManager.fetchContactsPublisher(contactsQuery).catch { _ in Just([]) },
session.dbManager.fetchGroupsPublisher(groupQuery).catch { _ in Just([]) }
session.dbManager.fetchContactsPublisher(contactsQuery).assertNoFailure(),
session.dbManager.fetchGroupsPublisher(groupQuery).assertNoFailure()
)
.map { $0.0.count + $0.1.count }
.eraseToAnyPublisher()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment