Merge branch 'mlin/PR/CVCPerf_PeekAndPop' into release/5.1.0

This commit is contained in:
Michelle Linington 2020-12-16 13:45:54 -08:00
commit 887879749e
5 changed files with 25 additions and 54 deletions

View File

@ -29,6 +29,10 @@ public extension ConversationViewController {
owsAssertDebug(hasViewWillAppearEverBegun)
if viewState.bottomViewType != newValue {
if viewState.bottomViewType == .inputToolbar {
// Dismiss the keyboard if we're swapping out the input toolbar
dismissKeyBoard()
}
viewState.bottomViewType = newValue
updateBottomBar()
}
@ -62,7 +66,11 @@ public extension ConversationViewController {
case .selection:
return .selection
case .normal:
return .inputToolbar
if viewState.isInPreviewPlatter || userLeftGroup {
return .none
} else {
return .inputToolbar
}
}
}
}()
@ -127,7 +135,6 @@ public extension ConversationViewController {
updateInputAccessoryPlaceholderHeight()
updateBottomBarPosition()
updateContentInsets(animated: hasAppearedAndHasAppliedFirstLoad)
updateInputVisibility()
}
// This is expensive. We only need to do it if conversationStyle has changed.
@ -224,33 +231,6 @@ public extension ConversationViewController {
ensureBottomViewType()
}
@objc
func updateInputVisibility() {
AssertIsOnMainThread()
guard hasViewWillAppearEverBegun else {
return
}
guard let inputToolbar = inputToolbar else {
owsFailDebug("Missing inputToolbar.")
return
}
if viewState.isInPreviewPlatter {
inputToolbar.isHidden = true
dismissKeyBoard()
return
}
if self.userLeftGroup {
// user has requested they leave the group. further sends disallowed
inputToolbar.isHidden = true
dismissKeyBoard()
} else {
inputToolbar.isHidden = false
}
}
@objc
func updateInputToolbarLayout() {
AssertIsOnMainThread()

View File

@ -626,14 +626,19 @@ extension ConversationViewController: CVLoadCoordinatorDelegate {
guard self.conversationStyle.type != .`default` else {
// Once we built a normal style, never go back to
// building an initial or placeholder style.
owsAssertDebug(navigationController != nil)
owsAssertDebug(navigationController != nil || viewState.isInPreviewPlatter)
return buildDefaultConversationStyle(type: .`default`)
}
guard let navigationController = navigationController else {
// Treat all styles as "initial" (not to be trusted) until
// we have a navigationController.
return buildDefaultConversationStyle(type: .initial)
if viewState.isInPreviewPlatter {
// In a preview platter, we'll never have a navigation controller
return buildDefaultConversationStyle(type: .`default`)
} else {
// Treat all styles as "initial" (not to be trusted) until
// we have a navigationController.
return buildDefaultConversationStyle(type: .initial)
}
}
let collectionViewWidth = self.collectionView.width
@ -649,12 +654,6 @@ extension ConversationViewController: CVLoadCoordinatorDelegate {
let hasValidStyle = !isMissingSafeAreaInsets && !hasInvalidWidth
if hasValidStyle {
// No need to rewrite style; style is already valid.
//
// Verify that navigationController view and CVC view
// state converge.
owsAssertDebug(navigationViewWidth == rootViewWidth)
owsAssertDebug(navigationViewWidth == collectionViewWidth)
return buildDefaultConversationStyle(type: .`default`)
} else {
let viewAge = abs(self.viewState.viewCreationDate.timeIntervalSinceNow)

View File

@ -55,7 +55,6 @@ typedef NS_ENUM(NSUInteger, ConversationViewAction) {
#pragma mark 3D Touch Methods
- (void)peekSetup;
- (void)popped;
#pragma mark - Keyboard Shortcuts

View File

@ -357,6 +357,10 @@ typedef enum : NSUInteger {
{
if (self.viewState.isInPreviewPlatter != inPreviewPlatter) {
self.viewState.isInPreviewPlatter = inPreviewPlatter;
if (self.hasViewWillAppearEverBegun) {
[self ensureBottomViewType];
}
[self configureScrollDownButtons];
}
}
@ -367,12 +371,6 @@ typedef enum : NSUInteger {
self.actionOnOpen = ConversationViewActionNone;
}
- (void)popped
{
[self setInPreviewPlatter:NO];
[self updateInputVisibility];
}
- (void)updateV2GroupIfNecessary
{
if (!self.thread.isGroupV2Thread) {
@ -423,7 +421,8 @@ typedef enum : NSUInteger {
- (void)viewDidLoad
{
OWSAssertDebug(self.navigationController != nil);
// We won't have a navigation controller if we're presented in a preview
OWSAssertDebug(self.navigationController != nil || self.isInPreviewPlatter);
#ifdef TESTABLE_BUILD
[self.initialLoadBenchSteps step:@"viewDidLoad.1"];
@ -632,10 +631,6 @@ typedef enum : NSUInteger {
[self createGestureRecognizers];
}
// We need to recheck on every appearance, since the user may have left the group in the settings VC,
// or on another device.
[self updateInputVisibility];
self.isViewVisible = YES;
[self viewWillAppearForLoad];

View File

@ -811,9 +811,7 @@ NSString *const kArchiveButtonPseudoGroup = @"kArchiveButtonPseudoGroup";
commitViewController:(UIViewController *)viewControllerToCommit
{
ConversationViewController *vc = (ConversationViewController *)viewControllerToCommit;
[vc popped];
[self.navigationController pushViewController:vc animated:NO];
[self presentThread:vc.thread action:ConversationViewActionNone animated:NO];
}
- (void)showNewConversationView