Skip to content

Commit

Permalink
AudioPlayer features #58: Fix: Remove files.
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Jan 11, 2020
1 parent 5a7fe54 commit ac9c8e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ReaderTranslatorPlayer/Views/ViewModes/FileListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import SwiftUI
struct FileListView: View {
@ObservedObject var fileStore = FileStore.shared
@ObservedObject var audioStore = AudioStore.shared
@State var files = FileStore.shared.files

var body: some View {
List {
ForEach(fileStore.files, id: \.self) { url in
ForEach(files, id: \.self) { url in
Button(action: {
self.audioStore.play(url)
}, label: {
Expand All @@ -26,9 +27,10 @@ struct FileListView: View {
}
.onDelete { indexSet in
guard let first = indexSet.first else { return }
let file = self.fileStore.files[first]
let file = self.files[first]
do {
try FileManager.default.removeItem(at: file)
self.files = self.fileStore.files
} catch {
print(error)
}
Expand Down

0 comments on commit ac9c8e3

Please sign in to comment.