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

Avoiding force unwraps

parent 6b1a73e5
No related branches found
No related tags found
2 merge requests!40v1.1.2b166,!38Using new database structure
......@@ -375,7 +375,7 @@ extension GroupChatController: UICollectionViewDataSource {
Bubbler.buildReplyGroup(
bubble: cell.rightView,
with: item,
reply: replyContent(item.replyMessageId),
reply: replyContent(replyMessageId),
sender: name(item.senderId)
)
......@@ -404,7 +404,7 @@ extension GroupChatController: UICollectionViewDataSource {
Bubbler.buildReplyGroup(
bubble: cell.rightView,
with: item,
reply: replyContent(item.replyMessageId),
reply: replyContent(replyMessageId),
sender: name(item.senderId)
)
......
......@@ -169,7 +169,7 @@ public final class ContactController: UIViewController {
.sink { [unowned self] in
coordinator.toNickname(
from: self,
prefilled: viewModel.contact.nickname ?? viewModel.contact.username!,
prefilled: (viewModel.contact.nickname ?? viewModel.contact.username) ?? "",
viewModel.didTapRequest(with:)
)
}.store(in: &cancellables)
......@@ -181,7 +181,7 @@ public final class ContactController: UIViewController {
.sink { [unowned self] in
coordinator.toNickname(
from: self,
prefilled: viewModel.contact.nickname ?? viewModel.contact.username!,
prefilled: (viewModel.contact.nickname ?? viewModel.contact.username) ?? "",
viewModel.didTapAccept(_:)
)
}.store(in: &cancellables)
......@@ -243,7 +243,7 @@ public final class ContactController: UIViewController {
.sink { [unowned self] in
coordinator.toNickname(
from: self,
prefilled: viewModel.contact.nickname ?? viewModel.contact.username!,
prefilled: (viewModel.contact.nickname ?? viewModel.contact.username) ?? "",
viewModel.didUpdateNickname(_:)
)
}
......
......@@ -74,7 +74,8 @@ public final class CreateGroupController: UIViewController {
) { [weak viewModel] collectionView, indexPath, contact in
let cell: CreateGroupCollectionCell = collectionView.dequeueReusableCell(forIndexPath: indexPath)
cell.setup(title: contact.nickname ?? contact.username!, image: contact.photo)
let title = (contact.nickname ?? contact.username) ?? ""
cell.setup(title: title, image: contact.photo)
cell.didTapRemove = { viewModel?.didSelect(contact: contact) }
return cell
......@@ -84,8 +85,9 @@ public final class CreateGroupController: UIViewController {
tableView: screenView.tableView
) { [weak self] tableView, indexPath, contact in
let cell = tableView.dequeueReusableCell(forIndexPath: indexPath, ofType: SmallAvatarAndTitleCell.self)
cell.titleLabel.text = contact.nickname ?? contact.username
cell.avatarView.setupProfile(title: contact.nickname ?? contact.username!, image: contact.photo, size: .medium)
let title = (contact.nickname ?? contact.username) ?? ""
cell.titleLabel.text = title
cell.avatarView.setupProfile(title: title, image: contact.photo, size: .medium)
if let selectedElements = self?.selectedElements, selectedElements.contains(contact) {
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
......
......@@ -67,7 +67,11 @@ final class CreateGroupViewModel {
return
}
contactsRelay.send(allContacts.filter { $0.username!.contains(text.lowercased()) })
contactsRelay.send(
allContacts.filter {
($0.username ?? "").contains(text.lowercased())
}
)
}
func create(name: String, welcome: String?, members: [Contact]) {
......
......@@ -110,7 +110,7 @@ public final class PushHandler: PushHandling {
return ($0.type.unknownSenderContent!, $0)
}
let name = contact.nickname ?? contact.username!
let name = (contact.nickname ?? contact.username) ?? ""
return ($0.type.knownSenderContent(name)!, $0)
}
......
......@@ -212,7 +212,7 @@ extension RequestsReceivedController {
let drawerNickname = DrawerText(
font: Fonts.Mulish.extraBold.font(size: 26.0),
text: contact.nickname ?? contact.username!,
text: (contact.nickname ?? contact.username) ?? "",
color: Asset.neutralDark.color,
spacingAfter: 20
)
......@@ -393,7 +393,7 @@ extension RequestsReceivedController {
let drawerUsername = DrawerText(
font: Fonts.Mulish.extraBold.font(size: 26.0),
text: contact.username!,
text: contact.username ?? "",
color: Asset.neutralDark.color,
spacingAfter: 25
)
......@@ -453,7 +453,7 @@ extension RequestsReceivedController {
items.append(drawerNicknameTitle)
let drawerNicknameInput = DrawerInput(
placeholder: contact.username!,
placeholder: contact.username ?? "",
validator: .init(
wrongIcon: .image(Asset.sharedError.image),
correctIcon: .image(Asset.sharedSuccess.image),
......
......@@ -89,7 +89,7 @@ final class RequestCell: UICollectionViewCell {
}
setupContact(
title: contact.nickname ?? contact.username!,
title: (contact.nickname ?? contact.username) ?? "",
photo: contact.photo,
phone: phone,
email: contact.email,
......@@ -128,7 +128,7 @@ final class RequestCell: UICollectionViewCell {
}
setupContact(
title: contact.nickname ?? contact.username!,
title: (contact.nickname ?? contact.username) ?? "",
photo: contact.photo,
phone: phone,
email: contact.email,
......@@ -165,7 +165,7 @@ final class RequestCell: UICollectionViewCell {
}
setupContact(
title: contact.nickname ?? contact.username!,
title: (contact.nickname ?? contact.username) ?? "",
photo: contact.photo,
phone: phone,
email: contact.email,
......
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