Compare commits

..

2 Commits
b1.0.0 ... main

4 changed files with 32 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.burgernotes/ .burgernotes/
packages/ packages/
.DS_Store .DS_Store
Burgernotes.xcodeproj/project.xcworkspace/xcuserdata/ffqq.xcuserdatad/UserInterfaceState.xcuserstate

View File

@ -24,7 +24,6 @@
"buildVersion": "1", "buildVersion": "1",
"date": "2024-02-29", "date": "2024-02-29",
"downloadURL": "https://centrifuge.hectabit.org/HectaBit/Burgernotes-iOS/releases/download/b1.0.0/Burgernotes.ipa", "downloadURL": "https://centrifuge.hectabit.org/HectaBit/Burgernotes-iOS/releases/download/b1.0.0/Burgernotes.ipa",
"size": 79821,
"minOSVersion": "15.0", "minOSVersion": "15.0",
}, },
], ],

View File

@ -43,7 +43,7 @@ struct ContentView: View {
@AppStorage("Username") var storedUsername: String? // Usernames are stored in UserDefaults for the sake of convenience @AppStorage("Username") var storedUsername: String? // Usernames are stored in UserDefaults for the sake of convenience
let keychain = KeychainSwift() let keychain = KeychainSwift()
func login() { func login() {
let hashHelper = HashHelper() let hashHelper = HashHelper()
// Use HashHelper to hash our password // Use HashHelper to hash our password
@ -212,14 +212,13 @@ struct ContentView: View {
} }
.padding() .padding()
Text("Burgernotes")
.font(.title)
.padding()
Group { Group {
if isOnline { if isOnline {
if !usingSettings { if !usingSettings {
if !isEditing { if !isEditing {
Text("Burgernotes")
.font(.title)
.padding()
List { List {
ForEach(notes, id: \.id) { note in ForEach(notes, id: \.id) { note in
let noteTitle = note.title.decrypt(password: encryptionKey ?? "this bum ain't got an encryption key!!!") let noteTitle = note.title.decrypt(password: encryptionKey ?? "this bum ain't got an encryption key!!!")
@ -285,6 +284,7 @@ struct ContentView: View {
}) { }) {
Image(systemName: "chevron.left") Image(systemName: "chevron.left")
.imageScale(.large) .imageScale(.large)
Text("Back")
} }
.padding() .padding()
Spacer() Spacer()
@ -352,6 +352,31 @@ struct ContentView: View {
Text("Sign out") Text("Sign out")
.foregroundStyle(Color.red) // Set the text color to red .foregroundStyle(Color.red) // Set the text color to red
} }
Button(action: {
let dialog = UIAlertController(title: "Delete my account", message: "Are you sure you want to delete your account? THIS CANNOT BE REVERSED", preferredStyle: .alert)
// In the case of a signout:
let deleteAccount = UIAlertAction(title: "Yes", style: .destructive) { _ in
guard let url = URL(string: "https://notes.hectabit.org/api/deleteaccount") else { return }
let parameters = ["secretKey": "\(secretKey ?? "bum")"]
JSONHelper.sendJSONRequest(url: url, parameters: parameters) { result in
switch result {
case .success:
keychain.delete("secretKey")
UserDefaults.standard.removeObject(forKey: "Username") // This will also trigger SwiftUI to change vstacks
keychain.delete("encryptionKey")
usingSettings = false
case .failure(let error):
print("Failed to delete account: \(error)") // This is not supposed to happen under any circumstances unless the session was deauthorized remotely
}
}
}
let no = UIAlertAction(title: "No", style: .default)
dialog.addAction(deleteAccount);dialog.addAction(no)
if let topVC = UIApplication.shared.keyWindow?.rootViewController { topVC.present(dialog, animated: true) } // We can keep using keyWindow, it's not a big deal for this specific usecase that it's deprecated
}) {
Text("Delete my account")
.foregroundStyle(Color.red) // Set the text color to red
}
} }
} }
} else { } else {
@ -428,7 +453,7 @@ struct ContentView: View {
.edgesIgnoringSafeArea(.all) .edgesIgnoringSafeArea(.all)
} }
} }
// Fetch notes // Fetch notes
private func fetchNotes() { private func fetchNotes() {
let secretKey = keychain.get("secretKey") let secretKey = keychain.get("secretKey")