Skip to content

Commit db96084

Browse files
authored
Offline Mode: Remove Deprecated Code – P13 (#23359)
2 parents 1784550 + c82cffc commit db96084

19 files changed

+9
-225
lines changed

WordPress/Classes/Services/Stories/StoryEditor.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,6 @@ class StoryEditor: CameraController {
211211
}
212212

213213
extension StoryEditor: PublishingEditor {
214-
var prepublishingSourceView: UIView? {
215-
return nil
216-
}
217-
218214
var alertBarButtonItem: UIBarButtonItem? {
219215
return nil
220216
}

WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,15 +1228,6 @@ extension AztecPostViewController: PostEditorStateContextDelegate {
12281228
}
12291229

12301230
switch keyPath {
1231-
case BasePost.statusKeyPath:
1232-
if let status = post.status {
1233-
postEditorStateContext.updated(postStatus: status)
1234-
editorContentWasUpdated()
1235-
}
1236-
case #keyPath(AbstractPost.date_created_gmt):
1237-
let dateCreated = post.dateCreated ?? Date()
1238-
postEditorStateContext.updated(publishDate: dateCreated)
1239-
editorContentWasUpdated()
12401231
case #keyPath(AbstractPost.content):
12411232
editorContentWasUpdated()
12421233
default:
@@ -1253,14 +1244,10 @@ extension AztecPostViewController: PostEditorStateContextDelegate {
12531244
}
12541245

12551246
internal func addObservers(toPost: AbstractPost) {
1256-
toPost.addObserver(self, forKeyPath: AbstractPost.statusKeyPath, options: [], context: nil)
1257-
toPost.addObserver(self, forKeyPath: #keyPath(AbstractPost.date_created_gmt), options: [], context: nil)
12581247
toPost.addObserver(self, forKeyPath: #keyPath(AbstractPost.content), options: [], context: nil)
12591248
}
12601249

12611250
internal func removeObservers(fromPost: AbstractPost) {
1262-
fromPost.removeObserver(self, forKeyPath: AbstractPost.statusKeyPath)
1263-
fromPost.removeObserver(self, forKeyPath: #keyPath(AbstractPost.date_created_gmt))
12641251
fromPost.removeObserver(self, forKeyPath: #keyPath(AbstractPost.content))
12651252
}
12661253
}
@@ -2506,21 +2493,6 @@ extension AztecPostViewController {
25062493
return failedIDs
25072494
}
25082495

2509-
var hasFailedMedia: Bool {
2510-
return !failedMediaIDs.isEmpty
2511-
}
2512-
2513-
func removeFailedMedia() {
2514-
for mediaID in failedMediaIDs {
2515-
if let attachment = self.findAttachment(withUploadID: mediaID) {
2516-
richTextView.remove(attachmentID: attachment.identifier)
2517-
}
2518-
if let media = mediaCoordinator.media(withObjectID: mediaID) {
2519-
mediaCoordinator.delete(media)
2520-
}
2521-
}
2522-
}
2523-
25242496
fileprivate func retryAllFailedMediaUploads() {
25252497
for mediaID in failedMediaIDs {
25262498
guard let attachment = self.findAttachment(withUploadID: mediaID),

WordPress/Classes/ViewRelated/Gutenberg/GutenbergMediaInserterHelper.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ class GutenbergMediaInserterHelper: NSObject {
125125
_ = mediaCoordinator.uploadMedia(for: post, automatedRetry: automatedRetry)
126126
}
127127

128-
func hasFailedMedia() -> Bool {
129-
return mediaCoordinator.hasFailedMedia(for: post)
130-
}
131-
132128
func insert(exportableAsset: ExportableAsset, source: MediaSource) -> Media? {
133129
let info = MediaAnalyticsInfo(origin: .editor(source), selectionMethod: mediaSelectionMethod)
134130
return mediaCoordinator.addMedia(from: exportableAsset, to: self.post, analyticsInfo: info)

WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
100100
return mediaInserterHelper.isUploadingMedia()
101101
}
102102

103-
var hasFailedMedia: Bool {
104-
return mediaInserterHelper.hasFailedMedia()
105-
}
106-
107103
func cancelUploadOfAllMedia(for post: AbstractPost) {
108104
return mediaInserterHelper.cancelUploadOfAllMedia()
109105
}
@@ -190,8 +186,6 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
190186

191187
var post: AbstractPost {
192188
didSet {
193-
removeObservers(fromPost: oldValue)
194-
addObservers(toPost: post)
195189
postEditorStateContext = PostEditorStateContext(post: post, delegate: self)
196190
attachmentDelegate = AztecAttachmentDelegate(post: post)
197191
mediaPickerHelper = GutenbergMediaPickerHelper(context: self, post: post)
@@ -311,8 +305,6 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
311305

312306
super.init(nibName: nil, bundle: nil)
313307

314-
addObservers(toPost: post)
315-
316308
self.navigationBarManager.delegate = self
317309
disableSocialConnectionsIfNecessary()
318310
}
@@ -323,7 +315,6 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
323315

324316
deinit {
325317
tearDownKeyboardObservers()
326-
removeObservers(fromPost: post)
327318
gutenberg.invalidate()
328319
attachmentDelegate.cancelAllPendingMediaRequests()
329320
}
@@ -1228,24 +1219,6 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
12281219
// MARK: - PostEditorStateContextDelegate
12291220

12301221
extension GutenbergViewController: PostEditorStateContextDelegate {
1231-
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
1232-
guard let keyPath = keyPath else {
1233-
return
1234-
}
1235-
1236-
switch keyPath {
1237-
case BasePost.statusKeyPath:
1238-
if let status = post.status {
1239-
postEditorStateContext.updated(postStatus: status)
1240-
}
1241-
case #keyPath(AbstractPost.date_created_gmt):
1242-
let dateCreated = post.dateCreated ?? Date()
1243-
postEditorStateContext.updated(publishDate: dateCreated)
1244-
default:
1245-
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
1246-
}
1247-
}
1248-
12491222
func context(_ context: PostEditorStateContext, didChangeAction: PostEditorAction) {
12501223
reloadPublishButton()
12511224
}
@@ -1257,16 +1230,6 @@ extension GutenbergViewController: PostEditorStateContextDelegate {
12571230
func reloadPublishButton() {
12581231
navigationBarManager.reloadPublishButton()
12591232
}
1260-
1261-
internal func addObservers(toPost: AbstractPost) {
1262-
toPost.addObserver(self, forKeyPath: AbstractPost.statusKeyPath, options: [], context: nil)
1263-
toPost.addObserver(self, forKeyPath: #keyPath(AbstractPost.date_created_gmt), options: [], context: nil)
1264-
}
1265-
1266-
internal func removeObservers(fromPost: AbstractPost) {
1267-
fromPost.removeObserver(self, forKeyPath: AbstractPost.statusKeyPath)
1268-
fromPost.removeObserver(self, forKeyPath: #keyPath(AbstractPost.date_created_gmt))
1269-
}
12701233
}
12711234

12721235
// MARK: - PostEditorNavigationBarManagerDelegate

WordPress/Classes/ViewRelated/Post/PostCardStatusViewModel.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ class PostCardStatusViewModel: NSObject, AbstractPostMenuViewModel {
77

88
let post: Post
99

10-
private let isInternetReachable: Bool
1110
private let isJetpackFeaturesEnabled: Bool
1211
private let isBlazeFlagEnabled: Bool
1312

1413
init(post: Post,
15-
isInternetReachable: Bool = ReachabilityUtils.isInternetReachable(),
1614
isJetpackFeaturesEnabled: Bool = JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled(),
1715
isBlazeFlagEnabled: Bool = BlazeHelper.isBlazeFlagEnabled()) {
1816
self.post = post
19-
self.isInternetReachable = isInternetReachable
2017
self.isJetpackFeaturesEnabled = isJetpackFeaturesEnabled
2118
self.isBlazeFlagEnabled = isBlazeFlagEnabled
2219
super.init()

WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ protocol PublishingEditor where Self: UIViewController {
2222
/// Title of the post
2323
var postTitle: String { get set }
2424

25-
var prepublishingSourceView: UIView? { get }
26-
2725
var alertBarButtonItem: UIBarButtonItem? { get }
2826

2927
/// Closure to be executed when the editor gets closed.
@@ -38,8 +36,6 @@ protocol PublishingEditor where Self: UIViewController {
3836
/// When the Prepublishing sheet or Prepublishing alert is dismissed, this is called.
3937
func publishingDismissed()
4038

41-
func removeFailedMedia()
42-
4339
/// Returns the word counts of the content in the editor.
4440
var wordCount: UInt { get }
4541

@@ -59,10 +55,6 @@ extension PublishingEditor {
5955
// Default implementation is empty, can be optionally implemented by other classes.
6056
}
6157

62-
func removeFailedMedia() {
63-
// TODO: we can only implement this when GB bridge allows removal of blocks
64-
}
65-
6658
// The debouncer will perform this callback every 500ms in order to save the post locally with a delay.
6759
var debouncerCallback: (() -> Void) {
6860
return { [weak self] in

WordPress/Classes/ViewRelated/Post/PostEditor.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ protocol PostEditor: PublishingEditor, UIViewControllerTransitioningDelegate {
4949
///
5050
func cancelUploadOfAllMedia(for post: AbstractPost)
5151

52-
/// Whether the editor has failed media or not
53-
///
54-
var hasFailedMedia: Bool { get }
55-
5652
var isUploadingMedia: Bool { get }
5753

5854
/// Verification prompt helper
@@ -73,9 +69,6 @@ protocol PostEditor: PublishingEditor, UIViewControllerTransitioningDelegate {
7369
/// Describes the editor type to be used in analytics reporting
7470
var analyticsEditorSource: String { get }
7571

76-
/// Error domain used when reporting error to Crash Logger
77-
var errorDomain: String { get }
78-
7972
/// Navigation bar manager for this post editor
8073
var navigationBarManager: PostEditorNavigationBarManager { get }
8174

@@ -110,21 +103,9 @@ extension PostEditor {
110103
postEditorStateContext.updated(hasChanges: editorHasChanges)
111104
}
112105

113-
var mainContext: NSManagedObjectContext {
114-
return ContextManager.sharedInstance().mainContext
115-
}
116-
117-
var currentBlogCount: Int {
118-
return postIsReblogged ? BlogQuery().hostedByWPCom(true).count(in: mainContext) : Blog.count(in: mainContext)
119-
}
120-
121106
var alertBarButtonItem: UIBarButtonItem? {
122107
return navigationBarManager.closeBarButtonItem
123108
}
124-
125-
var prepublishingSourceView: UIView? {
126-
return navigationBarManager.publishButton
127-
}
128109
}
129110

130111
extension PostEditor where Self: UIViewController {

WordPress/Classes/ViewRelated/Post/PostEditorAnalyticsSession.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,6 @@ struct PostEditorAnalyticsSession {
6060
WPAppAnalytics.track(.editorSessionSwitchEditor, withProperties: commonProperties)
6161
}
6262

63-
mutating func forceOutcome(_ newOutcome: Outcome) {
64-
// We're allowing an outcome to be force in a few specific cases:
65-
// - If a post was published, that should be the outcome no matter what happens later
66-
// - If a post is saved, that should be the outcome unless it's published later
67-
// - Otherwise, we'll use whatever outcome is set when the session ends
68-
switch (outcome, newOutcome) {
69-
case (_, .publish), (nil, .save):
70-
self.outcome = newOutcome
71-
default:
72-
break
73-
}
74-
}
75-
7663
func end(outcome endOutcome: Outcome) {
7764
let outcome = self.outcome ?? endOutcome
7865
let properties: [String: Any] = [

WordPress/Classes/ViewRelated/Post/PostEditorState.swift

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ public class PostEditorStateContext {
6868
}
6969
}
7070

71-
fileprivate var originalPostStatus: BasePost.Status?
72-
fileprivate var currentPostStatus: BasePost.Status?
73-
fileprivate var currentPublishDate: Date?
74-
fileprivate var userCanPublish: Bool
7571
private weak var delegate: PostEditorStateContextDelegate?
7672

7773
fileprivate var hasContent = false {
@@ -115,7 +111,6 @@ public class PostEditorStateContext {
115111

116112
self.init(originalPostStatus: originalPostStatus,
117113
userCanPublish: userCanPublish,
118-
publishDate: post.dateCreated,
119114
delegate: delegate)
120115

121116
if let action = action {
@@ -126,16 +121,9 @@ public class PostEditorStateContext {
126121
/// The default initializer
127122
///
128123
/// - Parameters:
129-
/// - originalPostStatus: If the post was already published (saved to the server) what is the status
130-
/// - userCanPublish: Does the user have permission to publish posts or merely create drafts
131-
/// - publishDate: The post publish date
132124
/// - delegate: Delegate for listening to change in state for the editor
133125
///
134-
required init(originalPostStatus: BasePost.Status? = nil, userCanPublish: Bool = true, publishDate: Date? = nil, delegate: PostEditorStateContextDelegate) {
135-
self.originalPostStatus = originalPostStatus
136-
self.currentPostStatus = originalPostStatus
137-
self.userCanPublish = userCanPublish
138-
self.currentPublishDate = publishDate
126+
required init(originalPostStatus: BasePost.Status? = nil, userCanPublish: Bool = true, delegate: PostEditorStateContextDelegate) {
139127
self.delegate = delegate
140128
self.action = PostEditorStateContext.initialAction(for: originalPostStatus, userCanPublish: userCanPublish)
141129
}
@@ -157,18 +145,6 @@ public class PostEditorStateContext {
157145
}
158146
}
159147

160-
/// Call when the post status has changed due to a remote operation
161-
///
162-
func updated(postStatus: BasePost.Status) {
163-
currentPostStatus = postStatus
164-
}
165-
166-
/// Call when the publish date has changed (picked a future date) or nil if publish immediately selected
167-
///
168-
func updated(publishDate: Date?) {
169-
currentPublishDate = publishDate
170-
}
171-
172148
/// Call whenever the post content is not empty - title or content body
173149
///
174150
func updated(hasContent: Bool) {

WordPress/Classes/ViewRelated/Post/PostListCell.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ protocol AbstractPostListCell {
77
}
88

99
final class PostListCell: UITableViewCell, AbstractPostListCell, PostSearchResultCell, Reusable {
10-
var isEnabled = true
11-
1210
// MARK: - Views
1311

1412
private lazy var mainStackView: UIStackView = {

0 commit comments

Comments
 (0)