Fixed issues found during QA

Fixed a couple issues around temporary file paths not getting created correctly
Fixed an issue where PhotoLibrary exports could fail without notifying the user correctly
Fixed a couple of bugs with the emoji list
pull/946/head
Morgan Pretty 1 year ago
parent 790ef16b9a
commit 08365a610e

@ -2333,8 +2333,7 @@ extension ConversationVC:
let url: URL = URL(fileURLWithPath: directory).appendingPathComponent(fileName) let url: URL = URL(fileURLWithPath: directory).appendingPathComponent(fileName)
// Set up audio session // Set up audio session
let isConfigured = (Environment.shared?.audioSession.startAudioActivity(recordVoiceMessageActivity) == true) guard Environment.shared?.audioSession.startAudioActivity(recordVoiceMessageActivity) == true else {
guard isConfigured else {
return cancelVoiceMessageRecording() return cancelVoiceMessageRecording()
} }

@ -17,7 +17,6 @@ final class ReactionContainerView: UIView {
private static let maxEmojiBeforeCollapse: Int = 6 private static let maxEmojiBeforeCollapse: Int = 6
private var maxWidth: CGFloat = 0 private var maxWidth: CGFloat = 0
private var collapsedCount: Int = 0
private var showingAllReactions: Bool = false private var showingAllReactions: Bool = false
private var showNumbers: Bool = true private var showNumbers: Bool = true
private var oldSize: CGSize = .zero private var oldSize: CGSize = .zero
@ -27,8 +26,6 @@ final class ReactionContainerView: UIView {
// MARK: - UI // MARK: - UI
private var collapseTextLabelRightConstraint: NSLayoutConstraint?
private let dummyReactionButton: ReactionButton = ReactionButton( private let dummyReactionButton: ReactionButton = ReactionButton(
viewModel: ReactionViewModel( viewModel: ReactionViewModel(
emoji: EmojiWithSkinTones(baseEmoji: .a, skinTones: nil), emoji: EmojiWithSkinTones(baseEmoji: .a, skinTones: nil),
@ -64,6 +61,7 @@ final class ReactionContainerView: UIView {
.withRenderingMode(.alwaysTemplate) .withRenderingMode(.alwaysTemplate)
) )
arrow.themeTintColor = .textPrimary arrow.themeTintColor = .textPrimary
arrow.setContentHuggingPriority(.required, for: .horizontal)
let textLabel: UILabel = UILabel() let textLabel: UILabel = UILabel()
textLabel.setContentHuggingPriority(.required, for: .vertical) textLabel.setContentHuggingPriority(.required, for: .vertical)
@ -80,12 +78,11 @@ final class ReactionContainerView: UIView {
result.addSubview(textLabel) result.addSubview(textLabel)
arrow.pin(.top, to: .top, of: result) arrow.pin(.top, to: .top, of: result)
arrow.pin(.leading, to: .leading, of: result)
arrow.pin(.bottom, to: .bottom, of: result) arrow.pin(.bottom, to: .bottom, of: result)
textLabel.center(.horizontal, in: result, withInset: (ReactionContainerView.arrowSize.width / 2))
textLabel.pin(.top, to: .top, of: result) textLabel.pin(.top, to: .top, of: result)
textLabel.pin(.leading, to: .trailing, of: arrow, withInset: ReactionContainerView.arrowSpacing) textLabel.pin(.leading, to: .trailing, of: arrow, withInset: ReactionContainerView.arrowSpacing)
collapseTextLabelRightConstraint = textLabel.pin(.trailing, to: .trailing, of: result)
textLabel.pin(.bottom, to: .bottom, of: result) textLabel.pin(.bottom, to: .bottom, of: result)
return result return result
@ -114,37 +111,7 @@ final class ReactionContainerView: UIView {
mainStackView.pin(.trailing, to: .trailing, of: self) mainStackView.pin(.trailing, to: .trailing, of: self)
mainStackView.pin(.bottom, to: .bottom, of: self, withInset: -Values.verySmallSpacing) mainStackView.pin(.bottom, to: .bottom, of: self, withInset: -Values.verySmallSpacing)
reactionContainerView.set(.width, to: .width, of: mainStackView) reactionContainerView.set(.width, to: .width, of: mainStackView)
} collapseButton.set(.width, to: .width, of: mainStackView)
override func layoutSubviews() {
super.layoutSubviews()
// Note: We update the 'collapseTextLabelRightConstraint' to try to make the "show less"
// button appear horizontally centered (if we don't do this it gets offset to one side)
guard frame != CGRect.zero, frame.size != oldSize else { return }
let targetSuperview: UIView? = {
var result: UIView? = self.superview
while result != nil, result?.isKind(of: UITableViewCell.self) != true {
result = result?.superview
}
return result
}()
if let targetSuperview: UIView = targetSuperview {
let parentWidth: CGFloat = targetSuperview.bounds.width
let frameInParent: CGRect = targetSuperview.convert(self.bounds, from: self)
let centeredWidth: CGFloat = (parentWidth - (frameInParent.minX * 2))
let diff: CGFloat = (frameInParent.width - centeredWidth)
collapseTextLabelRightConstraint?.constant = -(
diff +
((ReactionContainerView.arrowSize.width + ReactionContainerView.arrowSpacing) / 2)
)
}
oldSize = frame.size
} }
public func update( public func update(
@ -155,7 +122,17 @@ final class ReactionContainerView: UIView {
) { ) {
self.reactions = reactions self.reactions = reactions
self.maxWidth = maxWidth self.maxWidth = maxWidth
self.collapsedCount = { self.showNumbers = showNumbers
self.reactionViews = []
self.reactionContainerView.arrangedSubviews.forEach { $0.removeFromSuperview() }
let collapsedCount: Int = {
// If there are already more than 'maxEmojiBeforeCollapse' then no need to calculate, just
// always collapse
guard reactions.count <= ReactionContainerView.maxEmojiBeforeCollapse else {
return ReactionContainerView.numCollapsedEmoji
}
var numReactions: Int = 0 var numReactions: Int = 0
var runningWidth: CGFloat = 0 var runningWidth: CGFloat = 0
let estimatedExpandingButtonWidth: CGFloat = 52 let estimatedExpandingButtonWidth: CGFloat = 52
@ -180,27 +157,21 @@ final class ReactionContainerView: UIView {
numReactions += 1 numReactions += 1
} }
return (numReactions > ReactionContainerView.maxEmojiBeforeCollapse ? return numReactions
ReactionContainerView.numCollapsedEmoji :
numReactions
)
}() }()
self.showNumbers = showNumbers
self.reactionViews = []
self.reactionContainerView.arrangedSubviews.forEach { $0.removeFromSuperview() }
// Generate the lines of reactions (if the 'collapsedCount' matches the total number of // Generate the lines of reactions (if the 'collapsedCount' matches the total number of
// reactions then just show them app) // reactions then just show them app)
if showingAllReactions || self.collapsedCount >= reactions.count { if showingAllReactions || collapsedCount >= reactions.count {
self.updateAllReactions(reactions, maxWidth: maxWidth, showNumbers: showNumbers) self.updateAllReactions(reactions, maxWidth: maxWidth, showNumbers: showNumbers)
} }
else { else {
self.updateCollapsedReactions(reactions, maxWidth: maxWidth, showNumbers: showNumbers) self.updateCollapsedReactions(reactions, maxWidth: maxWidth, showNumbers: showNumbers, collapsedCount: collapsedCount)
} }
// Just in case we couldn't show everything for some reason update this based on the // Just in case we couldn't show everything for some reason update this based on the
// internal logic // internal logic
self.collapseButton.isHidden = (self.reactionContainerView.arrangedSubviews.count <= 1) self.collapseButton.isHidden = !showingAllReactions
self.showingAllReactions = !self.collapseButton.isHidden self.showingAllReactions = !self.collapseButton.isHidden
self.layoutIfNeeded() self.layoutIfNeeded()
} }
@ -218,15 +189,16 @@ final class ReactionContainerView: UIView {
private func updateCollapsedReactions( private func updateCollapsedReactions(
_ reactions: [ReactionViewModel], _ reactions: [ReactionViewModel],
maxWidth: CGFloat, maxWidth: CGFloat,
showNumbers: Bool showNumbers: Bool,
collapsedCount: Int
) { ) {
guard !reactions.isEmpty else { return } guard !reactions.isEmpty else { return }
let maxSize: CGSize = CGSize(width: maxWidth, height: 9999) let maxSize: CGSize = CGSize(width: maxWidth, height: 9999)
let stackView: UIStackView = createLineStackView() let stackView: UIStackView = createLineStackView()
let displayedReactions: [ReactionViewModel] = Array(reactions.prefix(upTo: self.collapsedCount)) let displayedReactions: [ReactionViewModel] = Array(reactions.prefix(upTo: collapsedCount))
let expandButtonReactions: [EmojiWithSkinTones] = reactions let expandButtonReactions: [EmojiWithSkinTones] = reactions
.suffix(from: self.collapsedCount) .suffix(from: collapsedCount)
.prefix(3) .prefix(3)
.map { $0.emoji } .map { $0.emoji }

@ -191,10 +191,13 @@ class PhotoCollectionContents {
exportSession.outputURL = exportURL exportSession.outputURL = exportURL
Logger.debug("starting video export") Logger.debug("starting video export")
exportSession.exportAsynchronously { exportSession.exportAsynchronously { [weak exportSession] in
Logger.debug("Completed video export") Logger.debug("Completed video export")
guard let dataSource = DataSourcePath.dataSource(with: exportURL, shouldDeleteOnDeallocation: true) else { guard
exportSession?.status == .completed,
let dataSource = DataSourcePath.dataSource(with: exportURL, shouldDeleteOnDeallocation: true)
else {
resolver(Result.failure(PhotoLibraryError.assertionError(description: "Failed to build data source for exported video URL"))) resolver(Result.failure(PhotoLibraryError.assertionError(description: "Failed to build data source for exported video URL")))
return return
} }

@ -207,7 +207,7 @@ final class MainAppContext: AppContext {
// //
// a) "ows_temp" name prefix. // a) "ows_temp" name prefix.
// b) modified time before app launch time. // b) modified time before app launch time.
let filePath: String = URL(fileURLWithPath: dirPath).appendingPathComponent(fileName).absoluteString let filePath: String = URL(fileURLWithPath: dirPath).appendingPathComponent(fileName).path
if !fileName.hasPrefix("ows_temp") { if !fileName.hasPrefix("ows_temp") {
// It's fine if we can't get the attributes (the file may have been deleted since we found it), // It's fine if we can't get the attributes (the file may have been deleted since we found it),

@ -60,8 +60,9 @@ public extension AppContext {
let dirName: String = "ows_temp_\(UUID().uuidString)" let dirName: String = "ows_temp_\(UUID().uuidString)"
let dirPath: String = URL(fileURLWithPath: NSTemporaryDirectory()) let dirPath: String = URL(fileURLWithPath: NSTemporaryDirectory())
.appendingPathComponent(dirName) .appendingPathComponent(dirName)
.absoluteString .path
_temporaryDirectory = dirPath _temporaryDirectory = dirPath
OWSFileSystem.ensureDirectoryExists(dirPath, fileProtectionType: .complete)
return dirPath return dirPath
} }

Loading…
Cancel
Save