From 29cd6fb312db1e52195b40febb01a301dcd89882 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 6 Jan 2022 10:08:59 +1100 Subject: [PATCH] fix minor issues --- Session/Calls/Views & Modals/IncomingCallBanner.swift | 2 +- .../Conversations/Message Cells/VisibleMessageCell.swift | 7 +++---- Session/Open Groups/JoinOpenGroupVC.swift | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Session/Calls/Views & Modals/IncomingCallBanner.swift b/Session/Calls/Views & Modals/IncomingCallBanner.swift index 9ba23cf3f..a4854f648 100644 --- a/Session/Calls/Views & Modals/IncomingCallBanner.swift +++ b/Session/Calls/Views & Modals/IncomingCallBanner.swift @@ -167,7 +167,7 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate { self.alpha = 0.0 let window = CurrentAppContext().mainWindow! window.addSubview(self) - let topMargin = UIApplication.shared.keyWindow!.safeAreaInsets.top - Values.smallSpacing + let topMargin = window.safeAreaInsets.top - Values.smallSpacing self.autoPinWidthToSuperview(withMargin: Values.smallSpacing) self.autoPinEdge(toSuperviewEdge: .top, withInset: topMargin) UIView.animate(withDuration: 0.5, delay: 0, options: [], animations: { diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index 0d39cc9f1..6308e1aab 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -207,8 +207,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { // MARK: Updating override func update() { guard let viewItem = viewItem, let message = viewItem.interaction as? TSMessage else { return } - let thread = message.thread - let isGroupThread = thread.isGroupThread() + let isGroupThread = viewItem.isGroupThread // Profile picture view profilePictureViewLeftConstraint.constant = isGroupThread ? VisibleMessageCell.groupThreadHSpacing : 0 profilePictureViewWidthConstraint.constant = isGroupThread ? VisibleMessageCell.profilePictureSize : 0 @@ -217,8 +216,8 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { if let senderSessionID = senderSessionID { profilePictureView.update(for: senderSessionID) } - if let thread = thread as? TSGroupThread, thread.isOpenGroup, let senderSessionID = senderSessionID { - if let openGroupV2 = Storage.shared.getV2OpenGroup(for: thread.uniqueId!) { + if let senderSessionID = senderSessionID, message.isOpenGroupMessage { + if let openGroupV2 = Storage.shared.getV2OpenGroup(for: message.uniqueThreadId) { let isUserModerator = OpenGroupAPIV2.isUserModerator(senderSessionID, for: openGroupV2.room, on: openGroupV2.server) moderatorIconImageView.isHidden = !isUserModerator || profilePictureView.isHidden } else { diff --git a/Session/Open Groups/JoinOpenGroupVC.swift b/Session/Open Groups/JoinOpenGroupVC.swift index b1587be54..debad90e2 100644 --- a/Session/Open Groups/JoinOpenGroupVC.swift +++ b/Session/Open Groups/JoinOpenGroupVC.swift @@ -143,7 +143,7 @@ final class JoinOpenGroupVC : BaseVC, UIPageViewControllerDataSource, UIPageView Storage.shared.write { transaction in OpenGroupManagerV2.shared.add(room: room, server: server, publicKey: publicKey, using: transaction) .done(on: DispatchQueue.main) { [weak self] _ in - self?.presentingViewController!.dismiss(animated: true, completion: nil) + self?.presentingViewController?.dismiss(animated: true, completion: nil) let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.forceSyncConfigurationNowIfNeeded().retainUntilComplete() // FIXME: It's probably cleaner to do this inside addOpenGroup(...) }