Backups in Ferrite archive a user's bookmarks, history, source lists, and source names. Sources are not archived due to the size of the backup increasing exponentially. These files use the .feb format to avoid JSON conflicts when opening the file in Ferrite. The backup file can be renamed to JSON for editing at any time. Add the Backport namespace to be used for ported features rather than making a file for every iOS 14 adaptation. Move history and bookmark creation to the PersistenceController rather than individual functions. 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()
|
|
}
|
|
}
|