Make lobby timer use timestamps.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2019-07-31 10:02:51 +02:00
Родитель a739a670a1
Коммит 3f7839c080
6 изменённых файлов: 17 добавлений и 17 удалений

Просмотреть файл

@ -95,7 +95,7 @@ typedef void (^UnsubscribeToPushProxyCompletionBlock)(NSError *error);
- (NSURLSessionDataTask *)removeRoomFromFavorites:(NSString *)token withCompletionBlock:(FavoriteRoomCompletionBlock)block;
- (NSURLSessionDataTask *)setNotificationLevel:(NCRoomNotificationLevel)level forRoom:(NSString *)token withCompletionBlock:(NotificationLevelCompletionBlock)block;
- (NSURLSessionDataTask *)setReadOnlyState:(NCRoomReadOnlyState)state forRoom:(NSString *)token withCompletionBlock:(ReadOnlyCompletionBlock)block;
- (NSURLSessionDataTask *)setLobbyState:(NCRoomLobbyState)state withTimer:(NSString *)timer forRoom:(NSString *)token withCompletionBlock:(SetLobbyStateCompletionBlock)block;
- (NSURLSessionDataTask *)setLobbyState:(NCRoomLobbyState)state withTimer:(NSInteger)timer forRoom:(NSString *)token withCompletionBlock:(SetLobbyStateCompletionBlock)block;
// Participants Controller
- (NSURLSessionDataTask *)getParticipantsFromRoom:(NSString *)token withCompletionBlock:(GetParticipantsFromRoomCompletionBlock)block;

Просмотреть файл

