Merge pull request #4536 from vector-im/doug/4521_remove_directory_from_rooms_tab

Remove directory section from rooms tab
This commit is contained in:
Doug
2021-07-22 15:02:22 +01:00
committed by GitHub
31 changed files with 12 additions and 354 deletions
+1
View File
@@ -6,6 +6,7 @@ Changes to be released in next version
🙌 Improvements
* Room: Added support for Voice Messages (#4090, #4091, #4092, #4094, #4095, #4096)
* Remove the directory section from the Rooms tab.
🐛 Bugfix
* Room: Fixed mentioning users from room info member details (#4583)
+1 -1
View File
@@ -148,7 +148,7 @@ final class BuildSettings: NSObject {
// MARK: - Public rooms Directory
static let publicRoomsShowDirectory: Bool = true
#warning("Unused build setting: should this be implemented in ShowDirectory?")
static let publicRoomsAllowServerChange: Bool = true
// List of homeservers for the public rooms directory
static let publicRoomsDirectoryServers = [
+2 -38
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="H1p-Uh-vWS">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="H1p-Uh-vWS">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -356,22 +356,6 @@
</objects>
<point key="canvasLocation" x="1223" y="-3899"/>
</scene>
<!--Riot Navigation Controller-->
<scene sceneID="TbB-77-7oK">
<objects>
<navigationController id="qAW-wR-KyU" customClass="RiotNavigationController" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="r5V-3P-3Lg">
<rect key="frame" x="0.0" y="0.0" width="375" height="56"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="mRq-hp-dod" kind="relationship" relationship="rootViewController" id="fqQ-aW-08c"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="T7q-ez-UVO" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3326" y="-2050"/>
</scene>
<!--Contact Details View Controller-->
<scene sceneID="grY-bt-CcD">
<objects>
@@ -479,7 +463,6 @@
</userDefinedRuntimeAttributes>
</tabBarItem>
<connections>
<segue destination="qAW-wR-KyU" kind="presentation" identifier="presentDirectoryServerPicker" id="1mb-Wk-zpt"/>
<segue destination="WDS-Ip-RQ9" kind="presentation" identifier="presentStartChat" id="Tfl-tq-LQp"/>
</connections>
</viewController>
@@ -560,25 +543,6 @@
</objects>
<point key="canvasLocation" x="374" y="449"/>
</scene>
<!--Directory Server Picker View Controller-->
<scene sceneID="t8d-GX-ntZ">
<objects>
<tableViewController storyboardIdentifier="DirectoryServerPickerViewControllerStoryboardId" id="mRq-hp-dod" customClass="DirectoryServerPickerViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="YbK-Rh-uRf">
<rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="mRq-hp-dod" id="71E-8v-wpk"/>
<outlet property="delegate" destination="mRq-hp-dod" id="0Nu-Wt-eJD"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="6vB-s9-qMc"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Q9W-8f-BvC" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="4174" y="-2050"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="Tfl-tq-LQp"/>
-1
View File
@@ -106,7 +106,6 @@
// Room recents
"room_recents_directory_section" = "ДИРЕКТОРИЯ СЪС СТАИ";
"room_creation_invite_another_user" = "Търси потребител по ID, име, имейл";
"room_recents_directory_section_network" = "Мрежа";
"room_recents_favourites_section" = "ЛЮБИМИ";
"room_recents_people_section" = "ХОРА";
"room_recents_conversations_section" = "СТАИ";
-1
View File
@@ -106,7 +106,6 @@
"room_creation_invite_another_user" = "Cerca / convida per l'identificador d'usuari, nom o correu electrònic";
// Room recents
"room_recents_directory_section" = "Directori de Sales";
"room_recents_directory_section_network" = "Xarxa";
"room_recents_favourites_section" = "Favorits";
"room_recents_people_section" = "Contactes";
"room_recents_conversations_section" = "Sales";
-1
View File
@@ -130,7 +130,6 @@
"room_creation_error_invite_user_by_email_without_identity_server" = "Nid oes unrhyw weinydd adnabod wedi'i osod felly ni allwch ychwanegu cyfranogwr gydag e-bost.";
// Room recents
"room_recents_directory_section" = "CYFEIRIADUR YSTAFELLOEDD";
"room_recents_directory_section_network" = "Rhwydwaith";
"room_recents_favourites_section" = "FFEFRYNAU";
"room_recents_people_section" = "POBL";
"room_recents_conversations_section" = "YSTAFELLOEDD";
-1
View File
@@ -79,7 +79,6 @@
"room_creation_wait_for_creation" = "Es wird gerade schon ein Raum erstellt. Bitte warten.";
// Room recents
"room_recents_directory_section" = "RAUM VERZEICHNIS";
"room_recents_directory_section_network" = "Netzwerk";
"room_recents_favourites_section" = "FAVORITEN";
"room_recents_people_section" = "PERSONEN";
"room_recents_conversations_section" = "RÄUME";
-1
View File
@@ -182,7 +182,6 @@
// Room recents
"room_recents_directory_section" = "ROOM DIRECTORY";
"room_recents_directory_section_network" = "Network";
"room_recents_favourites_section" = "FAVOURITES";
"room_recents_people_section" = "PEOPLE";
"room_recents_conversations_section" = "ROOMS";
-1
View File
@@ -244,7 +244,6 @@
"room_recents_server_notice_section" = "SISTEMAJ AVERTOJ";
"room_recents_low_priority_section" = "MALALTA PRIORITATO";
"room_recents_favourites_section" = "ELSTARIGITAJ";
"room_recents_directory_section_network" = "Reto";
// Room recents
"room_recents_directory_section" = "KATALOGO DE ĈAMBROJ";
-1
View File
@@ -144,7 +144,6 @@
"room_creation_invite_another_user" = "Buscar / invitar por ID de Usuario, Nombre o correo electrónico";
// Room recents
"room_recents_directory_section" = "DIRECTORIO DE SALAS";
"room_recents_directory_section_network" = "Red";
"room_recents_favourites_section" = "FAVORITOS";
"room_recents_people_section" = "PERSONAS";
"room_recents_conversations_section" = "SALAS";
-1
View File
@@ -218,7 +218,6 @@
"auth_login_single_sign_on" = "Logi sisse";
// Room recents
"room_recents_directory_section" = "JUTUTUBADE LOEND";
"room_recents_directory_section_network" = "Võrk";
"room_recents_favourites_section" = "LEMMIKUD";
"room_recents_people_section" = "INIMESED";
"room_recents_conversations_section" = "JUTUTOAD";
-1
View File
@@ -238,7 +238,6 @@
"room_creation_invite_another_user" = "Bilatu / gonbidatu erabiltzaile ID-a, izena edo e-maila erabiliz";
// Room recents
"room_recents_directory_section" = "GELEN DIREKTORIOA";
"room_recents_directory_section_network" = "Sarea";
"room_recents_favourites_section" = "GOGOKOAK";
"room_recents_invites_section" = "GONBIDAPENAK";
// People tab
-1
View File
@@ -97,7 +97,6 @@
"room_creation_invite_another_user" = "Rechercher/inviter par identifiant, nom ou e-mail";
// Room recents
"room_recents_directory_section" = "RÉPERTOIRE DES SALONS";
"room_recents_directory_section_network" = "Réseau";
"room_recents_favourites_section" = "FAVORIS";
"room_recents_people_section" = "PERSONNES";
"room_recents_conversations_section" = "SALONS";
-1
View File
@@ -108,7 +108,6 @@
"room_creation_invite_another_user" = "Keresés / meghívás felhasználói azonosítás, név vagy e-mail cím alapján";
// Room recents
"room_recents_directory_section" = "SZOBA KÖNYVTÁR";
"room_recents_directory_section_network" = "Hálózat";
"room_recents_favourites_section" = "KEDVENCEK";
"room_recents_people_section" = "EMBEREK";
"room_recents_conversations_section" = "SZOBÁK";
-1
View File
@@ -63,7 +63,6 @@
"room_creation_appearance_name" = "Heiti";
"room_creation_privacy" = "Meðferð persónuupplýsinga";
"room_creation_make_private" = "Gera einka";
"room_recents_directory_section_network" = "Netkerfi";
"room_recents_favourites_section" = "Eftirlæti";
"room_recents_people_section" = "FÓLK";
"room_recents_conversations_section" = "SPJALLRÁSIR";
-1
View File
@@ -112,7 +112,6 @@
"room_creation_invite_another_user" = "Cerca / invita per ID utente, nome o email";
// Room recents
"room_recents_directory_section" = "ELENCO STANZE";
"room_recents_directory_section_network" = "Rete";
"room_recents_favourites_section" = "PREFERITI";
"room_recents_people_section" = "CHAT DIRETTE";
"room_recents_conversations_section" = "STANZE";
-1
View File
@@ -105,7 +105,6 @@
"room_creation_invite_another_user" = "ユーザID, 表示名, 電子メールで検索と招待";
// Room recents
"room_recents_directory_section" = "ルーム一覧";
"room_recents_directory_section_network" = "通信回線";
"room_recents_favourites_section" = "お気に入り";
"room_recents_people_section" = "対話";
"room_recents_conversations_section" = "ルーム";
-1
View File
@@ -383,7 +383,6 @@
"room_recents_no_conversation" = "Ulac tixxamin";
"room_recents_conversations_section" = "TIXXAMIN";
"room_recents_people_section" = "IMDANEN";
"room_recents_directory_section_network" = "Aẓeṭṭa";
"room_creation_make_private" = "Err-it d uslig";
"room_creation_privacy" = "Tabaḍnit";
"room_creation_appearance_name" = "Isem";
-1
View File
@@ -64,7 +64,6 @@
"room_creation_appearance" = "Utseende";
"room_creation_appearance_name" = "Navn";
"room_creation_privacy" = "Personvern";
"room_recents_directory_section_network" = "Nettverk";
"room_recents_create_empty_room" = "Opprett et rom";
"room_recents_join_room" = "Bli med i rommet";
"room_recents_join_room_title" = "Bli med i et rom";
-1
View File
@@ -112,7 +112,6 @@
"room_creation_invite_another_user" = "Zoeken/uitnodigen met gebruikers-ID, naam of e-mailadres";
// Room recents
"room_recents_directory_section" = "GESPREKSCATALOGUS";
"room_recents_directory_section_network" = "Netwerk";
"room_recents_favourites_section" = "FAVORIETEN";
"room_recents_people_section" = "PERSONEN";
"room_recents_conversations_section" = "GESPREKKEN";
-1
View File
@@ -86,7 +86,6 @@
"room_creation_appearance" = "Wygląd";
"room_creation_appearance_name" = "Nazwa";
"room_creation_privacy" = "Prywatność";
"room_recents_directory_section_network" = "Sieć";
"room_recents_favourites_section" = "ULUBIONE";
"room_recents_people_section" = "OSOBY";
"room_recents_conversations_section" = "POKOJE";
-1
View File
@@ -101,7 +101,6 @@
"room_creation_make_private" = "Fazer privado";
"room_creation_wait_for_creation" = "Uma sala já está sendo criada. Por favor espere.";
"room_creation_invite_another_user" = "Buscar / convidar por ID de usuária(o), Nome ou email";
"room_recents_directory_section_network" = "Rede";
"room_recents_favourites_section" = "FAVORITOS";
"room_recents_people_section" = "PESSOAS";
"room_recents_conversations_section" = "SALAS";
-1
View File
@@ -98,7 +98,6 @@
"room_creation_invite_another_user" = "Поиск / приглашение по идентификатору пользователя, имени или адресу электронной почты";
// Room recents
"room_recents_directory_section" = "КАТАЛОГ КОМНАТ";
"room_recents_directory_section_network" = "Сеть";
"room_recents_favourites_section" = "ИЗБРАННЫЕ";
"room_recents_people_section" = "ЛЮДИ";
"room_recents_conversations_section" = "КОМНАТЫ";
-1
View File
@@ -84,7 +84,6 @@
"room_creation_make_private" = "Bëje private";
// Room recents
"room_recents_directory_section" = "DREJTORI DHOMASH";
"room_recents_directory_section_network" = "Rrjet";
"room_recents_people_section" = "PERSONA";
"room_recents_conversations_section" = "DHOMA";
"room_recents_no_conversation" = "Ska dhoma";
-1
View File
@@ -100,7 +100,6 @@
"room_creation_make_private" = "Gör privat";
"room_creation_wait_for_creation" = "Ett rum håller redan på att skapas. Vänligen vänta.";
"room_creation_invite_another_user" = "Sök / bjud in efter användar-ID, namn eller e-postadress";
"room_recents_directory_section_network" = "Nätverk";
"room_recents_favourites_section" = "FAVORITER";
"room_recents_people_section" = "PERSONER";
"room_recents_conversations_section" = "RUM";
-1
View File
@@ -105,7 +105,6 @@
"room_creation_invite_another_user" = "Tìm / mời bằng ID người dùng, tên hoặc email";
// Room recents
"room_recents_directory_section" = "DANH MỤC PHÒNG";
"room_recents_directory_section_network" = "Mạng";
"room_recents_favourites_section" = "YÊU THÍCH";
"room_recents_people_section" = "DANH BẠ";
"room_recents_conversations_section" = "PHÒNG";
-1
View File
@@ -96,7 +96,6 @@
"room_creation_invite_another_user" = "通过用户 ID、名称或电子邮件进行搜索/邀请";
// Room recents
"room_recents_directory_section" = "聊天室目录";
"room_recents_directory_section_network" = "网络";
"room_recents_favourites_section" = "收藏夹";
"room_recents_people_section" = "联系人";
"room_recents_conversations_section" = "聊天室";
-1
View File
@@ -184,7 +184,6 @@
"room_creation_invite_another_user" = "透過使用者ID、名稱、電子郵件地址來搜尋/邀請";
// Room recents
"room_recents_directory_section" = "聊天室目錄";
"room_recents_directory_section_network" = "網路";
"room_recents_favourites_section" = "收藏夾";
"room_recents_people_section" = "聯絡人";
"room_recents_conversations_section" = "聊天室";
-4
View File
@@ -3358,10 +3358,6 @@ internal enum VectorL10n {
internal static var roomRecentsDirectorySection: String {
return VectorL10n.tr("Vector", "room_recents_directory_section")
}
/// Network
internal static var roomRecentsDirectorySectionNetwork: String {
return VectorL10n.tr("Vector", "room_recents_directory_section_network")
}
/// FAVOURITES
internal static var roomRecentsFavouritesSection: String {
return VectorL10n.tr("Vector", "room_recents_favourites_section")
@@ -19,7 +19,6 @@
#import "RecentCellData.h"
#import "SectionHeaderView.h"
#import "DirectorySectionHeaderContainerView.h"
#import "ThemeService.h"
@@ -37,7 +36,6 @@
#define RECENTSDATASOURCE_SECTION_PEOPLE 0x40
#define RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT 30.0
#define RECENTSDATASOURCE_DIRECTORY_SECTION_HEADER_HEIGHT 65.0
NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSourceTapOnDirectoryServerChange";
@@ -48,10 +46,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
NSInteger shrinkedSectionsBitMask;
DirectorySectionHeaderContainerView *directorySectionContainer;
UILabel *networkLabel;
UILabel *directoryServerLabel;
NSMutableDictionary<NSString*, id> *roomTagsListenerByUserId;
// Timer to not refresh publicRoomsDirectoryDataSource on every keystroke.
@@ -483,13 +477,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
conversationSection = sectionsCount++;
}
if (_recentsDataSourceMode == RecentsDataSourceModeRooms
&& BuildSettings.publicRoomsShowDirectory)
{
// Add the directory section after "ROOMS"
directorySection = sectionsCount++;
}
if (self.lowPriorityCellDataArray.count > 0)
{
lowPrioritySection = sectionsCount++;
@@ -572,12 +559,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
{
return 0.0;
}
else if (section == directorySection
&& !(shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_DIRECTORY)
&& BuildSettings.publicRoomsAllowServerChange)
{
return RECENTSDATASOURCE_DIRECTORY_SECTION_HEADER_HEIGHT;
}
return RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT;
}
@@ -823,57 +804,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
[sectionHeader addSubview:headerLabel];
sectionHeader.headerLabel = headerLabel;
if (section == directorySection
&& _recentsDataSourceMode == RecentsDataSourceModeRooms
&& !(shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_DIRECTORY)
&& BuildSettings.publicRoomsAllowServerChange)
{
if (!directorySectionContainer)
{
directorySectionContainer = [[DirectorySectionHeaderContainerView alloc] initWithFrame:CGRectZero];
directorySectionContainer.backgroundColor = [UIColor clearColor];
// Add the "Network" label at the left
networkLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
networkLabel.font = [UIFont systemFontOfSize:16.0];
networkLabel.text = NSLocalizedStringFromTable(@"room_recents_directory_section_network", @"Vector", nil);
[directorySectionContainer addSubview:networkLabel];
directorySectionContainer.networkLabel = networkLabel;
// Add label for selected directory server
directoryServerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 30)];
directoryServerLabel.font = [UIFont systemFontOfSize:16.0];
directoryServerLabel.textAlignment = NSTextAlignmentRight;
[directorySectionContainer addSubview:directoryServerLabel];
directorySectionContainer.directoryServerLabel = directoryServerLabel;
// Chevron
UIImageView *chevronImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 6, 12)];
chevronImageView.contentMode = UIViewContentModeScaleAspectFit;
chevronImageView.image = [UIImage imageNamed:@"disclosure_icon"];
chevronImageView.tintColor = ThemeService.shared.theme.textSecondaryColor;
[directorySectionContainer addSubview:chevronImageView];
directorySectionContainer.disclosureView = chevronImageView;
// Set a tap listener on all the container
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onDirectoryServerPickerTap:)];
[tapGesture setNumberOfTouchesRequired:1];
[tapGesture setNumberOfTapsRequired:1];
[directorySectionContainer addGestureRecognizer:tapGesture];
}
// Apply the current UI theme.
networkLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
directoryServerLabel.textColor = ThemeService.shared.theme.textSecondaryColor;
// Set the current directory server name
directoryServerLabel.text = _publicRoomsDirectoryDataSource.directoryServerDisplayname;
// Add the check box container
[sectionHeader addSubview:directorySectionContainer];
sectionHeader.bottomView = directorySectionContainer;
}
return sectionHeader;
}
+8 -216
View File
@@ -18,16 +18,11 @@
#import "RecentsDataSource.h"
#import "DirectoryServerPickerViewController.h"
#import "Riot-Swift.h"
@interface RoomsViewController ()
{
RecentsDataSource *recentsDataSource;
// The animated view displayed at the table view bottom when paginating the room directory
UIView* footerSpinnerView;
}
@end
@@ -63,8 +58,6 @@
plusButtonImageView = [self vc_addFABWithImage:[UIImage imageNamed:@"rooms_floating_action"]
target:self
action:@selector(onPlusButtonPressed)];
self.enableStickyHeaders = YES;
}
- (void)viewWillAppear:(BOOL)animated
@@ -74,24 +67,12 @@
[AppDelegate theDelegate].masterTabBarController.navigationItem.title = NSLocalizedStringFromTable(@"title_rooms", @"Vector", nil);
[AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor;
// TODO: Notify RiotSettings.shared.showNSFWPublicRooms change for iPad as viewWillAppear may not be called
recentsDataSource.publicRoomsDirectoryDataSource.showNSFWRooms = RiotSettings.shared.showNSFWPublicRooms;
if ([self.dataSource isKindOfClass:RecentsDataSource.class])
{
BOOL isFirstTime = (recentsDataSource != self.dataSource);
// Take the lead on the shared data source.
recentsDataSource = (RecentsDataSource*)self.dataSource;
recentsDataSource.areSectionsShrinkable = NO;
[recentsDataSource setDelegate:self andRecentsDataSourceMode:RecentsDataSourceModeRooms];
if (isFirstTime)
{
// The first time the screen is displayed, make publicRoomsDirectoryDataSource
// start loading data
[recentsDataSource.publicRoomsDirectoryDataSource paginate:nil failure:nil];
}
}
}
@@ -113,32 +94,19 @@
[super refreshCurrentSelectedCell:forceVisible];
}
- (UIView *)tableView:(UITableView *)tableView viewForStickyHeaderInSection:(NSInteger)section
{
CGRect frame = [tableView rectForHeaderInSection:section];
frame.size.height = self.stickyHeaderHeight;
return [recentsDataSource viewForHeaderInSection:section withFrame:frame];
}
- (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)actionIdentifier inCell:(id<MXKCellRendering>)cell userInfo:(NSDictionary *)userInfo
{
if ([actionIdentifier isEqualToString:kRecentsDataSourceTapOnDirectoryServerChange])
{
// Show the directory server picker
[self performSegueWithIdentifier:@"presentDirectoryServerPicker" sender:self];
}
else
{
[super dataSource:dataSource didRecognizeAction:actionIdentifier inCell:cell userInfo:userInfo];
}
}
- (void)onPlusButtonPressed
{
[self showRoomDirectory];
}
#pragma mark - UITableView delegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
// Hide the header to merge Invites and Rooms into a single list.
return 0.0;
}
#pragma mark -
- (void)scrollToNextRoomWithMissedNotifications
@@ -150,181 +118,6 @@
}
}
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
[super prepareForSegue:segue sender:sender];
UIViewController *pushedViewController = [segue destinationViewController];
if ([[segue identifier] isEqualToString:@"presentDirectoryServerPicker"])
{
UINavigationController *pushedNavigationViewController = (UINavigationController*)pushedViewController;
DirectoryServerPickerViewController* directoryServerPickerViewController = (DirectoryServerPickerViewController*)pushedNavigationViewController.viewControllers.firstObject;
MXKDirectoryServersDataSource *directoryServersDataSource = [[MXKDirectoryServersDataSource alloc] initWithMatrixSession:recentsDataSource.publicRoomsDirectoryDataSource.mxSession];
[directoryServersDataSource finalizeInitialization];
// Add directory servers from the app settings
directoryServersDataSource.roomDirectoryServers = BuildSettings.publicRoomsDirectoryServers;
__weak typeof(self) weakSelf = self;
[directoryServerPickerViewController displayWithDataSource:directoryServersDataSource onComplete:^(id<MXKDirectoryServerCellDataStoring> cellData) {
if (weakSelf && cellData)
{
typeof(self) self = weakSelf;
// Use the selected directory server
if (cellData.thirdPartyProtocolInstance)
{
self->recentsDataSource.publicRoomsDirectoryDataSource.thirdpartyProtocolInstance = cellData.thirdPartyProtocolInstance;
}
else if (cellData.homeserver)
{
self->recentsDataSource.publicRoomsDirectoryDataSource.includeAllNetworks = cellData.includeAllNetworks;
self->recentsDataSource.publicRoomsDirectoryDataSource.homeserver = cellData.homeserver;
}
// Refresh data
[self addSpinnerFooterView];
[self->recentsDataSource.publicRoomsDirectoryDataSource paginate:^(NSUInteger roomsAdded) {
if (weakSelf)
{
typeof(self) self = weakSelf;
// The table view is automatically filled
[self removeSpinnerFooterView];
// Make the directory section appear full-page
[self.recentsTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:self->recentsDataSource.directorySection] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
} failure:^(NSError *error) {
if (weakSelf)
{
typeof(self) self = weakSelf;
[self removeSpinnerFooterView];
}
}];
}
}];
// Hide back button title
pushedViewController.navigationController.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}
}
#pragma mark - UITableView delegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == recentsDataSource.directorySection)
{
// Let the recents dataSource provide the height of this section header
return [recentsDataSource heightForHeaderInSection:section];
}
return [super tableView:tableView heightForHeaderInSection:section];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == recentsDataSource.directorySection)
{
// Sanity check
MXPublicRoom *publicRoom = [recentsDataSource.publicRoomsDirectoryDataSource roomAtIndexPath:indexPath];
if (publicRoom)
{
[self openPublicRoomAtIndexPath:indexPath];
}
}
else
{
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// Trigger inconspicuous pagination on directy when user scrolls down
if ((scrollView.contentSize.height - scrollView.contentOffset.y - scrollView.frame.size.height) < 300)
{
[self triggerDirectoryPagination];
}
[super scrollViewDidScroll:scrollView];
}
#pragma mark - Private methods
- (void)openPublicRoomAtIndexPath:(NSIndexPath *)indexPath
{
MXPublicRoom *publicRoom = [recentsDataSource.publicRoomsDirectoryDataSource roomAtIndexPath:indexPath];
[self openPublicRoom:publicRoom];
}
- (void)triggerDirectoryPagination
{
if (!recentsDataSource
|| recentsDataSource.state == MXKDataSourceStateUnknown
|| recentsDataSource.publicRoomsDirectoryDataSource.hasReachedPaginationEnd
|| footerSpinnerView)
{
// We are not yet ready or being killed or we got all public rooms or we are already paginating
// Do nothing
return;
}
[self addSpinnerFooterView];
[recentsDataSource.publicRoomsDirectoryDataSource paginate:^(NSUInteger roomsAdded) {
// The table view is automatically filled
[self removeSpinnerFooterView];
} failure:^(NSError *error) {
[self removeSpinnerFooterView];
}];
}
- (void)addSpinnerFooterView
{
if (!footerSpinnerView)
{
UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.transform = CGAffineTransformMakeScale(0.75f, 0.75f);
CGRect frame = spinner.frame;
frame.size.height = 80; // 80 * 0.75 = 60
spinner.bounds = frame;
spinner.color = [UIColor darkGrayColor];
spinner.hidesWhenStopped = NO;
spinner.backgroundColor = [UIColor clearColor];
[spinner startAnimating];
// No need to manage constraints here, iOS defines them
self.recentsTableView.tableFooterView = footerSpinnerView = spinner;
}
}
- (void)removeSpinnerFooterView
{
if (footerSpinnerView)
{
footerSpinnerView = nil;
// Hide line separators of empty cells
self.recentsTableView.tableFooterView = [[UIView alloc] init];;
}
}
#pragma mark - Empty view management
- (void)updateEmptyView
@@ -362,7 +155,6 @@
- (NSUInteger)totalItemCounts
{
return recentsDataSource.conversationCellDataArray.count
+ recentsDataSource.publicRoomsDirectoryDataSource.roomsCount
+ recentsDataSource.invitesCellDataArray.count;
}