From 73f07de338df3a1861ca4ad533cefa595c3e0b28 Mon Sep 17 00:00:00 2001 From: Ryan Nystrom Date: Sat, 2 Dec 2017 16:14:14 -0500 Subject: [PATCH] prevent slack cache from overwriting text (#1129) --- Classes/Views/TextActionsController.swift | 2 +- .../SlackTextViewController/Source/SLKTextViewController.m | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Classes/Views/TextActionsController.swift b/Classes/Views/TextActionsController.swift index 84f9c4b3..d0f97f74 100644 --- a/Classes/Views/TextActionsController.swift +++ b/Classes/Views/TextActionsController.swift @@ -74,7 +74,7 @@ final class TextActionsController: NSObject, // MARK: ImageUploadDelegate func imageUploaded(link: String, altText: String) { - textView?.replace(left: "![\(altText)](\(link))", right: nil, atLineStart: true) + textView?.replace(left: "![\(altText)](\(link))", right: nil, atLineStart: false) } } diff --git a/Local Pods/SlackTextViewController/Source/SLKTextViewController.m b/Local Pods/SlackTextViewController/Source/SLKTextViewController.m index 501742d0..3882283e 100755 --- a/Local Pods/SlackTextViewController/Source/SLKTextViewController.m +++ b/Local Pods/SlackTextViewController/Source/SLKTextViewController.m @@ -1904,8 +1904,9 @@ CGFloat const SLKAutoCompletionViewDefaultHeight = 140.0; cachedAttributedText = [NSKeyedUnarchiver unarchiveObjectWithData:obj]; } } - - if (self.textView.attributedText.length == 0 || cachedAttributedText.length > 0) { + + // only update the text if it is empty on the first load + if (self.textView.attributedText.length == 0 && cachedAttributedText.length > 0) { self.textView.attributedText = cachedAttributedText; } }