@ -497,13 +497,13 @@ NSString * const kNCSpreedAPIVersion = @"/apps/spreed/api/v1";
return task;
}
- (NSURLSessionDataTask *)setLobbyState:(NCRoomLobbyState)state withTimer:(NSString *)timer forRoom:(NSString *)token withCompletionBlock:(SetLobbyStateCompletionBlock)block
- (NSURLSessionDataTask *)setLobbyState:(NCRoomLobbyState)state withTimer:(NSInteger)timer forRoom:(NSString *)token withCompletionBlock:(SetLobbyStateCompletionBlock)block
{
NSString *URLString = [self getRequestURLForSpreedEndpoint:[NSString stringWithFormat:@"room/%@/webinary/lobby", token]];
NSMutableDictionary *parameters = [NSMutableDictionary new];
[parameters setObject:@(state) forKey:@"state"];
if (timer) {
[parameters setObject:timer forKey:@"timer"];
if (timer > 0) {
[parameters setObject:@(timer) forKey:@"timer"];
}
NSURLSessionDataTask *task = [[NCAPISessionManager sharedInstance] PUT:URLString parameters:parameters success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {

Просмотреть файл

@ -293,8 +293,8 @@
if ([self shouldPresentLobbyView]) {
[_chatBackgroundView.placeholderText setText:@"You are currently waiting in the lobby."];
[_chatBackgroundView.placeholderImage setImage:[UIImage imageNamed:@"lobby-placeholder"]];
NSDate *date = [NCUtils dateFromDateAtomFormat:_room.lobbyTimer];
if (date) {
if (_room.lobbyTimer > 0) {
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:_room.lobbyTimer];
NSString *meetingStart = [NCUtils readableDateFromDate:date];
NSString *placeHolderText = [NSString stringWithFormat:@"You are currently waiting in the lobby.\nThis meeting is scheduled for\n%@", meetingStart];
[_chatBackgroundView.placeholderText setText:placeHolderText];

Просмотреть файл

@ -62,7 +62,7 @@ extern NSString * const NCRoomObjectTypeSharePassword;
@property (nonatomic, copy) NSString *objectId;
@property (nonatomic, assign) NCRoomReadOnlyState readOnlyState;
@property (nonatomic, assign) NCRoomLobbyState lobbyState;
@property (nonatomic, copy) NSString *lobbyTimer;
@property (nonatomic, assign) NSInteger lobbyTimer;
+ (instancetype)roomWithDictionary:(NSDictionary *)roomDict;

Просмотреть файл

@ -42,7 +42,7 @@ NSString * const NCRoomObjectTypeSharePassword = @"share:password";
room.objectId = [roomDict objectForKey:@"objectId"];
room.readOnlyState = (NCRoomReadOnlyState)[[roomDict objectForKey:@"readOnly"] integerValue];
room.lobbyState = (NCRoomLobbyState)[[roomDict objectForKey:@"lobbyState"] integerValue];
room.lobbyTimer = [roomDict objectForKey:@"lobbyTimer"];
room.lobbyTimer = [[roomDict objectForKey:@"lobbyTimer"] integerValue];
id name = [roomDict objectForKey:@"name"];
if ([name isKindOfClass:[NSString class]]) {

Просмотреть файл

@ -672,15 +672,15 @@ typedef enum ModificationError {
- (void)enableLobby
{
[self setLobbyState:NCRoomLobbyStateModeratorsOnly withTimer:nil];
[self setLobbyState:NCRoomLobbyStateModeratorsOnly withTimer:0];
}
- (void)disableLobby
{
[self setLobbyState:NCRoomLobbyStateAllParticipants withTimer:nil];
[self setLobbyState:NCRoomLobbyStateAllParticipants withTimer:0];
}
- (void)setLobbyState:(NCRoomLobbyState)lobbyState withTimer:(NSString *)timer
- (void)setLobbyState:(NCRoomLobbyState)lobbyState withTimer:(NSInteger)timer
{
[self setModifyingRoomUI];
[[NCAPIController sharedInstance] setLobbyState:lobbyState withTimer:timer forRoom:_room.token withCompletionBlock:^(NSError *error) {
@ -696,7 +696,7 @@ typedef enum ModificationError {
- (void)setLobbyDate
{
NSString *lobbyTimer = [NCUtils dateAtomFormatFromDate:_lobbyDatePicker.date];
NSInteger lobbyTimer = _lobbyDatePicker.date.timeIntervalSince1970;
[self setLobbyState:NCRoomLobbyStateModeratorsOnly withTimer:lobbyTimer];
NSString *lobbyTimerReadable = [NCUtils readableDateFromDate:_lobbyDatePicker.date];
@ -706,7 +706,7 @@ typedef enum ModificationError {
- (void)removeLobbyDate
{
[self setLobbyState:NCRoomLobbyStateModeratorsOnly withTimer:nil];
[self setLobbyState:NCRoomLobbyStateModeratorsOnly withTimer:0];
[self dismissLobbyDatePicker];
}
@ -727,8 +727,8 @@ typedef enum ModificationError {
[toolBar setItems:[NSArray arrayWithObjects:cancelButton, space,doneButton, nil]];
[_lobbyDateTextField setInputAccessoryView:toolBar];
NSDate *date = [NCUtils dateFromDateAtomFormat:_room.lobbyTimer];
if (date) {
if (_room.lobbyTimer > 0) {
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:_room.lobbyTimer];
UIBarButtonItem *clearButton = [[UIBarButtonItem alloc] initWithTitle:@"Remove" style:UIBarButtonItemStylePlain target:self action:@selector(removeLobbyDate)];
[clearButton setTintColor:[UIColor redColor]];
[toolBar setItems:[NSArray arrayWithObjects:clearButton, space, doneButton, nil]];
@ -1224,8 +1224,8 @@ typedef enum ModificationError {
cell.textLabel.text = @"Start time";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryView = _lobbyDateTextField;
NSDate *date = [NCUtils dateFromDateAtomFormat:_room.lobbyTimer];
_lobbyDateTextField.text = date ? [NCUtils readableDateFromDate:date] : nil;
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:_room.lobbyTimer];
_lobbyDateTextField.text = _room.lobbyTimer > 0 ? [NCUtils readableDateFromDate:date] : nil;
[cell.imageView setImage:[UIImage imageNamed:@"timer"]];
return cell;