Expand all if and guard constructs involving @available(iOS 14... or #available(iOS 14...

Signed-off-by: Johannes Marbach <johannesm@element.io>
This commit is contained in:
Johannes Marbach
2022-06-23 09:13:10 +02:00
parent 868fd7e0c8
commit ce4c8b186c
21 changed files with 113 additions and 468 deletions

View File

@@ -398,13 +398,7 @@ final class BuildSettings: NSObject {
// MARK: - Polls
static var pollsEnabled: Bool {
guard #available(iOS 14, *) else {
return false
}
return true
}
static let pollsEnabled = true
// MARK: - Location Sharing

View File

@@ -119,21 +119,20 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
private func setupTheme() {
ThemeService.shared().themeId = RiotSettings.shared.userInterfaceTheme
if #available(iOS 14.0, *) {
// Set theme id from current theme.identifier, themeId can be nil.
if let themeId = ThemeIdentifier(rawValue: ThemeService.shared().theme.identifier) {
ThemePublisher.configure(themeId: themeId)
} else {
MXLog.error("[AppCoordinator] No theme id found to update ThemePublisher")
}
// Always republish theme change events, and again always getting the identifier from the theme.
let themeIdPublisher = NotificationCenter.default.publisher(for: Notification.Name.themeServiceDidChangeTheme)
.compactMap({ _ in ThemeIdentifier(rawValue: ThemeService.shared().theme.identifier) })
.eraseToAnyPublisher()
ThemePublisher.shared.republish(themeIdPublisher: themeIdPublisher)
// Set theme id from current theme.identifier, themeId can be nil.
if let themeId = ThemeIdentifier(rawValue: ThemeService.shared().theme.identifier) {
ThemePublisher.configure(themeId: themeId)
} else {
MXLog.error("[AppCoordinator] No theme id found to update ThemePublisher")
}
// Always republish theme change events, and again always getting the identifier from the theme.
let themeIdPublisher = NotificationCenter.default.publisher(for: Notification.Name.themeServiceDidChangeTheme)
.compactMap({ _ in ThemeIdentifier(rawValue: ThemeService.shared().theme.identifier) })
.eraseToAnyPublisher()
ThemePublisher.shared.republish(themeIdPublisher: themeIdPublisher)
}
private func excludeAllItemsFromBackup() {

View File

@@ -476,11 +476,9 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
self.pushNotificationService.delegate = self;
self.spaceFeatureUnavailablePresenter = [SpaceFeatureUnavailablePresenter new];
if (@available(iOS 14.0, *)) {
self.uisiAutoReporter = [[UISIAutoReporter alloc] init];
}
self.uisiAutoReporter = [[UISIAutoReporter alloc] init];
// Add matrix observers, and initialize matrix sessions if the app is not launched in background.
[self initMatrixSessions];
@@ -2022,11 +2020,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
// register the session to the uisi auto-reporter
if (_uisiAutoReporter != nil)
{
if (@available(iOS 14.0, *))
{
UISIAutoReporter* uisiAutoReporter = (UISIAutoReporter*)_uisiAutoReporter;
[uisiAutoReporter add:mxSession];
}
UISIAutoReporter* uisiAutoReporter = (UISIAutoReporter*)_uisiAutoReporter;
[uisiAutoReporter add:mxSession];
}
[mxSessionArray addObject:mxSession];
@@ -2048,11 +2043,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
// register the session to the uisi auto-reporter
if (_uisiAutoReporter != nil)
{
if (@available(iOS 14.0, *))
{
UISIAutoReporter* uisiAutoReporter = (UISIAutoReporter*)_uisiAutoReporter;
[uisiAutoReporter remove:mxSession];
}
UISIAutoReporter* uisiAutoReporter = (UISIAutoReporter*)_uisiAutoReporter;
[uisiAutoReporter remove:mxSession];
}
// Update the widgets manager

View File

@@ -104,13 +104,7 @@ class RoomActionProvider: RoomActionProviderProtocol {
}
private var leaveAction: UIAction {
let image: UIImage?
if #available(iOS 14.0, *) {
image = UIImage(systemName: "rectangle.righthalf.inset.fill.arrow.right")
} else {
image = UIImage(systemName: "rectangle.xmark")
}
let image = UIImage(systemName: "rectangle.righthalf.inset.fill.arrow.right")
let action = UIAction(title: VectorL10n.homeContextMenuLeave, image: image) { [weak self] action in
guard let self = self else { return }
self.service.leaveRoom(promptUser: true)

View File

@@ -75,7 +75,7 @@ final class CreateRoomCoordinator: CreateRoomCoordinatorType {
self.add(childCoordinator: createRoomCoordinator)
if let parentSpace = self.parentSpace, #available(iOS 14, *) {
if let parentSpace = self.parentSpace {
let roomSelectionCoordinator = self.createRoomSelectorCoordinator(parentSpace: parentSpace)
roomSelectionCoordinator.completion = { [weak self] result in
guard let self = self else {

View File

@@ -88,9 +88,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
self.roomViewController.parentSpaceId = parameters.parentSpaceId
if #available(iOS 14, *) {
TimelinePollProvider.shared.session = parameters.session
}
TimelinePollProvider.shared.session = parameters.session
super.init()
}
@@ -331,10 +329,6 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
}
private func showLocationCoordinatorWithEvent(_ event: MXEvent, bubbleData: MXKRoomBubbleCellDataStoring) {
guard #available(iOS 14.0, *) else {
return
}
guard let navigationRouter = self.navigationRouter,
let mediaManager = mxSession?.mediaManager,
let locationContent = event.location else {
@@ -377,10 +371,6 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
}
private func startLocationCoordinator() {
guard #available(iOS 14.0, *) else {
return
}
guard let navigationRouter = self.navigationRouter,
let mediaManager = mxSession?.mediaManager,
let user = mxSession?.myUser else {
@@ -414,10 +404,6 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
}
private func startEditPollCoordinator(startEvent: MXEvent? = nil) {
guard #available(iOS 14.0, *) else {
return
}
let parameters = PollEditFormCoordinatorParameters(room: roomViewController.roomDataSource.room, pollStartEvent: startEvent)
let coordinator = PollEditFormCoordinator(parameters: parameters)
@@ -562,26 +548,14 @@ extension RoomCoordinator: RoomViewControllerDelegate {
}
func roomViewController(_ roomViewController: RoomViewController, canEndPollWithEventIdentifier eventIdentifier: String) -> Bool {
guard #available(iOS 14.0, *) else {
return false
}
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEndPoll() ?? false
}
func roomViewController(_ roomViewController: RoomViewController, endPollWithEventIdentifier eventIdentifier: String) {
guard #available(iOS 14.0, *) else {
return
}
TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.endPoll()
}
func roomViewController(_ roomViewController: RoomViewController, canEditPollWithEventIdentifier eventIdentifier: String) -> Bool {
guard #available(iOS 14.0, *) else {
return false
}
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEditPoll() ?? false
}

View File

@@ -60,9 +60,6 @@ enum
enum
{
ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ACCESS,
ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_INVITED_ONLY,
ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE_APART_FROM_GUEST,
ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE,
ROOM_SETTINGS_ROOM_ACCESS_DIRECTORY_VISIBILITY,
ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING
};
@@ -147,9 +144,6 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
// Room Access items
TableViewCellWithCheckBoxAndLabel *accessInvitedOnlyTickCell;
TableViewCellWithCheckBoxAndLabel *accessAnyoneApartGuestTickCell;
TableViewCellWithCheckBoxAndLabel *accessAnyoneTickCell;
UISwitch *directoryVisibilitySwitch;
MXRoomDirectoryVisibility actualDirectoryVisibility;
MXHTTPOperation* actualDirectoryVisibilityRequest;
@@ -546,44 +540,20 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
if (RiotSettings.shared.roomSettingsScreenAllowChangingAccessSettings)
{
Section *sectionAccess = [Section sectionWithTag:SECTION_TAG_ACCESS];
if (@available(iOS 14, *))
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ACCESS];
// Check whether a room address is required for the current join rule
NSString *joinRule = updatedItemsDict[kRoomSettingsJoinRuleKey];
if (!joinRule)
{
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ACCESS];
// Check whether a room address is required for the current join rule
NSString *joinRule = updatedItemsDict[kRoomSettingsJoinRuleKey];
if (!joinRule)
{
// Use the actual values if no change is pending.
joinRule = mxRoomState.joinRule;
}
if ([joinRule isEqualToString:kMXRoomJoinRulePublic] && !roomAddresses.count)
{
// Notify the user that a room address is required.
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING];
}
// Use the actual values if no change is pending.
joinRule = mxRoomState.joinRule;
}
else
if ([joinRule isEqualToString:kMXRoomJoinRulePublic] && !roomAddresses.count)
{
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_INVITED_ONLY];
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE_APART_FROM_GUEST];
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE];
// Check whether a room address is required for the current join rule
NSString *joinRule = updatedItemsDict[kRoomSettingsJoinRuleKey];
if (!joinRule)
{
// Use the actual values if no change is pending.
joinRule = mxRoomState.joinRule;
}
if ([joinRule isEqualToString:kMXRoomJoinRulePublic] && !roomAddresses.count)
{
// Notify the user that a room address is required.
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING];
}
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_DIRECTORY_VISIBILITY];
// Notify the user that a room address is required.
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING];
}
if (mxRoom.isDirect)
@@ -596,15 +566,13 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
}
[tmpSections addObject:sectionAccess];
if (@available(iOS 14, *)) {
if (RiotSettings.shared.roomSettingsScreenAllowChangingAccessSettings)
{
Section *promotionAccess = [Section sectionWithTag:SECTION_TAG_PROMOTION];
promotionAccess.headerTitle = VectorL10n.roomDetailsPromoteRoomTitle;
[promotionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_DIRECTORY_VISIBILITY];
[promotionAccess addRowWithTag:ROOM_SETTINGS_ROOM_PROMOTE_SECTION_ROW_SUGGEST];
[tmpSections addObject:promotionAccess];
}
if (RiotSettings.shared.roomSettingsScreenAllowChangingAccessSettings)
{
Section *promotionAccess = [Section sectionWithTag:SECTION_TAG_PROMOTION];
promotionAccess.headerTitle = VectorL10n.roomDetailsPromoteRoomTitle;
[promotionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_DIRECTORY_VISIBILITY];
[promotionAccess addRowWithTag:ROOM_SETTINGS_ROOM_PROMOTE_SECTION_ROW_SUGGEST];
[tmpSections addObject:promotionAccess];
}
}
@@ -2610,46 +2578,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
{
guestAccess = mxRoomState.guestAccess;
}
if (row == ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_INVITED_ONLY)
{
roomAccessCell.label.text = [VectorL10n roomDetailsAccessSectionInvitedOnly];
roomAccessCell.enabled = ([joinRule isEqualToString:kMXRoomJoinRuleInvite]);
accessInvitedOnlyTickCell = roomAccessCell;
}
else if (row == ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE_APART_FROM_GUEST)
{
if (mxRoom.isDirect)
{
roomAccessCell.label.text = [VectorL10n roomDetailsAccessSectionAnyoneApartFromGuestForDm];
}
else
{
roomAccessCell.label.text = [VectorL10n roomDetailsAccessSectionAnyoneApartFromGuest];
}
roomAccessCell.enabled = ([joinRule isEqualToString:kMXRoomJoinRulePublic] && [guestAccess isEqualToString:kMXRoomGuestAccessForbidden]);
accessAnyoneApartGuestTickCell = roomAccessCell;
}
else if (row == ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE)
{
if (mxRoom.isDirect)
{
roomAccessCell.label.text = [VectorL10n roomDetailsAccessSectionAnyoneForDm];
}
else
{
roomAccessCell.label.text = [VectorL10n roomDetailsAccessSectionAnyone];
}
roomAccessCell.enabled = ([joinRule isEqualToString:kMXRoomJoinRulePublic] && [guestAccess isEqualToString:kMXRoomGuestAccessCanJoin]);
accessAnyoneTickCell = roomAccessCell;
}
// Check whether the user can change this option
roomAccessCell.userInteractionEnabled = (oneSelfPowerLevel >= [powerLevels minimumPowerLevelForSendingEventAsStateEvent:kMXEventTypeStringRoomJoinRules]);
roomAccessCell.checkBox.alpha = roomAccessCell.userInteractionEnabled ? 1.0f : 0.5f;
@@ -3150,129 +3079,8 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
else if (section == SECTION_TAG_ACCESS)
{
BOOL isUpdated = NO;
if (row == ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_INVITED_ONLY)
{
// Ignore the selection if the option is already enabled
if (! accessInvitedOnlyTickCell.isEnabled)
{
// Enable this option
accessInvitedOnlyTickCell.enabled = YES;
// Disable other options
accessAnyoneApartGuestTickCell.enabled = NO;
accessAnyoneTickCell.enabled = NO;
// Check the actual option
if ([mxRoomState.joinRule isEqualToString:kMXRoomJoinRuleInvite])
{
// No change on room access
[updatedItemsDict removeObjectForKey:kRoomSettingsJoinRuleKey];
[updatedItemsDict removeObjectForKey:kRoomSettingsGuestAccessKey];
}
else
{
updatedItemsDict[kRoomSettingsJoinRuleKey] = kMXRoomJoinRuleInvite;
// Update guest access to allow guest on invitation.
// Note: if guest_access is "forbidden" here, guests cannot join this room even if explicitly invited.
if ([mxRoomState.guestAccess isEqualToString:kMXRoomGuestAccessCanJoin])
{
[updatedItemsDict removeObjectForKey:kRoomSettingsGuestAccessKey];
}
else
{
updatedItemsDict[kRoomSettingsGuestAccessKey] = kMXRoomGuestAccessCanJoin;
}
}
isUpdated = YES;
}
}
else if (row == ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE_APART_FROM_GUEST)
{
// Ignore the selection if the option is already enabled
if (! accessAnyoneApartGuestTickCell.isEnabled)
{
// Enable this option
accessAnyoneApartGuestTickCell.enabled = YES;
// Disable other options
accessInvitedOnlyTickCell.enabled = NO;
accessAnyoneTickCell.enabled = NO;
// Check the actual option
if ([mxRoomState.joinRule isEqualToString:kMXRoomJoinRulePublic] && [mxRoomState.guestAccess isEqualToString:kMXRoomGuestAccessForbidden])
{
// No change on room access
[updatedItemsDict removeObjectForKey:kRoomSettingsJoinRuleKey];
[updatedItemsDict removeObjectForKey:kRoomSettingsGuestAccessKey];
}
else
{
if ([mxRoomState.joinRule isEqualToString:kMXRoomJoinRulePublic])
{
[updatedItemsDict removeObjectForKey:kRoomSettingsJoinRuleKey];
}
else
{
updatedItemsDict[kRoomSettingsJoinRuleKey] = kMXRoomJoinRulePublic;
}
if ([mxRoomState.guestAccess isEqualToString:kMXRoomGuestAccessForbidden])
{
[updatedItemsDict removeObjectForKey:kRoomSettingsGuestAccessKey];
}
else
{
updatedItemsDict[kRoomSettingsGuestAccessKey] = kMXRoomGuestAccessForbidden;
}
}
isUpdated = YES;
}
}
else if (row == ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE)
{
// Ignore the selection if the option is already enabled
if (! accessAnyoneTickCell.isEnabled)
{
// Enable this option
accessAnyoneTickCell.enabled = YES;
// Disable other options
accessInvitedOnlyTickCell.enabled = NO;
accessAnyoneApartGuestTickCell.enabled = NO;
// Check the actual option
if ([mxRoomState.joinRule isEqualToString:kMXRoomJoinRulePublic] && [mxRoomState.guestAccess isEqualToString:kMXRoomGuestAccessCanJoin])
{
// No change on room access
[updatedItemsDict removeObjectForKey:kRoomSettingsJoinRuleKey];
[updatedItemsDict removeObjectForKey:kRoomSettingsGuestAccessKey];
}
else
{
if ([mxRoomState.joinRule isEqualToString:kMXRoomJoinRulePublic])
{
[updatedItemsDict removeObjectForKey:kRoomSettingsJoinRuleKey];
}
else
{
updatedItemsDict[kRoomSettingsJoinRuleKey] = kMXRoomJoinRulePublic;
}
if ([mxRoomState.guestAccess isEqualToString:kMXRoomGuestAccessCanJoin])
{
[updatedItemsDict removeObjectForKey:kRoomSettingsGuestAccessKey];
}
else
{
updatedItemsDict[kRoomSettingsGuestAccessKey] = kMXRoomGuestAccessCanJoin;
}
}
isUpdated = YES;
}
}
else if (row == ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING)
if (row == ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING)
{
// Scroll to room addresses section
NSIndexPath *addressIndexPath = [_tableViewSections exactIndexPathForRowTag:0 sectionTag:SECTION_TAG_ADDRESSES];
@@ -3832,29 +3640,23 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
- (void)showRoomAccessFlow
{
if (@available(iOS 14.0, *))
{
MXRoom *room = [self.mainSession roomWithRoomId:self.roomId];
if (room) {
roomAccessPresenter = [[RoomAccessCoordinatorBridgePresenter alloc] initWithRoom:room parentSpaceId:self.parentSpaceId];
roomAccessPresenter.delegate = self;
[roomAccessPresenter presentFrom:self animated:YES];
}
MXRoom *room = [self.mainSession roomWithRoomId:self.roomId];
if (room) {
roomAccessPresenter = [[RoomAccessCoordinatorBridgePresenter alloc] initWithRoom:room parentSpaceId:self.parentSpaceId];
roomAccessPresenter.delegate = self;
[roomAccessPresenter presentFrom:self animated:YES];
}
}
- (void)showSuggestToSpaceMembers
{
if (@available(iOS 14.0, *))
{
MXRoom *room = [self.mainSession roomWithRoomId:self.roomId];
if (room) {
roomSuggestionPresenter = [[RoomSuggestionCoordinatorBridgePresenter alloc] initWithRoom:room];
roomSuggestionPresenter.delegate = self;
[roomSuggestionPresenter presentFrom:self animated:YES];
}
MXRoom *room = [self.mainSession roomWithRoomId:self.roomId];
if (room) {
roomSuggestionPresenter = [[RoomSuggestionCoordinatorBridgePresenter alloc] initWithRoom:room];
roomSuggestionPresenter.delegate = self;
[roomSuggestionPresenter presentFrom:self animated:YES];
}
}

View File

@@ -25,8 +25,7 @@ class LocationPlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, Room
override func render(_ cellData: MXKCellData!) {
super.render(cellData)
guard #available(iOS 14.0, *),
let bubbleData = cellData as? RoomBubbleCellData,
guard let bubbleData = cellData as? RoomBubbleCellData,
let event = bubbleData.events.last
else {
return
@@ -118,8 +117,7 @@ class LocationPlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, Room
roomCellContentView?.showSenderInfo = true
roomCellContentView?.showPaginationTitle = false
guard #available(iOS 14.0, *),
let contentView = roomCellContentView?.innerContentView else {
guard let contentView = roomCellContentView?.innerContentView else {
return
}

View File

@@ -24,8 +24,7 @@ class PollPlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCell
override func render(_ cellData: MXKCellData!) {
super.render(cellData)
guard #available(iOS 14.0, *),
let contentView = roomCellContentView?.innerContentView,
guard let contentView = roomCellContentView?.innerContentView,
let bubbleData = cellData as? RoomBubbleCellData,
let event = bubbleData.events.last,
event.eventType == __MXEventType.pollStart,

View File

@@ -414,23 +414,13 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
{
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_SHOW_DECODED_CONTENT];
}
if (@available(iOS 14.0, *)) {
// Don't display Global settings footer for iOS 14+
} else {
sectionNotificationSettings.footerTitle = [VectorL10n settingsGlobalSettingsInfo:AppInfo.current.displayName];
}
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX];
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_PIN_UNREAD_INDEX];
if (@available(iOS 14.0, *)) {
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_DEFAULT_SETTINGS_INDEX];
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_MENTION_AND_KEYWORDS_SETTINGS_INDEX];
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_OTHER_SETTINGS_INDEX];
} else {
// Don't add new sections on pre iOS 14
}
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_DEFAULT_SETTINGS_INDEX];
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_MENTION_AND_KEYWORDS_SETTINGS_INDEX];
[sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_OTHER_SETTINGS_INDEX];
sectionNotificationSettings.headerTitle = [VectorL10n settingsNotifications];
[tmpSections addObject:sectionNotificationSettings];
@@ -2941,18 +2931,16 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
}
else if (section == SECTION_TAG_NOTIFICATIONS)
{
if (@available(iOS 14.0, *)) {
switch (row) {
case NOTIFICATION_SETTINGS_DEFAULT_SETTINGS_INDEX:
[self showNotificationSettings:NotificationSettingsScreenDefaultNotifications];
break;
case NOTIFICATION_SETTINGS_MENTION_AND_KEYWORDS_SETTINGS_INDEX:
[self showNotificationSettings:NotificationSettingsScreenMentionsAndKeywords];
break;
case NOTIFICATION_SETTINGS_OTHER_SETTINGS_INDEX:
[self showNotificationSettings:NotificationSettingsScreenOther];
break;
}
switch (row) {
case NOTIFICATION_SETTINGS_DEFAULT_SETTINGS_INDEX:
[self showNotificationSettings:NotificationSettingsScreenDefaultNotifications];
break;
case NOTIFICATION_SETTINGS_MENTION_AND_KEYWORDS_SETTINGS_INDEX:
[self showNotificationSettings:NotificationSettingsScreenMentionsAndKeywords];
break;
case NOTIFICATION_SETTINGS_OTHER_SETTINGS_INDEX:
[self showNotificationSettings:NotificationSettingsScreenOther];
break;
}
}

View File

@@ -430,9 +430,7 @@ extension SideMenuCoordinator: SpaceListCoordinatorDelegate {
}
func spaceListCoordinatorDidSelectCreateSpace(_ coordinator: SpaceListCoordinatorType) {
if #available(iOS 14.0, *) {
self.showCreateSpace()
}
self.showCreateSpace()
}
}
@@ -460,11 +458,7 @@ extension SideMenuCoordinator: SpaceMenuPresenterDelegate {
case .addSpace:
AppDelegate.theDelegate().showAlert(withTitle: VectorL10n.spacesAddSpace, message: VectorL10n.spacesFeatureNotAvailable(AppInfo.current.displayName))
case .settings:
if #available(iOS 14.0, *) {
self.showSpaceSettings(spaceId: spaceId, session: session)
} else {
AppDelegate.theDelegate().showAlert(withTitle: VectorL10n.settingsTitle, message: VectorL10n.spacesFeatureNotAvailable(AppInfo.current.displayName))
}
self.showSpaceSettings(spaceId: spaceId, session: session)
case .invite:
self.showSpaceInvite(spaceId: spaceId, session: session)
}

