Merge branch 'updated-user-config-handling' into disappearing-message-redesign

pull/941/head
Ryan Zhao 2 years ago
commit defd7e3cfe

@ -903,7 +903,6 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers
guard self.hasLoadedInitialInteractionData else {
// Need to dispatch async to prevent this from causing glitches in the push animation
DispatchQueue.main.async {
self.hasLoadedInitialInteractionData = true
self.viewModel.updateInteractionData(updatedData)
// Update the empty state
@ -911,6 +910,7 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers
UIView.performWithoutAnimation {
self.tableView.reloadData()
self.hasLoadedInitialInteractionData = true
self.performInitialScrollIfNeeded()
}
}
@ -1218,7 +1218,11 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers
}
private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage && !self.isLoadingMore else { return }
guard
self.hasLoadedInitialInteractionData &&
!self.isAutoLoadingNextPage &&
!self.isLoadingMore
else { return }
self.isAutoLoadingNextPage = true

@ -409,8 +409,6 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData
// Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero)
guard hasLoadedInitialThreadData else {
hasLoadedInitialThreadData = true
UIView.performWithoutAnimation { [weak self] in
// Hide the 'loading conversations' label (now that we have received conversation data)
self?.loadingConversationsLabel.isHidden = true
@ -422,6 +420,8 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData
)
self?.viewModel.updateThreadData(updatedData)
self?.tableView.reloadData()
self?.hasLoadedInitialThreadData = true
}
return
}
@ -460,7 +460,11 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData
}
private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage && !self.isLoadingMore else { return }
guard
self.hasLoadedInitialThreadData &&
!self.isAutoLoadingNextPage &&
!self.isLoadingMore
else { return }
self.isAutoLoadingNextPage = true

@ -232,9 +232,18 @@ class MessageRequestsViewController: BaseVC, SessionUtilRespondingViewController
// Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero)
guard hasLoadedInitialThreadData else {
hasLoadedInitialThreadData = true
UIView.performWithoutAnimation {
handleThreadUpdates(updatedData, changeset: changeset, initialLoad: true)
// Hide the 'loading conversations' label (now that we have received conversation data)
loadingConversationsLabel.isHidden = true
// Show the empty state if there is no data
clearAllButton.isHidden = !(updatedData.first?.elements.isEmpty == false)
emptyStateLabel.isHidden = !clearAllButton.isHidden
// Update the content
viewModel.updateThreadData(updatedData)
tableView.reloadData()
hasLoadedInitialThreadData = true
}
return
}
@ -271,7 +280,11 @@ class MessageRequestsViewController: BaseVC, SessionUtilRespondingViewController
}
private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage && !self.isLoadingMore else { return }
guard
self.hasLoadedInitialThreadData &&
!self.isAutoLoadingNextPage &&
!self.isLoadingMore
else { return }
self.isAutoLoadingNextPage = true

@ -153,7 +153,7 @@ public class DocumentTileViewController: UIViewController, UITableViewDelegate,
}
private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage else { return }
guard self.hasLoadedInitialData && !self.isAutoLoadingNextPage else { return }
self.isAutoLoadingNextPage = true
@ -204,11 +204,11 @@ public class DocumentTileViewController: UIViewController, UITableViewDelegate,
// Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero)
guard hasLoadedInitialData else {
self.hasLoadedInitialData = true
self.viewModel.updateGalleryData(updatedGalleryData)
UIView.performWithoutAnimation {
self.tableView.reloadData()
self.hasLoadedInitialData = true
self.performInitialScrollIfNeeded()
}
return

@ -246,7 +246,7 @@ public class MediaTileViewController: UIViewController, UICollectionViewDataSour
}
private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage else { return }
guard self.hasLoadedInitialData && !self.isAutoLoadingNextPage else { return }
self.isAutoLoadingNextPage = true
@ -307,12 +307,12 @@ public class MediaTileViewController: UIViewController, UICollectionViewDataSour
// Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero)
guard hasLoadedInitialData else {
self.hasLoadedInitialData = true
self.viewModel.updateGalleryData(updatedGalleryData)
self.updateSelectButton(updatedData: updatedGalleryData, inBatchSelectMode: isInBatchSelectMode)
UIView.performWithoutAnimation {
self.collectionView.reloadData()
self.hasLoadedInitialData = true
self.performInitialScrollIfNeeded()
}
return

@ -224,21 +224,28 @@ class SessionTableViewController<NavItemId: Equatable, Section: SessionTableSect
changeset: StagedChangeset<[SectionModel]>,
initialLoad: Bool = false
) {
// Determine if we have any items for the empty state
let itemCount: Int = updatedData
.map { $0.elements.count }
.reduce(0, +)
// Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero)
guard hasLoadedInitialTableData else {
hasLoadedInitialTableData = true
UIView.performWithoutAnimation {
handleDataUpdates(updatedData, changeset: changeset, initialLoad: true)
// Update the empty state
emptyStateLabel.isHidden = (itemCount > 0)
// Update the content
viewModel.updateTableData(updatedData)
tableView.reloadData()
hasLoadedInitialTableData = true
}
return
}
// Show the empty state if there is no data
let itemCount: Int = updatedData
.map { $0.elements.count }
.reduce(0, +)
emptyStateLabel.isHidden = (itemCount > 0)
// Update the empty state
self.emptyStateLabel.isHidden = (itemCount > 0)
CATransaction.begin()
CATransaction.setCompletionBlock { [weak self] in
@ -265,7 +272,11 @@ class SessionTableViewController<NavItemId: Equatable, Section: SessionTableSect
}
private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage && !self.isLoadingMore else { return }
guard
self.hasLoadedInitialTableData &&
!self.isAutoLoadingNextPage &&
!self.isLoadingMore
else { return }
self.isAutoLoadingNextPage = true

@ -5,6 +5,9 @@ import GRDB
import Quick
import Nimble
import SessionUIKit
import SessionSnodeKit
@testable import Session
class NotificationContentViewModelSpec: QuickSpec {

Loading…
Cancel
Save