Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Tchap architecture with the Element one, and plug the rooms list to the rooms fetchers #484

Merged
merged 14 commits into from
Mar 30, 2022
Merged
6 changes: 3 additions & 3 deletions Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ final class BuildSettings: NSObject {

// MARK: - Main Tabs

static let homeScreenShowFavouritesTab: Bool = true
static let homeScreenShowPeopleTab: Bool = true
static let homeScreenShowFavouritesTab: Bool = false
static let homeScreenShowPeopleTab: Bool = false
static let homeScreenShowRoomsTab: Bool = true
static let homeScreenShowCommunitiesTab: Bool = true
static let homeScreenShowCommunitiesTab: Bool = false

// MARK: - General Settings Screen

Expand Down
25 changes: 19 additions & 6 deletions Btchap/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ targets:
- "Config/BuildSettings.swift"
- "Generated/InfoPlist.swift"
- "Generated/TchapDefaults.swift"
- "Modules/Application"
- "Modules/Common/ActivityIndicator"
- "Modules/Room/EmojiPicker/Data/EmojiMart/EmojiJSONStore.swift"
- "Modules/Room/Views/Title/RoomTitleView.*"
- "Modules/Room/RoomCoordinator.swift"
Expand All @@ -86,15 +88,18 @@ targets:
- "Modules/Room/Views/InputToolbar/RoomInputToolbarView.*"
- "Modules/Room/Views/Preview"
- "Modules/Room/Views/Title/RoomTitleView.*"
- "Modules/Rooms"
- "SupportingFiles/Info.plist"
- "TchapTools"
- "Routers"
- "Managers/AppVersion/AppVersion.swift"
- "Managers/UniversalLink"
- "**/*.strings" # Exclude all strings files
- "**/*.cer"
- path: ../Tchap/Modules/Application/VersionUpdate
- path: ../Tchap/Generated/Images_Riot.swift
- path: ../Tchap/Modules/Room/Views/BubbleCells/Antivirus
- path: ../Tchap/Modules/Rooms/Views

# Add separately localizable files
- path: ../Tchap/Assets/Localizations/fr.lproj/Tchap.strings
Expand All @@ -118,6 +123,7 @@ targets:
- path: ../Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift
- path: ../Riot/Managers/KeyValueStorage
- path: ../Riot/Managers/Locale
- path: ../Riot/Managers/Logging
- path: ../Riot/Managers/Room/RoomIdComponents.swift
- path: ../Riot/Managers/RoomMessageLinkParser/RoomMessageURLParser.swift
- path: ../Riot/Managers/PasswordStrength
Expand All @@ -137,7 +143,7 @@ targets:
- path: ../Riot/Model/Room/RoomPreviewData.m
- path: ../Riot/Model/WellKnown
- path: ../Riot/Modules/Analytics
- path: ../Riot/Modules/Application/ScreenNavigation
- path: ../Riot/Modules/Application
- path: ../Riot/Modules/Authentication/SSO
- path: ../Riot/Modules/Authentication/Views
- path: ../Riot/Modules/BadgeLabel
Expand All @@ -150,23 +156,22 @@ targets:
- path: ../Riot/Modules/Call/Views/IncomingCallView.h
- path: ../Riot/Modules/Call/Views/IncomingCallView.m
- path: ../Riot/Modules/Camera
- path: ../Riot/Modules/Common/ActivityIndicator
- path: ../Riot/Modules/Common/Avatar
- path: ../Riot/Modules/Common/Buttons
- path: ../Riot/Modules/Common/Cells
- path: ../Riot/Modules/Common/CollectionView
- path: ../Riot/Modules/Common/Models
- path: ../Riot/Modules/Common/NavigationController/RiotNavigationController.h
- path: ../Riot/Modules/Common/NavigationController/RiotNavigationController.m
- path: ../Riot/Modules/Common/Recents/DataSources
- path: ../Riot/Modules/Common/Recents/Model/RecentCellData.h
- path: ../Riot/Modules/Common/Recents/Model/RecentCellData.m
- path: ../Riot/Modules/Common/Recents/RecentsViewController.h
- path: ../Riot/Modules/Common/Recents/RecentsViewController.m
- path: ../Riot/Modules/Common/Recents/Model
- path: ../Riot/Modules/Common/Recents/Service
- path: ../Riot/Modules/Common/Recents/Views
excludes:
- "RecentTableViewCell.h"
- "RecentTableViewCell.m"
- "RecentTableViewCell.xib"
- path: ../Riot/Modules/Common/SectionHeaders
- path: ../Riot/Modules/Common/SegmentedViewController/SegmentedViewController.h
- path: ../Riot/Modules/Common/SegmentedViewController/SegmentedViewController.m
Expand All @@ -189,8 +194,10 @@ targets:
- path: ../Riot/Modules/Integrations
- path: ../Riot/Modules/KeyBackup
- path: ../Riot/Modules/KeyVerification
- path: ../Riot/Modules/LaunchLoading
- path: ../Riot/Modules/MatrixKit
- path: ../Riot/Modules/MediaPicker
- path: ../Riot/Modules/PublicRoomList
- path: ../Riot/Modules/QRCode
- path: ../Riot/Modules/Reauthentication
- path: ../Riot/Modules/Room
Expand All @@ -208,11 +215,15 @@ targets:
- "Views/Title/Thread"
- path: ../Riot/Modules/RoomKeyRequest/RoomKeyRequestViewController.h
- path: ../Riot/Modules/RoomKeyRequest/RoomKeyRequestViewController.m
- path: ../Riot/Modules/Rooms
- path: ../Riot/Modules/Secrets
- path: ../Riot/Modules/SecureBackup
- path: ../Riot/Modules/ServiceTerms
- path: ../Riot/Modules/SideMenu
- path: ../Riot/Modules/SlidingModal
- path: ../Riot/Modules/TabBar/MainTitleView.swift
- path: ../Riot/Modules/SplitView
- path: ../Riot/Modules/TabBar
- path: ../Riot/Modules/User/Avatar
- path: ../Riot/Modules/UserDevices/UsersDevicesViewController.h
- path: ../Riot/Modules/UserDevices/UsersDevicesViewController.m
- path: ../Riot/Modules/UserDevices/Views/DeviceTableViewCell.h
Expand All @@ -224,6 +235,8 @@ targets:

# Riot SwiftUI
- path: ../RiotSwiftUI/Modules/Common/Avatar/Model/AvatarProtocol.swift
- path: ../RiotSwiftUI/Modules/Common/Logging
- path: ../RiotSwiftUI/Modules/Common/Theme
- path: ../RiotSwiftUI/Modules/Room/NotificationSettings/Model

# Share extension
Expand Down
10 changes: 5 additions & 5 deletions Riot/Assets/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" 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="20037" 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="19519"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -343,7 +343,7 @@
<!--Placeholder Detail View Controller-->
<scene sceneID="2wP-Cu-Wca">
<objects>
<viewController storyboardIdentifier="EmptyDetailsViewControllerStoryboardId" id="Cpr-Tz-Az0" customClass="PlaceholderDetailViewController" customModule="Riot" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="EmptyDetailsViewControllerStoryboardId" id="Cpr-Tz-Az0" customClass="PlaceholderDetailViewController" customModule="Btchap" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="yS4-RU-AsN"/>
<viewControllerLayoutGuide type="bottom" id="VKG-pW-vMU"/>
Expand All @@ -352,7 +352,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launch_screen_logo" translatesAutoresizingMaskIntoConstraints="NO" id="6LG-qc-7jf">
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launch_screen_logo" translatesAutoresizingMaskIntoConstraints="NO" id="6LG-qc-7jf">
<rect key="frame" x="127.5" y="273.5" width="120" height="120"/>
<constraints>
<constraint firstAttribute="width" secondItem="6LG-qc-7jf" secondAttribute="height" multiplier="1:1" id="4Qy-7P-CuE"/>
Expand Down Expand Up @@ -478,7 +478,7 @@
<!--Thread-->
<scene sceneID="Opl-gU-pwm">
<objects>
<viewController storyboardIdentifier="ThreadViewControllerStoryboardId" title="Room" hidesBottomBarWhenPushed="YES" id="R2h-H9-hdJ" userLabel="Thread" customClass="ThreadViewController" customModule="Riot" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="ThreadViewControllerStoryboardId" title="Room" hidesBottomBarWhenPushed="YES" id="R2h-H9-hdJ" userLabel="Thread" customClass="ThreadViewController" customModule="Btchap" customModuleProvider="target" sceneMemberID="viewController">
<navigationItem key="navigationItem" id="TFF-nx-BSb">
<nil key="title"/>
<view key="titleView" contentMode="scaleToFill" id="e4J-vI-jzo" userLabel="Room title view container">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "side_menu_notif_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "side_menu_notif_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "side_menu_notif_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Riot/Model/Room/RoomPreviewData.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
*/
@property (nonatomic, readonly) RoomDataSource *roomDataSource;

/**
Contructors.

@param roomId the id of the room.
@param mxSession the session to open the room preview with.
*/
- (instancetype)initWithRoomId:(NSString*)roomId andSession:(MXSession*)mxSession;

/**
Contructors.

Expand Down
12 changes: 12 additions & 0 deletions Riot/Model/Room/RoomPreviewData.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@

@implementation RoomPreviewData

- (instancetype)initWithRoomId:(NSString *)roomId andSession:(MXSession *)mxSession
{
self = [super init];
if (self)
{
_roomId = roomId;
_mxSession = mxSession;
_numJoinedMembers = -1;
}
return self;
}

- (instancetype)initWithRoomId:(NSString *)roomId roomAlias:(NSString*)roomAlias andSession:(MXSession *)mxSession
{
self = [super init];
Expand Down
60 changes: 59 additions & 1 deletion Riot/Modules/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
fileprivate let legacyAppDelegate: LegacyAppDelegate = AppDelegate.theDelegate()
// swiftlint:enable weak_delegate

private let appVersionCheckerStore: AppVersionCheckerStoreType
private let appVersionChecker: AppVersionChecker
private var pendingCheckAppVersionOperation: MXHTTPOperation?
private weak var appVersionUpdateCoordinator: AppVersionUpdateCoordinatorType?

private lazy var appNavigator: AppNavigatorProtocol = {
return AppNavigator(appCoordinator: self)
}()
Expand Down Expand Up @@ -72,6 +77,11 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
self.customSchemeURLParser = CustomSchemeURLParser()
self.userSessionsService = UserSessionsService.shared

let clientConfigurationService = ClientConfigurationService()
let appVersionCheckerStore = AppVersionCheckerStore()
self.appVersionChecker = AppVersionChecker(clientConfigurationService: clientConfigurationService, appVersionCheckerStore: appVersionCheckerStore)
self.appVersionCheckerStore = appVersionCheckerStore

super.init()

setupFlexDebuggerOnWindow(window)
Expand Down Expand Up @@ -108,6 +118,23 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
return false
}
}

func checkMinAppVersionRequirements() {
guard self.pendingCheckAppVersionOperation == nil else {
return
}

self.pendingCheckAppVersionOperation = self.appVersionChecker.checkCurrentAppVersion { (versionResult) in
switch versionResult {
case .upToDate, .unknown:
break
case .shouldUpdate(versionInfo: let versionInfo):
MXLog.debug("[AppCoordinator] App should be upated with \(versionInfo)")
self.presentApplicationUpdate(with: versionInfo)
}
self.pendingCheckAppVersionOperation = nil
}
}

// MARK: - Private methods
private func setupLogger() {
Expand Down Expand Up @@ -230,11 +257,42 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
// Reload split view with selected space id
self.splitViewCoordinator?.start(with: spaceId)
}

private func presentApplicationUpdate(with versionInfo: ClientVersionInfo) {
guard self.appVersionUpdateCoordinator == nil else {
MXLog.debug("[AppCoordinor] AppVersionUpdateCoordinator already presented")
return
}

// Update should be display once and has already been dislayed, do not display again
if versionInfo.displayOnlyOnce && self.appVersionChecker.isClientVersionInfoAlreadyDisplayed(versionInfo) {
MXLog.debug("[AppCoordinor] AppVersionUpdateCoordinator already presented for versionInfo: \(versionInfo)")
return
} else if versionInfo.allowOpeningApp && self.appVersionChecker.isClientVersionInfoAlreadyDisplayedToday(versionInfo) {
MXLog.debug("[AppCoordinor] AppVersionUpdateCoordinator already presented today for versionInfo: \(versionInfo)")
return
}

let appVersionUpdateCoordinator = AppVersionUpdateCoordinator(rootRouter: self.rootRouter, versionInfo: versionInfo)
appVersionUpdateCoordinator.delegate = self
appVersionUpdateCoordinator.start()
self.add(childCoordinator: appVersionUpdateCoordinator)
self.appVersionUpdateCoordinator = appVersionUpdateCoordinator

self.appVersionCheckerStore.saveLastDisplayedClientVersionInfo(versionInfo)
self.appVersionCheckerStore.saveLastDisplayedClientVersionDate(Calendar.current.startOfDay(for: Date()))
}
}

// MARK: - AppVersionUpdateCoordinatorDelegate
extension AppCoordinator: AppVersionUpdateCoordinatorDelegate {
func appVersionUpdateCoordinatorDidCancel(_ coordinator: AppVersionUpdateCoordinatorType) {
self.remove(childCoordinator: coordinator)
}
}

// MARK: - LegacyAppDelegateDelegate
extension AppCoordinator: LegacyAppDelegateDelegate {

func legacyAppDelegate(_ legacyAppDelegate: LegacyAppDelegate!, wantsToPopToHomeViewControllerAnimated animated: Bool, completion: (() -> Void)!) {

MXLog.debug("[AppCoordinator] wantsToPopToHomeViewControllerAnimated")
Expand Down
3 changes: 3 additions & 0 deletions Riot/Modules/Application/AppCoordinatorType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ import Foundation
protocol AppCoordinatorType: Coordinator {

func open(url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool

/// Check if the user should be notified of an application update.
func checkMinAppVersionRequirements()
}
3 changes: 3 additions & 0 deletions Riot/Modules/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func applicationDidBecomeActive(_ application: UIApplication) {
self.legacyAppDelegate.applicationDidBecomeActive(application)

self.appCoordinator.checkMinAppVersionRequirements()
}

func applicationWillResignActive(_ application: UIApplication) {
Expand Down Expand Up @@ -106,6 +108,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// MARK: User Activity Continuation

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// return self.appCoordinator.handleUserActivity(userActivity, application: application)
return self.legacyAppDelegate.application(application, continue: userActivity, restorationHandler: restorationHandler)
}

Expand Down
Loading