Removing dead code part 3 (#2264)

This commit is contained in:
Mauro
2023-12-19 12:12:16 +01:00
committed by GitHub
parent 334d55aeaf
commit 09fb5461e6
77 changed files with 48 additions and 462 deletions
@@ -28,7 +28,6 @@ enum ServerConfirmationScreenCoordinatorAction {
}
final class ServerConfirmationScreenCoordinator: CoordinatorProtocol {
private let parameters: ServerConfirmationScreenCoordinatorParameters
private var viewModel: ServerConfirmationScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<ServerConfirmationScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -38,8 +37,6 @@ final class ServerConfirmationScreenCoordinator: CoordinatorProtocol {
}
init(parameters: ServerConfirmationScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = ServerConfirmationScreenViewModel(authenticationService: parameters.authenticationService,
authenticationFlow: parameters.authenticationFlow)
}
@@ -161,11 +161,6 @@ struct SoftLogoutScreen: View {
context.send(viewAction: .login)
}
/// Sends the `forgotPassword` view action.
func forgotPassword() {
context.send(viewAction: .forgotPassword)
}
/// Sends the `clearAllData` view action.
func clearData() {
context.send(viewAction: .clearAllData)
@@ -43,14 +43,6 @@ struct WaitlistScreenViewState: BindableState {
/// Whether or not the user is still waiting in the queue.
var isWaiting: Bool { userSession == nil }
var iconSymbolName: String {
if isWaiting {
return "stopwatch"
} else {
return "sparkles"
}
}
var title: String {
if isWaiting {
return L10n.screenWaitlistTitle
@@ -162,19 +162,6 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
"""
}
private func evaluateJavaScript(_ script: String) async -> String? {
guard let evaluator = state.bindings.javaScriptEvaluator else {
fatalError("Invalid javaScriptEvaluator")
}
do {
return try await evaluator(script) as? String
} catch {
MXLog.error("Failed evaluating javaScript with error: \(error)")
return nil
}
}
private func setupVoIPSession(callID: UUID) async throws {
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: [])
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
@@ -24,7 +24,6 @@ struct VoiceMessagePreviewComposer: View {
let waveform: WaveformSource
@ScaledMetric private var waveformLineWidth = 2.0
@ScaledMetric private var waveformLinePadding = 2.0
@State private var resumePlaybackAfterScrubbing = false
@GestureState var isDragging = false
let onPlay: () -> Void
@@ -95,20 +94,6 @@ struct VoiceMessagePreviewComposer: View {
onPlay()
}
}
private func onScrubbing(_ scrubbing: Bool) {
if scrubbing {
if playerState.playbackState == .playing {
resumePlaybackAfterScrubbing = true
onPause()
}
} else {
if resumePlaybackAfterScrubbing {
onPlay()
resumePlaybackAfterScrubbing = false
}
}
}
}
private extension DateFormatter {
@@ -33,12 +33,6 @@ struct VoiceMessageRecordingComposer: View {
}
}
}
private func onPlaybackPlayPause() { }
private func onPlaybackSeek(_ progress: Double) { }
private func onPlaybackScrubbing(_ dragging: Bool) { }
}
struct VoiceMessageRecordingComposer_Previews: PreviewProvider, TestablePreview {
@@ -27,7 +27,6 @@ enum StaticLocationScreenCoordinatorAction {
}
final class StaticLocationScreenCoordinator: CoordinatorProtocol {
let parameters: StaticLocationScreenCoordinatorParameters
let viewModel: StaticLocationScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<StaticLocationScreenCoordinatorAction, Never> = .init()
@@ -38,8 +37,6 @@ final class StaticLocationScreenCoordinator: CoordinatorProtocol {
}
init(parameters: StaticLocationScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = StaticLocationScreenViewModel(interactionMode: parameters.interactionMode)
}
@@ -37,8 +37,7 @@ final class RoomPollsHistoryScreenCoordinator: CoordinatorProtocol {
}
init(parameters: RoomPollsHistoryScreenCoordinatorParameters) {
viewModel = RoomPollsHistoryScreenViewModel(roomProxy: parameters.roomProxy,
pollInteractionHandler: parameters.pollInteractionHandler,
viewModel = RoomPollsHistoryScreenViewModel(pollInteractionHandler: parameters.pollInteractionHandler,
roomTimelineController: parameters.roomTimelineController,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
}
@@ -26,7 +26,6 @@ class RoomPollsHistoryScreenViewModel: RoomPollsHistoryScreenViewModelType, Room
static let backPaginationEventLimit: UInt = 250
}
private let roomProxy: RoomProxyProtocol
private let pollInteractionHandler: PollInteractionHandlerProtocol
private let roomTimelineController: RoomTimelineControllerProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
@@ -40,11 +39,9 @@ class RoomPollsHistoryScreenViewModel: RoomPollsHistoryScreenViewModelType, Room
actionsSubject.eraseToAnyPublisher()
}
init(roomProxy: RoomProxyProtocol,
pollInteractionHandler: PollInteractionHandlerProtocol,
init(pollInteractionHandler: PollInteractionHandlerProtocol,
roomTimelineController: RoomTimelineControllerProtocol,
userIndicatorController: UserIndicatorControllerProtocol) {
self.roomProxy = roomProxy
self.pollInteractionHandler = pollInteractionHandler
self.roomTimelineController = roomTimelineController
self.userIndicatorController = userIndicatorController
@@ -189,12 +186,3 @@ class RoomPollsHistoryScreenViewModel: RoomPollsHistoryScreenViewModelType, Room
}
}
}
// MARK: - Mocks
extension RoomPollsHistoryScreenViewModel {
static let mock = RoomPollsHistoryScreenViewModel(roomProxy: RoomProxyMock(),
pollInteractionHandler: PollInteractionHandlerMock(),
roomTimelineController: MockRoomTimelineController(),
userIndicatorController: UserIndicatorControllerMock())
}
@@ -126,8 +126,7 @@ struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview {
roomTimelineController.timelineItems = []
let roomProxyMockConfiguration = RoomProxyMockConfiguration(displayName: "Polls")
roomProxyMockConfiguration.timeline.timelineStartReached = false
let viewModel = RoomPollsHistoryScreenViewModel(roomProxy: RoomProxyMock(with: roomProxyMockConfiguration),
pollInteractionHandler: PollInteractionHandlerMock(),
let viewModel = RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(),
roomTimelineController: roomTimelineController,
userIndicatorController: UserIndicatorControllerMock())
return viewModel
@@ -150,8 +149,7 @@ struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview {
let roomProxyMockConfiguration = RoomProxyMockConfiguration(displayName: "Polls")
roomProxyMockConfiguration.timeline.timelineStartReached = true
let viewModel = RoomPollsHistoryScreenViewModel(roomProxy: RoomProxyMock(with: roomProxyMockConfiguration),
pollInteractionHandler: PollInteractionHandlerMock(),
let viewModel = RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(),
roomTimelineController: roomTimelineController,
userIndicatorController: UserIndicatorControllerMock())
@@ -26,8 +26,6 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
let timelineItem: EventBasedTimelineItemProtocol
let adjustedDeliveryStatus: TimelineItemDeliveryStatus?
@ViewBuilder let content: () -> Content
@State private var showItemActionMenu = false
private var isEncryptedOneToOneRoom: Bool { context.viewState.isEncryptedOneToOneRoom }
@@ -24,8 +24,6 @@ struct TimelineItemPlainStylerView<Content: View>: View {
let timelineItem: EventBasedTimelineItemProtocol
let adjustedDeliveryStatus: TimelineItemDeliveryStatus?
@ViewBuilder let content: () -> Content
@State private var showItemActionMenu = false
var body: some View {
VStack(alignment: .trailing, spacing: 0) {
@@ -68,10 +68,6 @@ private struct TimelineGroupStyleKey: EnvironmentKey {
static let defaultValue = TimelineGroupStyle.single
}
private struct ReadReceiptsEnabledKey: EnvironmentKey {
static let defaultValue = false
}
extension EnvironmentValues {
var timelineStyle: TimelineStyle {
get { self[TimelineStyleKey.self] }
@@ -18,8 +18,6 @@ import SwiftUI
@MainActor
struct TimelineReactionsView: View {
private static let horizontalSpacing: CGFloat = 4
private static let verticalSpacing: CGFloat = 4
private let feedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
@Environment(\.layoutDirection) private var layoutDirection: LayoutDirection
@@ -20,8 +20,6 @@ struct PollRoomTimelineView: View {
let timelineItem: PollRoomTimelineItem
@EnvironmentObject private var context: RoomScreenViewModel.Context
private let feedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
var body: some View {
TimelineStyler(timelineItem: timelineItem) {
PollView(poll: poll, editable: timelineItem.isEditable) { action in
@@ -24,6 +24,7 @@ import OrderedCollections
class TimelineItemCell: UITableViewCell {
static let reuseIdentifier = "TimelineItemCell"
// periphery:ignore - retaining purpose
var item: RoomTimelineItemViewState?
override func prepareForReuse() {
@@ -63,8 +64,6 @@ class TimelineTableViewController: UIViewController {
paginateBackwardsPublisher.send(())
}
}
var contextMenuActionProvider: (@MainActor (_ itemID: TimelineItemIdentifier) -> TimelineItemMenuActions?)?
@Binding private var isScrolledToBottom: Bool
@@ -66,9 +66,6 @@ struct UITimelineView: UIViewControllerRepresentable {
if tableViewController.isBackPaginating != context.viewState.timelineViewState.isBackPaginating {
tableViewController.isBackPaginating = context.viewState.timelineViewState.isBackPaginating
}
// Doesn't have an equatable conformance :(
tableViewController.contextMenuActionProvider = context.viewState.timelineItemMenuActionProvider
}
func send(viewAction: RoomScreenViewAction) {
@@ -133,7 +133,7 @@ extension RoomTimelineItemProtocol {
}
}
public struct TimelineItemMenu: View {
struct TimelineItemMenu: View {
@EnvironmentObject private var context: RoomScreenViewModel.Context
@Environment(\.dismiss) private var dismiss
@@ -141,7 +141,7 @@ public struct TimelineItemMenu: View {
let actions: TimelineItemMenuActions
private let feedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
public var body: some View {
var body: some View {
VStack(spacing: 8) {
header
.frame(idealWidth: 300.0)
@@ -27,7 +27,6 @@ enum SecureBackupKeyBackupScreenCoordinatorAction {
}
final class SecureBackupKeyBackupScreenCoordinator: CoordinatorProtocol {
private let parameters: SecureBackupKeyBackupScreenCoordinatorParameters
private var viewModel: SecureBackupKeyBackupScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<SecureBackupKeyBackupScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -37,8 +36,6 @@ final class SecureBackupKeyBackupScreenCoordinator: CoordinatorProtocol {
}
init(parameters: SecureBackupKeyBackupScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = SecureBackupKeyBackupScreenViewModel(secureBackupController: parameters.secureBackupController,
userIndicatorController: parameters.userIndicatorController)
}
@@ -33,8 +33,6 @@ struct SecureBackupKeyBackupScreenViewStateBindings {
var alertInfo: AlertInfo<UUID>?
}
var alertInfo: AlertInfo<UUID>?
enum SecureBackupKeyBackupScreenViewAction {
case cancel
case toggleBackup
@@ -29,7 +29,6 @@ enum SecureBackupLogoutConfirmationScreenCoordinatorAction {
}
final class SecureBackupLogoutConfirmationScreenCoordinator: CoordinatorProtocol {
private let parameters: SecureBackupLogoutConfirmationScreenCoordinatorParameters
private var viewModel: SecureBackupLogoutConfirmationScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<SecureBackupLogoutConfirmationScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -39,8 +38,6 @@ final class SecureBackupLogoutConfirmationScreenCoordinator: CoordinatorProtocol
}
init(parameters: SecureBackupLogoutConfirmationScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = SecureBackupLogoutConfirmationScreenViewModel(secureBackupController: parameters.secureBackupController,
networkMonitor: parameters.networkMonitor)
}
@@ -23,6 +23,7 @@ class SecureBackupLogoutConfirmationScreenViewModel: SecureBackupLogoutConfirmat
private let secureBackupController: SecureBackupControllerProtocol
private let networkMonitor: NetworkMonitorProtocol
// periphery:ignore - auto cancels when reassigned
@CancellableTask
private var keyUploadWaitingTask: Task<Void, Never>?
@@ -30,7 +30,6 @@ enum SecureBackupRecoveryKeyScreenCoordinatorAction {
}
final class SecureBackupRecoveryKeyScreenCoordinator: CoordinatorProtocol {
private let parameters: SecureBackupRecoveryKeyScreenCoordinatorParameters
private var viewModel: SecureBackupRecoveryKeyScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<SecureBackupRecoveryKeyScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
@@ -40,8 +39,6 @@ final class SecureBackupRecoveryKeyScreenCoordinator: CoordinatorProtocol {
}
init(parameters: SecureBackupRecoveryKeyScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = SecureBackupRecoveryKeyScreenViewModel(secureBackupController: parameters.secureBackupController,
userIndicatorController: parameters.userIndicatorController)
}
@@ -24,18 +24,11 @@ struct SecureBackupScreenCoordinatorParameters {
let userIndicatorController: UserIndicatorControllerProtocol
}
enum SecureBackupScreenCoordinatorAction { }
final class SecureBackupScreenCoordinator: CoordinatorProtocol {
private let parameters: SecureBackupScreenCoordinatorParameters
private var viewModel: SecureBackupScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<SecureBackupScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
var actions: AnyPublisher<SecureBackupScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(parameters: SecureBackupScreenCoordinatorParameters) {
self.parameters = parameters
@@ -26,7 +26,6 @@ struct SessionVerificationScreenCoordinatorParameters {
}
final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
private let parameters: SessionVerificationScreenCoordinatorParameters
private var viewModel: SessionVerificationScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<SessionVerificationScreenCoordinatorAction, Never> = .init()
@@ -37,8 +36,6 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
}
init(parameters: SessionVerificationScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy)
}
@@ -211,19 +211,6 @@ struct SessionVerificationScreen: View {
.padding(8.0)
}
}
struct StateIcon: View {
let systemName: String
var body: some View {
Image(systemName: systemName)
.resizable()
.font(.compound.bodyLG.weight(.light))
.scaledToFit()
.foregroundColor(.compound.iconPrimary)
.frame(width: 100, height: 100)
}
}
}
// MARK: - Previews
@@ -41,6 +41,7 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
private let parameters: SettingsScreenCoordinatorParameters
private var viewModel: SettingsScreenViewModelProtocol
// periphery:ignore - retaining purpose
private var appLockSetupFlowCoordinator: AppLockSetupFlowCoordinator?
private let actionsSubject: PassthroughSubject<SettingsScreenCoordinatorAction, Never> = .init()
@@ -20,9 +20,6 @@ import SwiftUI
typealias SettingsScreenViewModelType = StateStoreViewModel<SettingsScreenViewState, SettingsScreenViewAction>
class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewModelProtocol {
private let userSession: UserSessionProtocol
private let appSettings: AppSettings
private var actionsSubject: PassthroughSubject<SettingsScreenViewModelAction, Never> = .init()
var actions: AnyPublisher<SettingsScreenViewModelAction, Never> {
@@ -30,9 +27,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
}
init(userSession: UserSessionProtocol, appSettings: AppSettings) {
self.userSession = userSession
self.appSettings = appSettings
super.init(initialViewState: .init(deviceID: userSession.deviceID,
userID: userSession.userID,
accountProfileURL: userSession.clientProxy.accountURL(action: .profile),
@@ -24,18 +24,11 @@ struct UserDetailsEditScreenCoordinatorParameters {
let userIndicatorController: UserIndicatorControllerProtocol
}
enum UserDetailsEditScreenCoordinatorAction { }
final class UserDetailsEditScreenCoordinator: CoordinatorProtocol {
private let parameters: UserDetailsEditScreenCoordinatorParameters
private var viewModel: UserDetailsEditScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<UserDetailsEditScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
var actions: AnyPublisher<UserDetailsEditScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(parameters: UserDetailsEditScreenCoordinatorParameters) {
self.parameters = parameters
@@ -37,12 +37,7 @@ struct UserDetailsEditScreenViewState: BindableState {
var nameDidChange: Bool {
bindings.name != currentDisplayName
}
/// The string shown for the room's name when it can't be edited.
var nameRowTitle: String {
bindings.name.isEmpty ? L10n.screenEditProfileDisplayName : bindings.name
}
var avatarDidChange: Bool {
localMedia != nil || selectedAvatarURL != currentAvatarURL
}
@@ -99,6 +99,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
.store(in: &cancellables)
}
// periphery:ignore - auto cancels when reassigned
@CancellableTask
private var fetchUsersTask: Task<Void, Never>?