Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autosave attributes to Core Data #12826

Merged
6 changes: 6 additions & 0 deletions MIGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
This file documents changes in the data model. Please explain any changes to the
data model as well as any custom migrations.

## WordPress 93

@guarani 2019-10-27

- `AbstractPost` added `autosaveTitle` (`nullable` `String`), `autosaveExcerpt` (`nullable` `String`), `autosaveContent` (`nullable` `String`), and `autosaveModifiedDate` (`nullable` `Date`) properties.

## WordPress 92

@jklausa 2019-08-19
Expand Down
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def wordpress_ui
end

def wordpress_kit
pod 'WordPressKit', '~> 4.5.3-beta.1'
#pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => ''
pod 'WordPressKit', '~> 4.5.3-beta.2'
#pod 'WordPressKit', :git => 'https://github.com/guarani/WordPressKit-iOS.git', :branch => 'issue/12141-restore-revision-dialog'
#pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => ''
#pod 'WordPressKit', :path => '../WordPressKit-iOS'
end
Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ PODS:
- WordPressKit (~> 4.5.1)
- WordPressShared (~> 1.8)
- WordPressUI (~> 1.4-beta.1)
- WordPressKit (4.5.3-beta.1):
- WordPressKit (4.5.3-beta.2):
- Alamofire (~> 4.7.3)
- CocoaLumberjack (~> 3.4)
- NSObject-SafeExpectations (= 0.0.3)
Expand Down Expand Up @@ -300,7 +300,7 @@ DEPENDENCIES:
- SVProgressHUD (= 2.2.5)
- WordPress-Editor-iOS (~> 1.11.0)
- WordPressAuthenticator (~> 1.10.2)
- WordPressKit (~> 4.5.3-beta.1)
- WordPressKit (~> 4.5.3-beta.2)
- WordPressMocks (~> 0.0.6)
- WordPressShared (~> 1.8.8)
- WordPressUI (~> 1.5.0)
Expand Down Expand Up @@ -489,7 +489,7 @@ SPEC CHECKSUMS:
WordPress-Aztec-iOS: 050b34d4c3adfb7c60363849049b13d60683b348
WordPress-Editor-iOS: 304098424f1051cb271546c99f906aac296b1b81
WordPressAuthenticator: af8a2b733b8a33d2ad04cdd30f5410bfe772f439
WordPressKit: 6e02d166cbc6c6482987f5107f53d6cc1e8cbc87
WordPressKit: 620bff49011b1e888a6132410c700a25dd059f2d
WordPressMocks: 5913bd04586a360212e07a8ccbcb36068d4425a3
WordPressShared: 64332b24b8a70b7796ee137847cd0d66bdb6b4c1
WordPressUI: 4a4adafd2b052e94e4846c0a0203761773dc4fd5
Expand All @@ -499,6 +499,6 @@ SPEC CHECKSUMS:
ZendeskSDK: 35b16898fae049f6ebffba96793f209b03a41495
ZIPFoundation: 89df685c971926b0323087952320bdfee9f0b6ef

PODFILE CHECKSUM: f0c0f973e03d32d504ef8ec8d6532b61f97761a8
PODFILE CHECKSUM: 6a663fb0ac12175246b87a8c071b48000e3e97bc

COCOAPODS: 1.8.4
8 changes: 8 additions & 0 deletions WordPress/Classes/Models/AbstractPost.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ typedef NS_ENUM(NSUInteger, AbstractPostRemoteStatus) {
*/
@property (nonatomic, strong, nonnull) NSNumber *autoUploadAttemptsCount;

/**
Autosave attributes hold a snapshot of the post's content.
*/
@property (nonatomic, copy, nullable) NSString *autosaveContent;
@property (nonatomic, copy, nullable) NSString *autosaveExcerpt;
@property (nonatomic, copy, nullable) NSString *autosaveTitle;
@property (nonatomic, copy, nullable) NSDate *autosaveModifiedDate;

// Revision management
- (AbstractPost *)createRevision;
- (void)deleteRevision;
Expand Down
4 changes: 4 additions & 0 deletions WordPress/Classes/Models/AbstractPost.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ @implementation AbstractPost
@dynamic confirmedChangesHash;
@dynamic confirmedChangesTimestamp;
@dynamic autoUploadAttemptsCount;
@dynamic autosaveContent;
@dynamic autosaveExcerpt;
@dynamic autosaveTitle;
@dynamic autosaveModifiedDate;

@synthesize restorableStatus;

Expand Down
5 changes: 5 additions & 0 deletions WordPress/Classes/Services/PostService.m
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,11 @@ - (void)updatePost:(AbstractPost *)post withRemotePost:(RemotePost *)remotePost
[self updateCommentsForPost:post];
}

