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 { guard self.hasLoadedInitialInteractionData else {
// Need to dispatch async to prevent this from causing glitches in the push animation // Need to dispatch async to prevent this from causing glitches in the push animation
DispatchQueue.main.async { DispatchQueue.main.async {
self.hasLoadedInitialInteractionData = true
self.viewModel.updateInteractionData(updatedData) self.viewModel.updateInteractionData(updatedData)
// Update the empty state // Update the empty state
@ -911,6 +910,7 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers
UIView.performWithoutAnimation { UIView.performWithoutAnimation {
self.tableView.reloadData() self.tableView.reloadData()
self.hasLoadedInitialInteractionData = true
self.performInitialScrollIfNeeded() self.performInitialScrollIfNeeded()
} }
} }
@ -1218,7 +1218,11 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers
} }
private func autoLoadNextPageIfNeeded() { private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage && !self.isLoadingMore else { return } guard
self.hasLoadedInitialInteractionData &&
!self.isAutoLoadingNextPage &&
!self.isLoadingMore
else { return }
self.isAutoLoadingNextPage = true 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 // Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero) // in from a frame of CGRect.zero)
guard hasLoadedInitialThreadData else { guard hasLoadedInitialThreadData else {
hasLoadedInitialThreadData = true
UIView.performWithoutAnimation { [weak self] in UIView.performWithoutAnimation { [weak self] in
// Hide the 'loading conversations' label (now that we have received conversation data) // Hide the 'loading conversations' label (now that we have received conversation data)
self?.loadingConversationsLabel.isHidden = true self?.loadingConversationsLabel.isHidden = true
@ -422,6 +420,8 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData
) )
self?.viewModel.updateThreadData(updatedData) self?.viewModel.updateThreadData(updatedData)
self?.tableView.reloadData()
self?.hasLoadedInitialThreadData = true
} }
return return
} }
@ -460,7 +460,11 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData
} }
private func autoLoadNextPageIfNeeded() { private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage && !self.isLoadingMore else { return } guard
self.hasLoadedInitialThreadData &&
!self.isAutoLoadingNextPage &&
!self.isLoadingMore
else { return }
self.isAutoLoadingNextPage = true 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 // Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero) // in from a frame of CGRect.zero)
guard hasLoadedInitialThreadData else { guard hasLoadedInitialThreadData else {
hasLoadedInitialThreadData = true
UIView.performWithoutAnimation { 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 return
} }
@ -271,7 +280,11 @@ class MessageRequestsViewController: BaseVC, SessionUtilRespondingViewController
} }
private func autoLoadNextPageIfNeeded() { private func autoLoadNextPageIfNeeded() {
guard !self.isAutoLoadingNextPage && !self.isLoadingMore else { return } guard
self.hasLoadedInitialThreadData &&
!self.isAutoLoadingNextPage &&
!self.isLoadingMore
else { return }
self.isAutoLoadingNextPage = true self.isAutoLoadingNextPage = true

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

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

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

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

Loading…
Cancel
Save