Skip to content

Commit

Permalink
Implement isTyping property of MLContact
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Sep 8, 2024
1 parent 799d00c commit 872fa32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Monal/Classes/MLContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ FOUNDATION_EXPORT NSString* const kAskSubscribe;
*/
@property (nonatomic, copy) NSString* statusMessage;
@property (nonatomic, readonly) NSDate* _Nullable lastInteractionTime;
@property (nonatomic, readonly) BOOL isTyping;

/**
used to display the badge on a row
Expand Down
7 changes: 5 additions & 2 deletions Monal/Classes/MLContact.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ @interface MLContact ()
@property (nonatomic, strong) NSSet<NSString*>* rosterGroups;

@property (nonatomic, strong) NSDate* _Nullable lastInteractionTime;
@property (nonatomic, assign) BOOL isTyping;

@property (nonatomic, assign) NSInteger unreadCount;

Expand Down Expand Up @@ -286,9 +287,11 @@ -(void) handleLastInteractionTimeUpdate:(NSNotification*) notification

if(![self.contactJid isEqualToString:data[@"jid"]] || self.accountID.intValue != notificationAccountID.intValue)
return; // ignore other accounts or contacts
if(data[@"lastInteraction"] == nil)
return; // ignore typing notifications

self.isTyping = [data[@"isTyping"] boolValue];

if(data[@"lastInteraction"] == nil)
return;
//this will be nil if "urn:xmpp:idle:1" is not supported by any of the contact's devices
DDLogVerbose(@"Updating lastInteractionTime=%@ of %@", data[@"lastInteraction"], self);
self.lastInteractionTime = nilExtractor(data[@"lastInteraction"]);
Expand Down

0 comments on commit 872fa32

Please sign in to comment.