View File

@@ -167,10 +167,8 @@ final class SpaceListViewModel: SpaceListViewModelType {
]
let spacesSectionIndex = sections.count - 1
if #available(iOS 14.0, *) {
let addSpaceViewData = self.createAddSpaceViewData(session: session)
sections.append(.addSpace(addSpaceViewData))
}
let addSpaceViewData = self.createAddSpaceViewData(session: session)
sections.append(.addSpace(addSpaceViewData))
self.sections = sections
let homeIndexPath = viewDataList.invites.isEmpty ? IndexPath(row: 0, section: 0) : IndexPath(row: 0, section: 1)

View File

@@ -146,9 +146,7 @@ extension SpaceMenuPresenter: SpaceMenuModelViewModelCoordinatorDelegate {
case .invite:
self.delegate?.spaceMenuPresenter(self, didCompleteWith: .invite, forSpaceWithId: self.spaceId, with: self.session)
case .leaveSpaceAndChooseRooms:
if #available(iOS 14.0, *) {
self.showLeaveSpace()
}
self.showLeaveSpace()
default:
MXLog.error("[SpaceMenuPresenter] spaceListViewModel didSelectItem: invalid action \(action)")
}

View File

@@ -85,22 +85,6 @@ class SpaceMenuViewModel: SpaceMenuViewModelType {
}
private func leaveSpace() {
guard #available(iOS 14, *) else {
guard let room = self.session.room(withRoomId: self.spaceId), let displayName = room.summary?.displayname else {
return
}
var isAdmin = false
if let roomState = room.dangerousSyncState, let powerLevels = roomState.powerLevels {
let powerLevel = powerLevels.powerLevelOfUser(withUserID: self.session.myUserId)
let roomPowerLevel = RoomPowerLevelHelper.roomPowerLevel(from: powerLevel)
isAdmin = roomPowerLevel == .admin
}
self.viewDelegate?.spaceMenuViewModel(self, didUpdateViewState: .leaveOptions(displayName, isAdmin))
return
}
self.viewDelegate?.spaceMenuViewModel(self, didUpdateViewState: .deselect)
self.coordinatorDelegate?.spaceMenuViewModel(self, didSelectItemWith: .leaveSpaceAndChooseRooms)
}

