forked from mirrors/linphone-iphone
factoize how to mark a chat room as read
This commit is contained in:
parent
08ca95be22
commit
7c0e9382fb
7 changed files with 26 additions and 36 deletions
|
|
@ -139,11 +139,8 @@
|
|||
index = (int)count - 1;
|
||||
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
|
||||
linphone_chat_room_mark_as_read(_chatRoom);
|
||||
[ChatConversationView markAsRead:_chatRoom];
|
||||
}
|
||||
TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController
|
||||
getCachedController:NSStringFromClass(TabBarView.class)];
|
||||
[tab update:YES];
|
||||
|
||||
// Scroll to unread
|
||||
if (index < 0)
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@
|
|||
@property (weak, nonatomic) IBOutlet UIIconButton *infoButton;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *particpantsLabel;
|
||||
|
||||
+ (void)markAsRead:(LinphoneChatRoom *)chatRoom;
|
||||
|
||||
- (void)configureForRoom:(BOOL)editing;
|
||||
- (IBAction)onBackClick:(id)event;
|
||||
- (IBAction)onEditClick:(id)event;
|
||||
|
|
@ -70,7 +72,6 @@
|
|||
- (IBAction)onCallClick:(id)sender;
|
||||
- (IBAction)onDeleteClick:(id)sender;
|
||||
- (IBAction)onEditionChangeClick:(id)sender;
|
||||
- (void)markAsRead;
|
||||
- (void)update;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -68,6 +68,19 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
return self.class.compositeViewDescription;
|
||||
}
|
||||
|
||||
|
||||
+ (void)markAsRead:(LinphoneChatRoom *)chatRoom {
|
||||
if (!chatRoom)
|
||||
return;
|
||||
|
||||
linphone_chat_room_mark_as_read(chatRoom);
|
||||
if (IPAD) {
|
||||
ChatsListView *listView = VIEW(ChatsListView);
|
||||
[listView.tableController markCellAsRead:chatRoom];
|
||||
}
|
||||
[PhoneMainView.instance updateApplicationBadgeNumber];
|
||||
}
|
||||
|
||||
#pragma mark - ViewController Functions
|
||||
|
||||
- (void)viewDidLoad {
|
||||
|
|
@ -197,13 +210,12 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
_chatView.hidden = NO;
|
||||
[self update];
|
||||
linphone_chat_room_mark_as_read(_chatRoom);
|
||||
[PhoneMainView.instance updateApplicationBadgeNumber];
|
||||
[ChatConversationView markAsRead:_chatRoom];
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(NSNotification *)notif {
|
||||
if (_chatRoom != nil) {
|
||||
linphone_chat_room_mark_as_read(_chatRoom);
|
||||
[ChatConversationView markAsRead:_chatRoom];
|
||||
TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController
|
||||
getCachedController:NSStringFromClass(TabBarView.class)];
|
||||
[tab update:YES];
|
||||
|
|
@ -215,14 +227,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[_backToCallButton update];
|
||||
}
|
||||
|
||||
- (void)markAsRead {
|
||||
linphone_chat_room_mark_as_read(_chatRoom);
|
||||
if (IPAD) {
|
||||
ChatsListView *listView = VIEW(ChatsListView);
|
||||
[listView.tableController markCellAsRead:_chatRoom];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)update {
|
||||
if (_chatRoom == NULL) {
|
||||
LOGW(@"Cannot update chat room header: null contact");
|
||||
|
|
@ -759,9 +763,6 @@ void on_chat_room_chat_message_received(LinphoneChatRoom *cr, const LinphoneEven
|
|||
return;
|
||||
|
||||
[view.tableController addEventEntry:(LinphoneEventLog *)event_log];
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
||||
linphone_chat_room_mark_as_read(view.chatRoom);
|
||||
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:view];
|
||||
[view.tableController scrollToLastUnread:TRUE];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -623,10 +623,7 @@ didInvalidatePushTokenForType:(NSString *)type {
|
|||
LinphoneAddress *local = linphone_address_new(local_address.UTF8String);
|
||||
LinphoneChatRoom *room = linphone_core_find_chat_room(LC, peer, local);
|
||||
if (room) {
|
||||
linphone_chat_room_mark_as_read(room);
|
||||
TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)];
|
||||
[tab update:YES];
|
||||
[PhoneMainView.instance updateApplicationBadgeNumber];
|
||||
[ChatConversationView markAsRead:room];
|
||||
}
|
||||
linphone_address_unref(peer);
|
||||
linphone_address_unref(local);
|
||||
|
|
@ -783,14 +780,9 @@ didInvalidatePushTokenForType:(NSString *)type {
|
|||
LinphoneAddress *peer = linphone_address_new(peer_address.UTF8String);
|
||||
LinphoneAddress *local = linphone_address_new(local_address.UTF8String);
|
||||
LinphoneChatRoom *room = linphone_core_find_chat_room(LC, peer, local);
|
||||
if (room) {
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
||||
linphone_chat_room_mark_as_read(room);
|
||||
TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController
|
||||
getCachedController:NSStringFromClass(TabBarView.class)];
|
||||
[tab update:YES];
|
||||
[PhoneMainView.instance updateApplicationBadgeNumber];
|
||||
}
|
||||
if (room && [UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
||||
[ChatConversationView markAsRead:room];
|
||||
|
||||
linphone_address_unref(peer);
|
||||
linphone_address_unref(local);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2561,10 +2561,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
if (linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room))
|
||||
[LinphoneManager.instance alertLIME:room];
|
||||
|
||||
linphone_chat_room_mark_as_read(room);
|
||||
TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)];
|
||||
[tab update:YES];
|
||||
[PhoneMainView.instance updateApplicationBadgeNumber];
|
||||
[ChatConversationView markAsRead:room];
|
||||
}
|
||||
|
||||
- (void)call:(const LinphoneAddress *)iaddr {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@
|
|||
} else {
|
||||
[_messageText setAccessibilityLabel:@"Incoming message"];
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
|
||||
VIEW(ChatConversationView).markAsRead;
|
||||
[ChatConversationView markAsRead:VIEW(ChatConversationView).chatRoom];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -551,6 +551,8 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
count += [LinphoneManager unreadMessageCount];
|
||||
count += linphone_core_get_calls_nb(LC);
|
||||
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];
|
||||
TabBarView *view = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)];
|
||||
[view update:TRUE];
|
||||
}
|
||||
|
||||
+ (CATransition *)getBackwardTransition {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue