diff --git a/Leanote/Leanote-Info.plist b/Leanote/Leanote-Info.plist index 0729054..0656c3b 100755 --- a/Leanote/Leanote-Info.plist +++ b/Leanote/Leanote-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 944 + 945 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/Leanote/Settings.bundle/Root.plist b/Leanote/Settings.bundle/Root.plist index b6e7859..8ecce85 100755 --- a/Leanote/Settings.bundle/Root.plist +++ b/Leanote/Settings.bundle/Root.plist @@ -18,7 +18,7 @@ AutocorrectionType No DefaultValue - 1.0 (944) + 1.0 (945) IsSecure Key diff --git a/Leanote/service/NoteService.m b/Leanote/service/NoteService.m index 997dd1c..f8986c5 100644 --- a/Leanote/service/NoteService.m +++ b/Leanote/service/NoteService.m @@ -252,7 +252,7 @@ note.isInitSync = M_YES; // 需要重新同步笔记 note.isDirty = M_NO; note.localIsNew = M_NO; - note.updatedTime = [NSDate date]; + note.updatedTime = [Common goDate:obj[@"UpdatedTime"]]; NSString *tagsStr; if(![Common isNull:tags]) { @@ -296,18 +296,21 @@ NSNumber *isBlog = obj[@"IsBlog"]; NSNumber *isTrash = obj[@"IsTrash"]; + NSString *createdTime = obj[@"CreatedTime"]; + NSString *updatedTime = obj[@"UpdatedTime"]; + Note *note = [NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:self.tmpContext]; note.title = title; note.content = @""; note.serverNoteId = serverNoteId; - note.createdTime = [NSDate date]; - note.updatedTime = note.createdTime; note.isMarkdown = isMarkdown; note.isBlog = isBlog; note.usn = usn; note.isTrash = isTrash; + note.createdTime = [Common goDate:createdTime]; + note.updatedTime = [Common goDate:updatedTime]; note.isDirty = M_NO; note.localIsNew = M_NO; diff --git a/Leanote/service/NotebookService.m b/Leanote/service/NotebookService.m index bf485e1..70cfa47 100644 --- a/Leanote/service/NotebookService.m +++ b/Leanote/service/NotebookService.m @@ -181,6 +181,7 @@ static Notebook * curNotebook = nil; notebook.title = title; notebook.seq = seq; notebook.usn = usn; + notebook.updatedTime = [Common goDate:obj[@"UpdatedTime"]]; NSString *parentNotebookId = @""; if (![parentServerNotebookId isEqualToString:@""]) { @@ -224,6 +225,9 @@ static Notebook * curNotebook = nil; notebook.title = title; notebook.userId = [UserService getCurUserId]; + notebook.createdTime = [Common goDate:obj[@"CreatedTime"]]; + notebook.updatedTime = [Common goDate:obj[@"UpdatedTime"]]; + notebook.seq = seq; notebook.usn = usn; diff --git a/Leanote/service/SyncService.m b/Leanote/service/SyncService.m index 0b4e422..86bf306 100644 --- a/Leanote/service/SyncService.m +++ b/Leanote/service/SyncService.m @@ -232,7 +232,7 @@ BOOL inSyncing = NO; continue; } - [_tagService addTag:title isForce:YES usn:usn]; + [_tagService addTagForce:eachObj]; } // push到context中, 并写 diff --git a/Leanote/service/TagService.h b/Leanote/service/TagService.h index 1e792a5..00d8341 100644 --- a/Leanote/service/TagService.h +++ b/Leanote/service/TagService.h @@ -18,6 +18,7 @@ inContext:(NSManagedObjectContext *)inContext; -(Tag *)addTag:(NSString *)title isForce:(BOOL)isForce usn:(NSNumber *)usn; +- (Tag *) addTagForce:(id)obj; + (Tag *) addTag:(NSString *)title isForce:(BOOL)isForce usn:(NSNumber *)usn inContext:(NSManagedObjectContext *)inContext; diff --git a/Leanote/service/TagService.m b/Leanote/service/TagService.m index ddff69d..04571df 100644 --- a/Leanote/service/TagService.m +++ b/Leanote/service/TagService.m @@ -51,8 +51,42 @@ return [self.class addTag:title isForce:isForce usn:usn inContext:self.tmpContext]; } +- (Tag *) addTagForce:(id)obj +{ + NSString *title = obj[@"Tag"]; + NSNumber *usn = obj[@"Usn"]; + + NSDate *createdTime = [Common goDate:obj[@"CreatedTime"]]; + NSDate *updatedTime = [Common goDate:obj[@"UpdatedTime"]]; + + return [self.class addTag:title + isForce:YES + createdTime:createdTime + updatedTime:updatedTime + usn:usn + inContext:self.tmpContext]; + +} + // 新增或更新 -+ (Tag *) addTag:(NSString *)title isForce:(BOOL)isForce usn:(NSNumber *)usn ++ (Tag *) addTag:(NSString *)title + isForce:(BOOL)isForce + usn:(NSNumber *)usn + inContext:(NSManagedObjectContext *)inContext +{ + return [self addTag:title + isForce:isForce + createdTime:[NSDate date] + updatedTime:[NSDate date] + usn:usn inContext:inContext]; +} + +// 新增或更新 ++ (Tag *) addTag:(NSString *)title + isForce:(BOOL)isForce + createdTime:(NSDate *)createdTime + updatedTime:(NSDate *)updatedTime + usn:(NSNumber *)usn inContext:(NSManagedObjectContext *)inContext { // 空标题不让新增 @@ -77,12 +111,12 @@ // 新增 tag = [NSEntityDescription insertNewObjectForEntityForName:@"Tag" inManagedObjectContext:inContext]; tag.title = title; - tag.createdTime = [NSDate date]; - tag.updatedTime = tag.createdTime; + tag.createdTime = createdTime; + tag.updatedTime = updatedTime; tag.isDirty = isForce ? M_NO : M_YES; tag.localIsDelete = M_NO; tag.userId = [UserService getCurUserId]; - + if(isForce) { tag.usn = usn; } @@ -90,7 +124,7 @@ if(!isForce) { [self saveContext]; } - + // 发送改变之 /* [self push:tag success:^{ diff --git a/Leanote/util/Common.h b/Leanote/util/Common.h index afc3206..24726ce 100644 --- a/Leanote/util/Common.h +++ b/Leanote/util/Common.h @@ -32,4 +32,6 @@ +(void) setBarStyleBlack; + (BOOL)isiOSVersionEarlierThan8; + ++ (NSDate *)goDate:(NSString *)dateStr; @end diff --git a/Leanote/util/Common.m b/Leanote/util/Common.m index 0f401de..3ca8375 100644 --- a/Leanote/util/Common.m +++ b/Leanote/util/Common.m @@ -189,4 +189,32 @@ return [[[UIDevice currentDevice] systemVersion] floatValue] < 8.0; } +/* + //2014-01-06T18:29:48.802+08:00 + function goNowToDatetime(goNow) { + if(!goNow) { + return ""; + } + // new Date(); + if(typeof goNow == 'object') { + var date = new Date(goNow); + return date.format("yyyy-MM-dd hh:mm:ss"); + } + return goNow.substr(0, 10) + " " + goNow.substr(11, 8); +*/ ++ (NSDate *)goDate:(NSString *)dateStr +{ + if ([Common isBlankString:dateStr]) { + return [NSDate date]; + } + + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; + + NSString *ymd = [dateStr substringWithRange:NSMakeRange(0, 10)]; + NSString *hms = [dateStr substringWithRange:NSMakeRange(11, 8)]; + NSDate *date = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@ %@", ymd, hms]]; + return date; +} + @end diff --git a/README.md b/README.md index 5aae1a6..ba29a41 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Leanote-IOS +# Leanote IOS Download From App Store