View File

@@ -240,10 +240,6 @@ final class ExploreRoomCoordinator: NSObject, ExploreRoomCoordinatorType {
}
private func startEditPollCoordinator(room: MXRoom, startEvent: MXEvent? = nil) {
guard #available(iOS 14.0, *) else {
return
}
let parameters = PollEditFormCoordinatorParameters(room: room, pollStartEvent: startEvent)
let coordinator = PollEditFormCoordinator(parameters: parameters)
@@ -283,9 +279,7 @@ extension ExploreRoomCoordinator: SpaceExploreRoomCoordinatorDelegate {
func spaceExploreRoomCoordinator(_ coordinator: SpaceExploreRoomCoordinatorType, openSettingsOf item: SpaceExploreRoomListItemViewData) {
if item.childInfo.roomType == .space {
if #available(iOS 14, *) {
self.showSpaceSettings(of: item.childInfo)
}
self.showSpaceSettings(of: item.childInfo)
} else {
if !presentSettings(ofRoomWithId: item.childInfo.childRoomId) {
self.navigateTo(roomWith: item.childInfo.childRoomId, showSettingsInitially: true, animated: true)
@@ -438,18 +432,10 @@ extension ExploreRoomCoordinator: RoomViewControllerDelegate {
}
func roomViewController(_ roomViewController: RoomViewController, canEditPollWithEventIdentifier eventIdentifier: String) -> Bool {
guard #available(iOS 14.0, *) else {
return false
}
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEditPoll() ?? false
}
func roomViewController(_ roomViewController: RoomViewController, endPollWithEventIdentifier eventIdentifier: String) {
guard #available(iOS 14.0, *) else {
return
}
TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.endPoll()
}
@@ -458,10 +444,6 @@ extension ExploreRoomCoordinator: RoomViewControllerDelegate {
}
func roomViewController(_ roomViewController: RoomViewController, canEndPollWithEventIdentifier eventIdentifier: String) -> Bool {
guard #available(iOS 14.0, *) else {
return false
}
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEndPoll() ?? false
}

