AllDebrid is another debrid provider. Add support to Ferrite in addition to RealDebrid. The overall debrid login backend has changed to accomodate for a more agnostic app structure where more services can be added as needed. Also add some cosmetic changes to search so filters can be added while searching for a phrase. Signed-off-by: kingbri <bdashore3@proton.me>
54 lines
1.5 KiB
Swift
54 lines
1.5 KiB
Swift
//
|
|
// HistoryActionsView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 9/7/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct HistoryActionsView: View {
|
|
@EnvironmentObject var toastModel: ToastViewModel
|
|
|
|
@State private var showActionSheet = false
|
|
|
|
var body: some View {
|
|
Button("Clear") {
|
|
showActionSheet.toggle()
|
|
}
|
|
.backport.tint(.red)
|
|
.backport.confirmationDialog(
|
|
isPresented: $showActionSheet,
|
|
title: "Clear watch history",
|
|
message: "This is an irreversible action!",
|
|
buttons: [
|
|
AlertButton("Past day", role: .destructive) {
|
|
deleteHistory(.day)
|
|
},
|
|
AlertButton("Past week", role: .destructive) {
|
|
deleteHistory(.week)
|
|
},
|
|
AlertButton("Past month", role: .destructive) {
|
|
deleteHistory(.month)
|
|
},
|
|
AlertButton("All time", role: .destructive) {
|
|
deleteHistory(.allTime)
|
|
}
|
|
]
|
|
)
|
|
}
|
|
|
|
func deleteHistory(_ deleteRange: HistoryDeleteRange) {
|
|
do {
|
|
try PersistenceController.shared.batchDeleteHistory(range: deleteRange)
|
|
} catch {
|
|
toastModel.updateToastDescription("History delete error: \(error)")
|
|
}
|
|
}
|
|
}
|
|
|
|
struct HistoryActionsView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
HistoryActionsView()
|
|
}
|
|
}
|