post.autosaveTitle = remotePost.autosave.title;
post.autosaveExcerpt = remotePost.autosave.excerpt;
post.autosaveContent = remotePost.autosave.content;
post.autosaveModifiedDate = remotePost.autosave.modifiedDate;

if ([post isKindOfClass:[Page class]]) {
Page *pagePost = (Page *)post;
pagePost.parentID = remotePost.parentID;
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/PostServiceOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
@property (nonatomic, assign) PostServiceResultsOrdering orderBy;
@property (nonatomic, strong) NSNumber *authorID;
@property (nonatomic, copy) NSString *search;
@property (nonatomic, copy) NSString *meta;

@end
9 changes: 9 additions & 0 deletions WordPress/Classes/Services/PostServiceOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@

@implementation PostServiceSyncOptions

- (instancetype)init
{
self = [super init];
if (self) {
self.meta = @"autosave";
}
return self;
}

@end
2 changes: 1 addition & 1 deletion WordPress/Classes/WordPress.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>WordPress 92.xcdatamodel</string>
<string>WordPress 93.xcdatamodel</string>
</dict>
</plist>

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,7 @@
31EC15061A5B6675009FC8B3 /* WPStyleGuide+Suggestions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPStyleGuide+Suggestions.h"; sourceTree = "<group>"; };
31EC15071A5B6675009FC8B3 /* WPStyleGuide+Suggestions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "WPStyleGuide+Suggestions.m"; sourceTree = "<group>"; };
31FA16CC1A49B3C0003E1887 /* WordPress 25.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 25.xcdatamodel"; sourceTree = "<group>"; };
32A29A16236BC8BC009488C2 /* WordPress 93.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 93.xcdatamodel"; sourceTree = "<group>"; };
33D5016BDA00B45DFCAF3818 /* Pods-WordPressNotificationServiceExtension.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressNotificationServiceExtension.release-internal.xcconfig"; path = "../Pods/Target Support Files/Pods-WordPressNotificationServiceExtension/Pods-WordPressNotificationServiceExtension.release-internal.xcconfig"; sourceTree = "<group>"; };
368127CE6F1CA15EC198147D /* Pods-WordPressTodayWidget.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressTodayWidget.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-WordPressTodayWidget/Pods-WordPressTodayWidget.debug.xcconfig"; sourceTree = "<group>"; };
37022D8F1981BF9200F322B7 /* VerticallyStackedButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VerticallyStackedButton.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -14804,6 +14805,7 @@
E125443B12BF5A7200D87A0A /* WordPress.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
32A29A16236BC8BC009488C2 /* WordPress 93.xcdatamodel */,
57CCB37E2358E5DC003ECD0C /* WordPress 92.xcdatamodel */,
E63EC3632356633B008CEB16 /* WordPress 91.xcdatamodel */,
F14E844C2317252200D0C63E /* WordPress 90.xcdatamodel */,
Expand Down Expand Up @@ -14897,7 +14899,7 @@
8350E15911D28B4A00A7B073 /* WordPress.xcdatamodel */,
E125443D12BF5A7200D87A0A /* WordPress 2.xcdatamodel */,
);
currentVersion = 57CCB37E2358E5DC003ECD0C /* WordPress 92.xcdatamodel */;
currentVersion = 32A29A16236BC8BC009488C2 /* WordPress 93.xcdatamodel */;
name = WordPress.xcdatamodeld;
path = Classes/WordPress.xcdatamodeld;
sourceTree = "<group>";
Expand Down