View File

@@ -65,11 +65,6 @@ final class AnalyticsPromptCoordinator: Coordinator, Presentable {
// MARK: - Public
func start() {
guard #available(iOS 14.0, *) else {
MXLog.debug("[AnalyticsPromptCoordinator] start: Invalid iOS version, returning.")
return
}
MXLog.debug("[AnalyticsPromptCoordinator] did start.")
analyticsPromptViewModel.completion = { [weak self] result in

View File

@@ -91,11 +91,6 @@ final class LocationSharingCoordinator: Coordinator, Presentable {
// MARK: - Public
func start() {
guard #available(iOS 14.0, *) else {
MXLog.error("[LocationSharingCoordinator] start: Invalid iOS version, returning.")
return
}
locationSharingViewModel.completion = { [weak self] result in
guard let self = self else { return }

View File

@@ -37,45 +37,21 @@ final class RoomNotificationSettingsCoordinator: RoomNotificationSettingsCoordin
init(room: MXRoom, presentedModally: Bool = true) {
let roomNotificationService = MXRoomNotificationSettingsService(room: room)
let avatarData: AvatarProtocol?
let showAvatar = presentedModally
if #available(iOS 14.0.0, *) {
avatarData = showAvatar ? AvatarInput(
mxContentUri: room.summary.avatar,
matrixItemId: room.roomId,
displayName: room.summary.displayname
) : nil
} else {
avatarData = showAvatar ? RoomAvatarViewData(
roomId: room.roomId,
displayName: room.summary.displayname,
avatarUrl: room.summary.avatar,
mediaManager: room.mxSession.mediaManager
) : nil
}
let viewModel: RoomNotificationSettingsViewModel
let viewController: UIViewController
if #available(iOS 14.0.0, *) {
let swiftUIViewModel = RoomNotificationSettingsSwiftUIViewModel(
roomNotificationService: roomNotificationService,
avatarData: avatarData,
displayName: room.summary.displayname,
roomEncrypted: room.summary.isEncrypted)
let avatarService: AvatarServiceProtocol = AvatarService(mediaManager: room.mxSession.mediaManager)
let view = RoomNotificationSettings(viewModel: swiftUIViewModel, presentedModally: presentedModally)
.addDependency(avatarService)
let host = VectorHostingController(rootView: view)
viewModel = swiftUIViewModel
viewController = host
} else {
viewModel = RoomNotificationSettingsViewModel(
roomNotificationService: roomNotificationService,
avatarData: avatarData,
displayName: room.summary.displayname,
roomEncrypted: room.summary.isEncrypted)
viewController = RoomNotificationSettingsViewController.instantiate(with: viewModel)
}
let avatarData = showAvatar ? AvatarInput(
mxContentUri: room.summary.avatar,
matrixItemId: room.roomId,
displayName: room.summary.displayname
) : nil
let viewModel = RoomNotificationSettingsSwiftUIViewModel(
roomNotificationService: roomNotificationService,
avatarData: avatarData,
displayName: room.summary.displayname,
roomEncrypted: room.summary.isEncrypted)
let avatarService: AvatarServiceProtocol = AvatarService(mediaManager: room.mxSession.mediaManager)
let view = RoomNotificationSettings(viewModel: viewModel, presentedModally: presentedModally)
.addDependency(avatarService)
let viewController = VectorHostingController(rootView: view)
self.roomNotificationSettingsViewModel = viewModel
self.roomNotificationSettingsViewController = viewController
}

View File

@@ -64,11 +64,6 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
// MARK: - Public
func start() {
guard #available(iOS 14.0, *) else {
MXLog.error("[PollEditFormCoordinator] start: Invalid iOS version, returning.")
return
}
pollEditFormViewModel.completion = { [weak self] result in
guard let self = self else { return }
switch result {

View File

@@ -33,30 +33,20 @@ final class UserSuggestionCoordinatorBridge: NSObject {
init(mediaManager: MXMediaManager, room: MXRoom) {
let parameters = UserSuggestionCoordinatorParameters(mediaManager: mediaManager, room: room)
if #available(iOS 14.0, *) {
let userSuggestionCoordinator = UserSuggestionCoordinator(parameters: parameters)
self._userSuggestionCoordinator = userSuggestionCoordinator
}
let userSuggestionCoordinator = UserSuggestionCoordinator(parameters: parameters)
self._userSuggestionCoordinator = userSuggestionCoordinator
super.init()
if #available(iOS 14.0, *) {
userSuggestionCoordinator.delegate = self
}
userSuggestionCoordinator.delegate = self
}
func processTextMessage(_ textMessage: String) {
if #available(iOS 14.0, *) {
return self.userSuggestionCoordinator.processTextMessage(textMessage)
}
return self.userSuggestionCoordinator.processTextMessage(textMessage)
}
func toPresentable() -> UIViewController? {
if #available(iOS 14.0, *) {
return self.userSuggestionCoordinator.toPresentable()
}
return nil
return self.userSuggestionCoordinator.toPresentable()
}
}

