applied comments and fix bug when tagging msgs already tagged

pull/53/head
Alexandre Cloutier 2014-09-02 14:31:46 -04:00
parent 3b65eaea0b
commit 32476b16cc
2 changed files with 10 additions and 12 deletions

View File

@ -635,11 +635,7 @@
flags = [NSArray arrayWithObject:[content objectForKey:@"flags"]];
msgUIDs = [NSArray arrayWithArray:[content objectForKey:@"msgUIDs"]];
operation = [content objectForKey:@"operation"];
if ([operation isEqualToString:@"add"])
addOrRemove = YES;
else
addOrRemove = NO;
addOrRemove = ([operation isEqualToString:@"add"]? YES: NO);
co = [self clientObject];
client = [[co imap4Connection] client];
@ -648,7 +644,7 @@
if ([[[[result objectForKey:@"RawResponse"] objectForKey:@"ResponseResult"] objectForKey:@"description"] isEqualToString:@"Completed"])
response = [self responseWith204];
else
response = nil;
response = [self responseWithStatus:500 andJSONRepresentation:result];
return response;
}
@ -674,16 +670,16 @@
co = [self clientObject];
v = [[[context activeUser] userDefaults] mailLabelsColors];
[flags addObjectsFromArray: [v allKeys]];
client = [[co imap4Connection] client];
[[co imap4Connection] selectFolder: [co imap4URL]];
result = [client storeFlags:flags forUIDs:msgUIDs addOrRemove:NO];
if ([[[[result objectForKey:@"RawResponse"] objectForKey:@"ResponseResult"] objectForKey:@"description"] isEqualToString:@"Completed"])
response = [self responseWith204];
else
response = nil;
response = [self responseWithStatus:500 andJSONRepresentation:result];
return response;
}

View File

@ -2550,8 +2550,10 @@ function messageFlagCallback(http) {
var flags = [];
if (labels.length > 0)
flags = labels.split(" ");
if (operation == "add")
flags.push(data["flag"]);
if (operation == "add") {
if (flags.indexOf(data["flag"]) == -1)
flags.push(data["flag"]);
}
else {
// Remove flag
var flag = data["flag"];