Skip to content

Commit

Permalink
Save instead of previewing when filename changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Samasaur1 committed May 3, 2023
1 parent 6f93450 commit b86ed9e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Remote Text/FileDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct FileDetailView: View {
@State var fileName = ""
@State var content = ""
@State private var loading = true
@State private var initialFilename = ""
@State private var initialContent = ""

private let id: UUID
Expand All @@ -35,8 +36,9 @@ struct FileDetailView: View {
self.hash = history.refs.first { $0.name == "main" }!.hash
let file = await model.getFile(id: id, atVersion: self.hash)
self.fileName = file.name
self.initialContent = file.content
self.content = file.content
self.initialFilename = file.name
self.initialContent = file.content
self.loading = false
}
}
Expand Down Expand Up @@ -72,7 +74,7 @@ struct FileDetailView: View {
}
.navigationTitle(fileName)
.toolbar {
if self.initialContent == self.content {
if self.initialContent == self.content && self.initialFilename == self.fileName {
ToolbarItem(placement: .navigationBarTrailing) {
NavigationLink(value: ContentView.Navigation.previewFile(id: id, hash: hash, filename: fileName)) {
Text("Preview")
Expand Down

0 comments on commit b86ed9e

Please sign in to comment.