View File

@@ -77,24 +77,22 @@ final class SpaceCreationCoordinator: Coordinator {
// MARK: - Public
func start() {
if #available(iOS 14.0, *) {
MXLog.debug("[SpaceCreationCoordinator] did start.")
let rootCoordinator = self.createMenuCoordinator(with: spaceVisibilityMenuParameters)
rootCoordinator.start()
self.add(childCoordinator: rootCoordinator)
self.toPresentable().isModalInPresentation = true
if self.navigationRouter.modules.isEmpty == false {
self.navigationRouter.push(rootCoordinator, animated: true, popCompletion: { [weak self] in
self?.remove(childCoordinator: rootCoordinator)
})
} else {
self.navigationRouter.setRootModule(rootCoordinator) { [weak self] in
self?.remove(childCoordinator: rootCoordinator)
}
MXLog.debug("[SpaceCreationCoordinator] did start.")
let rootCoordinator = self.createMenuCoordinator(with: spaceVisibilityMenuParameters)
rootCoordinator.start()
self.add(childCoordinator: rootCoordinator)
self.toPresentable().isModalInPresentation = true
if self.navigationRouter.modules.isEmpty == false {
self.navigationRouter.push(rootCoordinator, animated: true, popCompletion: { [weak self] in
self?.remove(childCoordinator: rootCoordinator)
})
} else {
self.navigationRouter.setRootModule(rootCoordinator) { [weak self] in
self?.remove(childCoordinator: rootCoordinator)
}
}
}