Made a few small bug fixes & improvements

Updated the conversation empty state to appear in all conversation types
Recreating the interaction FTS table if it doesn't exist (somehow was removed from some of my DBs...)
Fixed a couple of incorrect swipe action colours
Fixed a few issues causing unneeded conversation cell layouts which could impact performance
Fixed a bug where the in-conversation search loading indicator wouldn't disappear when pressing the clear button
pull/856/head
Morgan Pretty 2 years ago
parent d463a459a2
commit a6699f0c58

@ -258,7 +258,7 @@ final class EditClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegat
let delete: UIContextualAction = UIContextualAction(
title: "GROUP_ACTION_REMOVE".localized(),
icon: UIImage(named: "icon_bin"),
themeTintColor: .textPrimary,
themeTintColor: .white,
themeBackgroundColor: .conversationButton_swipeDestructive,
side: .trailing,
actionIndex: 0,

@ -317,6 +317,7 @@ public final class SearchResultsBar: UIView {
label.text = ""
downButton.isEnabled = false
upButton.isEnabled = false
stopLoading()
return
}

@ -162,6 +162,8 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
result.register(view: InfoMessageCell.self)
result.register(view: TypingIndicatorCell.self)
result.register(view: CallMessageCell.self)
result.estimatedSectionHeaderHeight = ConversationVC.loadingHeaderHeight
result.sectionFooterHeight = 0
result.dataSource = self
result.delegate = self
@ -209,7 +211,7 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
private lazy var emptyStateLabel: UILabel = {
let text: String = String(
format: "GROUP_CONVERSATION_EMPTY_STATE".localized(),
format: "CONVERSATION_EMPTY_STATE".localized(),
self.viewModel.threadData.displayName
)
@ -228,10 +230,6 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
result.textAlignment = .center
result.lineBreakMode = .byWordWrapping
result.numberOfLines = 0
result.isHidden = (
self.viewModel.threadData.threadVariant != .legacyGroup &&
self.viewModel.threadData.threadVariant != .group
)
return result
}()
@ -401,8 +399,8 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
view.addSubview(messageRequestStackView)
emptyStateLabel.pin(.top, to: .top, of: view, withInset: Values.largeSpacing)
emptyStateLabel.pin(.leading, to: .leading, of: view, withInset: Values.largeSpacing)
emptyStateLabel.pin(.trailing, to: .trailing, of: view, withInset: -Values.largeSpacing)
emptyStateLabel.pin(.leading, to: .leading, of: view, withInset: Values.veryLargeSpacing)
emptyStateLabel.pin(.trailing, to: .trailing, of: view, withInset: -Values.veryLargeSpacing)
messageRequestStackView.addArrangedSubview(messageRequestBlockButton)
messageRequestStackView.addArrangedSubview(messageRequestDescriptionContainerView)
@ -620,7 +618,9 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
// PagedDatabaseObserver won't have them so we need to force a re-fetch of the current
// data to ensure everything is up to date
if didReturnFromBackground {
self?.viewModel.pagedDataObserver?.reload()
DispatchQueue.global(qos: .background).async {
self?.viewModel.pagedDataObserver?.reload()
}
}
}
}
@ -674,7 +674,7 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
// Update the empty state
let text: String = String(
format: "GROUP_CONVERSATION_EMPTY_STATE".localized(),
format: "CONVERSATION_EMPTY_STATE".localized(),
updatedThreadData.displayName
)
emptyStateLabel.attributedText = NSAttributedString(string: text)
@ -775,6 +775,13 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
changeset: StagedChangeset<[ConversationViewModel.SectionModel]>,
initialLoad: Bool = false
) {
// Determine if we have any messages for the empty state
let hasMessages: Bool = (updatedData
.filter { $0.model == .messages }
.first?
.elements
.isEmpty == false)
// Ensure the first load or a load when returning from a child screen runs without
// animations (if we don't do this the cells will animate in from a frame of
// CGRect.zero or have a buggy transition)
@ -785,17 +792,7 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
self.viewModel.updateInteractionData(updatedData)
// Update the empty state
let hasMessages: Bool = (updatedData
.filter { $0.model == .messages }
.first?
.elements
.isEmpty == false)
self.emptyStateLabel.isHidden = (
hasMessages || (
self.viewModel.threadData.threadVariant != .legacyGroup &&
self.viewModel.threadData.threadVariant != .group
)
)
self.emptyStateLabel.isHidden = hasMessages
UIView.performWithoutAnimation {
self.tableView.reloadData()
@ -806,12 +803,7 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
}
// Update the empty state
self.emptyStateLabel.isHidden = (
!updatedData.isEmpty || (
self.viewModel.threadData.threadVariant != .legacyGroup &&
self.viewModel.threadData.threadVariant != .group
)
)
self.emptyStateLabel.isHidden = hasMessages
// Update the ReactionListSheet (if one exists)
if let messageUpdates: [MessageViewModel] = updatedData.first(where: { $0.model == .messages })?.elements {
@ -1428,14 +1420,6 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
}
// MARK: - UITableViewDelegate
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
let section: ConversationViewModel.SectionModel = viewModel.interactionData[section]
@ -1507,15 +1491,6 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
return
}
// Note: In this case we need to force a tableView layout to ensure updating the
// scroll position has the correct offset (otherwise there are some cases where
// the screen will jump up - eg. when sending a reply while the soft keyboard
// is visible)
UIView.performWithoutAnimation {
self.tableView.setNeedsLayout()
self.tableView.layoutIfNeeded()
}
let targetIndexPath: IndexPath = IndexPath(
row: (self.viewModel.interactionData[messagesSectionIndex].elements.count - 1),
section: messagesSectionIndex
@ -1762,12 +1737,6 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl
return
}
// Note: If the tableView needs to layout then we should do it first without an animation
// to prevent an annoying issue where the screen jumps slightly after the scroll completes
UIView.performWithoutAnimation {
self.tableView.layoutIfNeeded()
}
let targetIndexPath: IndexPath = IndexPath(
row: targetMessageIndex,
section: messageSectionIndex

@ -408,7 +408,7 @@ class MessageRequestsViewController: BaseVC, UITableViewDelegate, UITableViewDat
let delete: UIContextualAction = UIContextualAction(
title: "TXT_DELETE_TITLE".localized(),
icon: UIImage(named: "icon_bin"),
themeTintColor: .textPrimary,
themeTintColor: .white,
themeBackgroundColor: .conversationButton_swipeDestructive,
side: .trailing,
actionIndex: (threadVariant == .contact ? 1 : 0),
@ -428,8 +428,8 @@ class MessageRequestsViewController: BaseVC, UITableViewDelegate, UITableViewDat
let block: UIContextualAction = UIContextualAction(
title: "BLOCK_LIST_BLOCK_BUTTON".localized(),
icon: UIImage(named: "table_ic_block"),
themeTintColor: .textPrimary,
themeBackgroundColor: .conversationButton_swipeDestructive,
themeTintColor: .white,
themeBackgroundColor: .conversationButton_swipeSecondary,
side: .trailing,
actionIndex: 0,
indexPath: indexPath,

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -613,5 +613,5 @@
"CONTACT_NICKNAME_PLACEHOLDER" = "Enter a name";
"MARK_AS_READ" = "Mark Read";
"MARK_AS_UNREAD" = "Mark Unread";
"GROUP_CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"CONVERSATION_EMPTY_STATE" = "You have no messages from %@. Send a message to start the conversation!";
"USER_CONFIG_OUTDATED_WARNING" = "Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.";

@ -160,6 +160,18 @@ enum _012_SessionUtilChanges: Migration {
SessionThread.Columns.pinnedPriority.set(to: 1)
)
// There seems to have been an issue where the interaction FTS table might have been dropped
// so if it has we should recreate it
if try db.tableExists(Interaction.fullTextSearchTableName) == false {
try db.create(virtualTable: Interaction.fullTextSearchTableName, using: FTS5()) { t in
t.synchronize(withTable: Interaction.databaseTableName)
t.tokenizer = _001_InitialSetupMigration.fullTextSearchTokenizer
t.column(Interaction.Columns.body.name)
t.column(Interaction.Columns.threadId.name)
}
}
// If we don't have an ed25519 key then no need to create cached dump data
let userPublicKey: String = getUserHexEncodedPublicKey(db)

Loading…
Cancel
Save