зеркало из https://github.com/nextcloud/talk-ios.git
Add the ability to search and join open conversations.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
9efaf8be94
Коммит
c1a5be4dfb
|
@ -121,6 +121,7 @@ extern NSInteger const kReceivedChatMessagesLimit;
|
||||||
// Rooms Controller
|
// Rooms Controller
|
||||||
- (NSURLSessionDataTask *)getRoomsForAccount:(TalkAccount *)account updateStatus:(BOOL)updateStatus withCompletionBlock:(GetRoomsCompletionBlock)block;
|
- (NSURLSessionDataTask *)getRoomsForAccount:(TalkAccount *)account updateStatus:(BOOL)updateStatus withCompletionBlock:(GetRoomsCompletionBlock)block;
|
||||||
- (NSURLSessionDataTask *)getRoomForAccount:(TalkAccount *)account withToken:(NSString *)token withCompletionBlock:(GetRoomCompletionBlock)block;
|
- (NSURLSessionDataTask *)getRoomForAccount:(TalkAccount *)account withToken:(NSString *)token withCompletionBlock:(GetRoomCompletionBlock)block;
|
||||||
|
- (NSURLSessionDataTask *)getListableRoomsForAccount:(TalkAccount *)account withSearchTerm:(NSString *)searchTerm andCompletionBlock:(GetRoomsCompletionBlock)block;
|
||||||
- (NSURLSessionDataTask *)createRoomForAccount:(TalkAccount *)account with:(NSString *)invite ofType:(NCRoomType)type andName:(NSString *)roomName withCompletionBlock:(CreateRoomCompletionBlock)block;
|
- (NSURLSessionDataTask *)createRoomForAccount:(TalkAccount *)account with:(NSString *)invite ofType:(NCRoomType)type andName:(NSString *)roomName withCompletionBlock:(CreateRoomCompletionBlock)block;
|
||||||
- (NSURLSessionDataTask *)renameRoom:(NSString *)token forAccount:(TalkAccount *)account withName:(NSString *)newName andCompletionBlock:(RenameRoomCompletionBlock)block;
|
- (NSURLSessionDataTask *)renameRoom:(NSString *)token forAccount:(TalkAccount *)account withName:(NSString *)newName andCompletionBlock:(RenameRoomCompletionBlock)block;
|
||||||
- (NSURLSessionDataTask *)makeRoomPublic:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(MakeRoomPublicCompletionBlock)block;
|
- (NSURLSessionDataTask *)makeRoomPublic:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(MakeRoomPublicCompletionBlock)block;
|
||||||
|
|
|
@ -298,6 +298,38 @@ NSInteger const kReceivedChatMessagesLimit = 100;
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)getListableRoomsForAccount:(TalkAccount *)account withSearchTerm:(NSString *)searchTerm andCompletionBlock:(GetRoomsCompletionBlock)block
|
||||||
|
{
|
||||||
|
NSString *endpoint = @"listed-room";
|
||||||
|
NSInteger conversationAPIVersion = [self conversationAPIVersionForAccount:account];
|
||||||
|
NSString *URLString = [self getRequestURLForEndpoint:endpoint withAPIVersion:conversationAPIVersion forAccount:account];
|
||||||
|
NSDictionary *parameters = nil;
|
||||||
|
if (searchTerm.length > 0) {
|
||||||
|
parameters = @{@"searchTerm" : searchTerm};
|
||||||
|
}
|
||||||
|
NCAPISessionManager *apiSessionManager = [_apiSessionManagers objectForKey:account.accountId];
|
||||||
|
NSURLSessionDataTask *task = [apiSessionManager GET:URLString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
|
||||||
|
NSArray *responseRooms = [[responseObject objectForKey:@"ocs"] objectForKey:@"data"];
|
||||||
|
NSMutableArray *parsedRooms = [NSMutableArray new];
|
||||||
|
for (NSDictionary *roomDict in responseRooms) {
|
||||||
|
NCRoom *room = [NCRoom roomWithDictionary:roomDict andAccountId:account.accountId];
|
||||||
|
[parsedRooms addObject:room];
|
||||||
|
}
|
||||||
|
if (block) {
|
||||||
|
block(parsedRooms, nil, 0);
|
||||||
|
}
|
||||||
|
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||||
|
NSInteger statusCode = [self getResponseStatusCode:task.response];
|
||||||
|
[self checkResponseStatusCode:statusCode forAccount:account];
|
||||||
|
if (block) {
|
||||||
|
block(nil, error, statusCode);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (NSURLSessionDataTask *)createRoomForAccount:(TalkAccount *)account with:(NSString *)invite ofType:(NCRoomType)type andName:(NSString *)roomName withCompletionBlock:(CreateRoomCompletionBlock)block
|
- (NSURLSessionDataTask *)createRoomForAccount:(TalkAccount *)account with:(NSString *)invite ofType:(NCRoomType)type andName:(NSString *)roomName withCompletionBlock:(CreateRoomCompletionBlock)block
|
||||||
{
|
{
|
||||||
NSString *endpoint = @"room";
|
NSString *endpoint = @"room";
|
||||||
|
|
|
@ -42,6 +42,7 @@ extern NSString * const kCapabilityCirclesSupport;
|
||||||
extern NSString * const kCapabilityChatReferenceId;
|
extern NSString * const kCapabilityChatReferenceId;
|
||||||
extern NSString * const kCapabilityPhonebookSearch;
|
extern NSString * const kCapabilityPhonebookSearch;
|
||||||
extern NSString * const kCapabilityChatReadStatus;
|
extern NSString * const kCapabilityChatReadStatus;
|
||||||
|
extern NSString * const kCapabilityListableRooms;
|
||||||
extern NSString * const kCapabilityDeleteMessages;
|
extern NSString * const kCapabilityDeleteMessages;
|
||||||
extern NSString * const kCapabilityCallFlags;
|
extern NSString * const kCapabilityCallFlags;
|
||||||
extern NSString * const kCapabilityRoomDescription;
|
extern NSString * const kCapabilityRoomDescription;
|
||||||
|
|
|
@ -44,6 +44,7 @@ NSString * const kCapabilityCirclesSupport = @"circles-support";
|
||||||
NSString * const kCapabilityChatReferenceId = @"chat-reference-id";
|
NSString * const kCapabilityChatReferenceId = @"chat-reference-id";
|
||||||
NSString * const kCapabilityPhonebookSearch = @"phonebook-search";
|
NSString * const kCapabilityPhonebookSearch = @"phonebook-search";
|
||||||
NSString * const kCapabilityChatReadStatus = @"chat-read-status";
|
NSString * const kCapabilityChatReadStatus = @"chat-read-status";
|
||||||
|
NSString * const kCapabilityListableRooms = @"listable-rooms";
|
||||||
NSString * const kCapabilityDeleteMessages = @"delete-messages";
|
NSString * const kCapabilityDeleteMessages = @"delete-messages";
|
||||||
NSString * const kCapabilityCallFlags = @"conversation-call-flags";
|
NSString * const kCapabilityCallFlags = @"conversation-call-flags";
|
||||||
NSString * const kCapabilityRoomDescription = @"room-description";
|
NSString * const kCapabilityRoomDescription = @"room-description";
|
||||||
|
|
|
@ -24,9 +24,15 @@
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class NCRoom;
|
||||||
|
|
||||||
@interface RoomSearchTableViewController : UITableViewController
|
@interface RoomSearchTableViewController : UITableViewController
|
||||||
|
|
||||||
@property (nonatomic, strong) NSArray *rooms;
|
@property (nonatomic, strong) NSArray *rooms;
|
||||||
|
@property (nonatomic, strong) NSArray *listableRooms;
|
||||||
|
|
||||||
|
- (NCRoom *)roomForIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
- (BOOL)hasResults;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,11 @@
|
||||||
#import "PlaceholderView.h"
|
#import "PlaceholderView.h"
|
||||||
#import "RoomTableViewCell.h"
|
#import "RoomTableViewCell.h"
|
||||||
|
|
||||||
|
typedef enum RoomSearchSection {
|
||||||
|
RoomSearchSectionFiltered = 0,
|
||||||
|
RoomSearchSectionListable
|
||||||
|
} RoomSearchSection;
|
||||||
|
|
||||||
@interface RoomSearchTableViewController ()
|
@interface RoomSearchTableViewController ()
|
||||||
{
|
{
|
||||||
PlaceholderView *_roomSearchBackgroundView;
|
PlaceholderView *_roomSearchBackgroundView;
|
||||||
|
@ -85,14 +90,39 @@
|
||||||
return [formatter stringFromDate:date];
|
return [formatter stringFromDate:date];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Table view data source
|
- (NCRoom *)roomForIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
if (indexPath.section == RoomSearchSectionFiltered && indexPath.row < _rooms.count) {
|
||||||
return 1;
|
return [_rooms objectAtIndex:indexPath.row];
|
||||||
|
} else if (indexPath.section == RoomSearchSectionListable && indexPath.row < _listableRooms.count) {
|
||||||
|
return [_listableRooms objectAtIndex:indexPath.row];
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
- (BOOL)hasResults
|
||||||
return _rooms.count;
|
{
|
||||||
|
return _rooms.count > 0 || _listableRooms.count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Table view data source
|
||||||
|
|
||||||
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||||
|
{
|
||||||
|
return _listableRooms.count > 0 ? 2 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||||
|
{
|
||||||
|
switch (section) {
|
||||||
|
case RoomSearchSectionFiltered:
|
||||||
|
return _rooms.count;
|
||||||
|
case RoomSearchSectionListable:
|
||||||
|
return _listableRooms.count;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
@ -100,14 +130,20 @@
|
||||||
return kRoomTableCellHeight;
|
return kRoomTableCellHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
||||||
//{
|
{
|
||||||
// return [_indexes objectAtIndex:section];
|
switch (section) {
|
||||||
//}
|
case RoomSearchSectionListable:
|
||||||
|
return NSLocalizedString(@"Open conversations", nil);
|
||||||
|
default:
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [self roomForIndexPath:indexPath];
|
||||||
|
|
||||||
RoomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kRoomCellIdentifier];
|
RoomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kRoomCellIdentifier];
|
||||||
if (!cell) {
|
if (!cell) {
|
||||||
cell = [[RoomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kRoomCellIdentifier];
|
cell = [[RoomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kRoomCellIdentifier];
|
||||||
|
|
|
@ -454,8 +454,17 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
|
|
||||||
- (void)searchForRoomsWithString:(NSString *)searchString
|
- (void)searchForRoomsWithString:(NSString *)searchString
|
||||||
{
|
{
|
||||||
|
// Filter rooms
|
||||||
_resultTableViewController.rooms = [self filterRoomsWithString:searchString];
|
_resultTableViewController.rooms = [self filterRoomsWithString:searchString];
|
||||||
[_resultTableViewController.tableView reloadData];
|
[_resultTableViewController.tableView reloadData];
|
||||||
|
// Search for listable rooms
|
||||||
|
TalkAccount *account = [[NCDatabaseManager sharedInstance] activeAccount];
|
||||||
|
[[NCAPIController sharedInstance] getListableRoomsForAccount:account withSearchTerm:searchString andCompletionBlock:^(NSArray *rooms, NSError *error, NSInteger statusCode) {
|
||||||
|
if (!error) {
|
||||||
|
self->_resultTableViewController.listableRooms = rooms;
|
||||||
|
[self->_resultTableViewController.tableView reloadData];
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)filterRoomsWithString:(NSString *)searchString
|
- (NSArray *)filterRoomsWithString:(NSString *)searchString
|
||||||
|
@ -687,8 +696,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)setNotificationLevelForRoomAtIndexPath:(NSIndexPath *)indexPath
|
- (void)setNotificationLevelForRoomAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
UIAlertController *optionsActionSheet =
|
UIAlertController *optionsActionSheet =
|
||||||
|
@ -731,8 +740,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)shareLinkFromRoomAtIndexPath:(NSIndexPath *)indexPath
|
- (void)shareLinkFromRoomAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
|
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
|
||||||
|
@ -767,8 +776,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)addRoomToFavoritesAtIndexPath:(NSIndexPath *)indexPath
|
- (void)addRoomToFavoritesAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[NCAPIController sharedInstance] addRoomToFavorites:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSError *error) {
|
[[NCAPIController sharedInstance] addRoomToFavorites:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSError *error) {
|
||||||
|
@ -782,8 +791,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)removeRoomFromFavoritesAtIndexPath:(NSIndexPath *)indexPath
|
- (void)removeRoomFromFavoritesAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[NCAPIController sharedInstance] removeRoomFromFavorites:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSError *error) {
|
[[NCAPIController sharedInstance] removeRoomFromFavorites:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSError *error) {
|
||||||
|
@ -797,8 +806,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)presentRoomInfoForRoomAtIndexPath:(NSIndexPath *)indexPath
|
- (void)presentRoomInfoForRoomAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomInfoTableViewController *roomInfoVC = [[RoomInfoTableViewController alloc] initForRoom:room];
|
RoomInfoTableViewController *roomInfoVC = [[RoomInfoTableViewController alloc] initForRoom:room];
|
||||||
|
@ -809,8 +818,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)leaveRoomAtIndexPath:(NSIndexPath *)indexPath
|
- (void)leaveRoomAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
UIAlertController *confirmDialog =
|
UIAlertController *confirmDialog =
|
||||||
|
@ -818,7 +827,7 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
message:NSLocalizedString(@"Once a conversation is left, to rejoin a closed conversation, an invite is needed. An open conversation can be rejoined at any time.", nil)
|
message:NSLocalizedString(@"Once a conversation is left, to rejoin a closed conversation, an invite is needed. An open conversation can be rejoined at any time.", nil)
|
||||||
preferredStyle:UIAlertControllerStyleAlert];
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Leave", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Leave", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
||||||
[_rooms removeObjectAtIndex:indexPath.row];
|
[self->_rooms removeObjectAtIndex:indexPath.row];
|
||||||
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
||||||
[[NCAPIController sharedInstance] removeSelfFromRoom:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSInteger errorCode, NSError *error) {
|
[[NCAPIController sharedInstance] removeSelfFromRoom:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSInteger errorCode, NSError *error) {
|
||||||
if (errorCode == 400) {
|
if (errorCode == 400) {
|
||||||
|
@ -838,8 +847,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)deleteRoomAtIndexPath:(NSIndexPath *)indexPath
|
- (void)deleteRoomAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
UIAlertController *confirmDialog =
|
UIAlertController *confirmDialog =
|
||||||
|
@ -847,7 +856,7 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
message:room.deletionMessage
|
message:room.deletionMessage
|
||||||
preferredStyle:UIAlertControllerStyleAlert];
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Delete", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Delete", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
||||||
[_rooms removeObjectAtIndex:indexPath.row];
|
[self->_rooms removeObjectAtIndex:indexPath.row];
|
||||||
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
||||||
[[NCAPIController sharedInstance] deleteRoom:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSError *error) {
|
[[NCAPIController sharedInstance] deleteRoom:room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -865,8 +874,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (void)presentMoreActionsForRoomAtIndexPath:(NSIndexPath *)indexPath
|
- (void)presentMoreActionsForRoomAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
UIAlertController *optionsActionSheet =
|
UIAlertController *optionsActionSheet =
|
||||||
|
@ -930,8 +939,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
|
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[NCRoomsManager sharedInstance] startChatInRoom:room];
|
[[NCRoomsManager sharedInstance] startChatInRoom:room];
|
||||||
|
@ -1001,8 +1010,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *deleteButtonText = NSLocalizedString(@"Delete", nil);
|
NSString *deleteButtonText = NSLocalizedString(@"Delete", nil);
|
||||||
|
@ -1016,8 +1025,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||||
{
|
{
|
||||||
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (room.isLeavable) {
|
if (room.isLeavable) {
|
||||||
|
@ -1045,8 +1054,8 @@ API_AVAILABLE(ios(11.0)){
|
||||||
deleteAction.image = [UIImage imageNamed:@"delete"];
|
deleteAction.image = [UIImage imageNamed:@"delete"];
|
||||||
|
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (room.isLeavable) {
|
if (room.isLeavable) {
|
||||||
|
@ -1064,8 +1073,8 @@ API_AVAILABLE(ios(11.0)){
|
||||||
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView leadingSwipeActionsConfigurationForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
|
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView leadingSwipeActionsConfigurationForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
|
||||||
API_AVAILABLE(ios(11.0)){
|
API_AVAILABLE(ios(11.0)){
|
||||||
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
NCRoom *room = [_rooms objectAtIndex:indexPath.row];
|
||||||
if (_searchController.active && _resultTableViewController.rooms.count > 0) {
|
if (_searchController.active && _resultTableViewController.hasResults) {
|
||||||
room = [_resultTableViewController.rooms objectAtIndex:indexPath.row];
|
room = [_resultTableViewController roomForIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
UIContextualAction *favoriteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:nil
|
UIContextualAction *favoriteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:nil
|
||||||
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче