Browse files

fixed task completed problem

  • Loading branch information...
1 parent 255448f commit c2957a81dc2679f93c0f7908596691c6f5c92e4b Gerhard Schraml committed Jan 18, 2010
Showing with 29 additions and 27 deletions.
  1. +27 −23 Classes/HomeNavigationController.m
  2. +1 −3 Classes/SyncManager.m
  3. +1 −1 toodledo-objc
View
50 Classes/HomeNavigationController.m
@@ -166,35 +166,39 @@ -(IBAction)syncButtonPressed:(id)sender
[appDelegate startAnimating];
- SyncManager *syncManager = [[[SyncManager alloc] init] autorelease];
- BOOL successful = [syncManager syncWithPreference:SyncPreferRemote error:&error];
- //BOOL successful = [syncManager overwriteRemote:&error];
+ SyncManager *syncManager = [[SyncManager alloc] init];
+ Setting *settings = [Setting getSettings:&error];
NSString *stopTitle = nil;
NSString *stopMessage = nil;
- if(!successful)
+ if(error == nil)
{
- stopTitle = @"Error";
- stopMessage = [SyncManager gtdErrorMessage:[error code]];
- ALog(@"Error syncWithPreference:SyncPreferLocal = %@: %@", [SyncManager gtdErrorMessage:[error code]], error);
- }
- else
- {
- stopTitle = @"Success";
- stopMessage = @"Sync with ToodleDo was successful";
- ALog(@"syncWithPreference:SyncPreferLocal was successful");
+ BOOL successful = NO;
+ if(settings.preferToodleDo)
+ successful = [syncManager syncWithPreference:SyncPreferRemote error:&error];
+ else
+ successful = [syncManager syncWithPreference:SyncPreferLocal error:&error];
+
+ if(!successful)
+ {
+ stopTitle = @"Error";
+ stopMessage = [SyncManager gtdErrorMessage:[error code]];
+ ALog(@"Error syncWithPreference:SyncPreferLocal = %@: %@", [SyncManager gtdErrorMessage:[error code]], error);
+ }
+ else
+ {
+ stopTitle = @"Success";
+ stopMessage = @"Sync with ToodleDo was successful";
+ ALog(@"syncWithPreference:SyncPreferLocal was successful");
+ }
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"TaskAddedNotification" object:nil];
}
- /*BOOL successful = [syncManager overwriteRemote:&error];
- if(!successful)
- {
- ALog(@"Error overwriteLocal: = %@: %@", [SyncManager gtdErrorMessage:[error code]], error);
+ else {
+ stopTitle = @"Error";
+ stopMessage = @"Could not retrieve Toodledo account settings";
}
- else
- {
- ALog(@"overwriteLocal: was successful");
- }*/
-
+
[appDelegate stopAnimatingWithTitle:stopTitle andMessage:stopMessage];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"TaskAddedNotification" object:nil];
+ [syncManager release];
}
@end
View
4 Classes/SyncManager.m
@@ -271,8 +271,6 @@ +(NSString *)gtdErrorMessage:(NSInteger)errorCode
GtdApiContextNotAddedError = 510,
GtdApiContextNotDeletedError = 520,
GtdApiContextNotEditedError = 530*/
- ALog(@"gtdErrorMessage called with errorCode %d", errorCode);
- return [NSString stringWithFormat:@"gtdErrorMessage errorCode=%d", errorCode];
switch (errorCode) {
case GtdApiNoConnectionError:
return @"Toodledo API no connection";
@@ -1023,7 +1021,7 @@ -(BOOL)syncTasksMatchDates
remoteTask.folder = [localTask.folder.remoteId integerValue];
remoteTask.context = [localTask.context.remoteId integerValue];
remoteTask.priority = [localTask.priority integerValue];
- remoteTask.completed = (localTask.isCompleted ? [NSDate dateWithTimeIntervalSince1970:0] : nil);
+ remoteTask.completed = ([localTask.isCompleted boolValue] ? [NSDate dateWithTimeIntervalSince1970:0] : nil);
remoteTask.length = [localTask.duration integerValue];
remoteTask.note = localTask.note;
remoteTask.star = [localTask.star boolValue];
2 toodledo-objc
@@ -1 +1 @@
-Subproject commit 500ec06c224f01a941aef28ed6128765f0bd3818
+Subproject commit 80f9dca29e61b24e0b644d977d6f2ba000e6b309

0 comments on commit c2957a8

Please sign in to comment.