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

Fix null errors #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions watoi/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ - (NSManagedObject *) addMissingMember:(NSString *)memberJID toChat:(NSString *)
NSMutableDictionary * members = [self.chatMembers objectForKey:chatJID];
NSManagedObject *chat = [self.chats objectForKey:chatJID];

[member setValue:memberJID forKey:@"memberJID"];
if (![memberJID isKindOfClass:[NSNull class]]) {
[member setValue:memberJID forKey:@"memberJID"];
} else {
[member setValue:@"null" forKey:@"memberJID"];
}
if (![isAdmin isKindOfClass:[NSNull class]]) {
[member setValue:isAdmin forKey:@"isAdmin"];
}
Expand Down Expand Up @@ -458,10 +462,6 @@ - (void) importMessages {
if (isGroup) {
NSString *senderJID = [amsg objectForKey:@"remote_resource"];
NSManagedObject *member = [members objectForKey:senderJID];
if (member == nil) {
NSLog(@"\tmissing sender %@", senderJID);
member = [self addMissingMember:senderJID toChat:chatJID asAdmin:@NO];
}

[msg setValue:member forKey:@"groupMember"];
}
Expand Down Expand Up @@ -521,6 +521,7 @@ - (void) importMessages {
[msg setValue:text forKey:@"text"];
} else {
NSLog(@"null text detected: %@", amsg);
[msg setValue:@"<null>" forKey:@"text"];
}

[msg setValue:chat forKey:@"chatSession"];
Expand Down