Room member details: Factorised the pretty string for presence in [Tools presenceText]

This commit is contained in:
manuroe
2016-04-29 09:54:43 +02:00
parent 7120fe73af
commit 64d93e36b2
6 changed files with 111 additions and 66 deletions
@@ -25,6 +25,7 @@
#import "RageShakeManager.h"
#import "AvatarGenerator.h"
#import "Tools.h"
#import "TableViewCellWithButton.h"
@@ -219,41 +220,12 @@
memberTitleView.memberBadge.hidden = YES;
}
NSString* presenceText = nil;
NSString* presenceText;
if (self.mxRoomMember.userId)
{
MXUser *user = [self.mxRoom.mxSession userWithUserId:self.mxRoomMember.userId];
if (user)
{
if (user.presence == MXPresenceOnline)
{
presenceText = NSLocalizedStringFromTable(@"room_participants_active", @"Vector", nil);
}
else
{
NSUInteger lastActiveMs = user.lastActiveAgo;
if (-1 != lastActiveMs)
{
NSUInteger lastActivehour = lastActiveMs / 1000 / 60 / 60;
NSUInteger lastActiveDays = lastActivehour / 24;
if (lastActivehour < 1)
{
presenceText = NSLocalizedStringFromTable(@"room_participants_active_less_1_hour", @"Vector", nil);
}
else if (lastActivehour < 24)
{
presenceText = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_participants_active_less_x_hours", @"Vector", nil), lastActivehour];
}
else
{
presenceText = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_participants_active_less_x_days", @"Vector", nil), lastActiveDays];
}
}
}
}
presenceText = [Tools presenceText:user];
}
self.roomMemberStatusLabel.text = presenceText;