onAppear wasn't being called with the current implementation of the cloud tab in library. Fix this to listen to the selectedDebridType variable instead of relying on the onAppear call of a view.y Also do some further project cleanup and LOC removal Signed-off-by: kingbri <bdashore3@proton.me>
49 lines
1.2 KiB
Swift
49 lines
1.2 KiB
Swift
//
|
|
// DebridCloudView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 12/31/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct DebridCloudView: View {
|
|
@EnvironmentObject var debridManager: DebridManager
|
|
|
|
@Binding var searchText: String
|
|
|
|
@State private var viewTask: Task<Void, Never>?
|
|
|
|
var body: some View {
|
|
List {
|
|
switch debridManager.selectedDebridType {
|
|
case .realDebrid:
|
|
RealDebridCloudView(searchText: $searchText)
|
|
case .premiumize:
|
|
PremiumizeCloudView(searchText: $searchText)
|
|
case .allDebrid:
|
|
AllDebridCloudView(searchText: $searchText)
|
|
case .none:
|
|
EmptyView()
|
|
}
|
|
}
|
|
.listStyle(.plain)
|
|
.backport.onAppear {
|
|
viewTask = Task {
|
|
await debridManager.fetchDebridCloud()
|
|
}
|
|
}
|
|
.onDisappear {
|
|
viewTask?.cancel()
|
|
}
|
|
.onChange(of: debridManager.selectedDebridType) { newType in
|
|
viewTask?.cancel()
|
|
|
|
if newType != nil {
|
|
viewTask = Task {
|
|
await debridManager.fetchDebridCloud()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|