Skip to content

Commit

Permalink
feat: delete docs
Browse files Browse the repository at this point in the history
  • Loading branch information
reez authored Jan 29, 2024
1 parent a67a3af commit 4f4f857
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 75 deletions.
4 changes: 0 additions & 4 deletions LDKNodeMonday.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
AE1D9BEC2B2A1FFD00620748 /* BitcoinUI in Frameworks */ = {isa = PBXBuildFile; productRef = AE1D9BEB2B2A1FFD00620748 /* BitcoinUI */; };
AE1D9C0B2B2A251500620748 /* ChannelDetails+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE1D9C0A2B2A251500620748 /* ChannelDetails+Extensions.swift */; };
AE49E84C2A24F96F002623E8 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE49E84B2A24F96F002623E8 /* Constants.swift */; };
AE49E84E2A24FDD7002623E8 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE49E84D2A24FDD7002623E8 /* FileManager+Extensions.swift */; };
AE49E8502A2535E3002623E8 /* TabHomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE49E84F2A2535E3002623E8 /* TabHomeViewModel.swift */; };
AE49E8522A253618002623E8 /* StartViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE49E8512A253618002623E8 /* StartViewModel.swift */; };
AE49E8542A253647002623E8 /* BitcoinViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE49E8532A253647002623E8 /* BitcoinViewModel.swift */; };
Expand Down Expand Up @@ -111,7 +110,6 @@
AE186B8D2A1540B700338463 /* StartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartView.swift; sourceTree = "<group>"; };
AE1D9C0A2B2A251500620748 /* ChannelDetails+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ChannelDetails+Extensions.swift"; sourceTree = "<group>"; };
AE49E84B2A24F96F002623E8 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
AE49E84D2A24FDD7002623E8 /* FileManager+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+Extensions.swift"; sourceTree = "<group>"; };
AE49E84F2A2535E3002623E8 /* TabHomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabHomeViewModel.swift; sourceTree = "<group>"; };
AE49E8512A253618002623E8 /* StartViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartViewModel.swift; sourceTree = "<group>"; };
AE49E8532A253647002623E8 /* BitcoinViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BitcoinViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -500,7 +498,6 @@
AEE8FDDC29F855E700406DD9 /* String+Extensions.swift */,
AE6BB56E2A008CBA009E16E3 /* UInt64+Extensions.swift */,
AE0BD4AB2B598C3F00B9901E /* UInt32+Extensions.swift */,
AE49E84D2A24FDD7002623E8 /* FileManager+Extensions.swift */,
AE51BEF92B37A2A500BAE452 /* Event+Extensions.swift */,
AEDF47F22B3FBAB900145D64 /* Notification+Extensions.swift */,
AE0055112B47A65700100797 /* Color+Extensions.swift */,
Expand Down Expand Up @@ -599,7 +596,6 @@
buildActionMask = 2147483647;
files = (
AE83142629AED67B00088A70 /* MondayError.swift in Sources */,
AE49E84E2A24FDD7002623E8 /* FileManager+Extensions.swift in Sources */,
AE49E8562A253674002623E8 /* AddressViewModel.swift in Sources */,
AE7096352B5C205F0038BE56 /* PriceServiceError.swift in Sources */,
AE186B8E2A1540B700338463 /* StartView.swift in Sources */,
Expand Down
43 changes: 0 additions & 43 deletions LDKNodeMonday/Extensions/FileManager+Extensions.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,10 @@ extension LightningNodeService {
try keyService.saveBackupInfo(backupInfo)
}
}

// Delete Documents
extension LightningNodeService {
func deleteDocuments() throws {
try storageManager.deleteAllContentsInDocuments()
}
}
18 changes: 18 additions & 0 deletions LDKNodeMonday/Service/Lightning Service/LightningStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,22 @@ struct LightningStorage {
let pathString = path.path
return pathString
}

func deleteAllContentsInDocuments() throws {
let fileManager = FileManager.default
let documentsURL = try fileManager.url(
for: .documentDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: false
)
let contents = try fileManager.contentsOfDirectory(
at: documentsURL,
includingPropertiesForKeys: nil,
options: []
)
for fileURL in contents {
try fileManager.removeItem(at: fileURL)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class NodeIDViewModel: ObservableObject {
// Delete network and URL settings using KeyClient
try KeyClient.live.deleteNetwork()
try KeyClient.live.deleteEsplora()
// ... then delete all files
try LightningNodeService.shared.deleteDocuments()
// ... then set isOnboarding to true
self.isOnboarding = true
// ... which should send you back to OnboardingView
Expand Down
56 changes: 28 additions & 28 deletions LDKNodeMonday/View/Lightning/NodeID/NodeIDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,97 +83,97 @@ struct NodeIDView: View {
VStack(spacing: 20) {

Button {
showingStopNodeConfirmation = true
showingShowSeedConfirmation = true
} label: {
HStack {
Image(systemName: "xmark")
Text("Stop Node")
Image(systemName: "list.number")
Text("Show Seed")
}
.foregroundColor(Color(uiColor: UIColor.systemBackground))
.bold()
.frame(width: 130)
.frame(width: 200)
}
.buttonBorderShape(.capsule)
.buttonStyle(.borderedProminent)
.tint(.red)
.alert(
"Are you sure you want to stop the node?",
isPresented: $showingStopNodeConfirmation
"Are you sure you want to view the seed?",
isPresented: $showingShowSeedConfirmation
) {
Button("Yes", role: .destructive) {
viewModel.stop()
isSeedPresented = true
}
Button("No", role: .cancel) {}
}

Button {
showingShowSeedConfirmation = true
showingStopNodeConfirmation = true
} label: {
HStack {
Image(systemName: "list.number")
Text("Show Seed")
Image(systemName: "xmark")
Text("Stop Node")
}
.foregroundColor(Color(uiColor: UIColor.systemBackground))
.bold()
.frame(width: 130)
.frame(width: 200)
}
.buttonBorderShape(.capsule)
.buttonStyle(.borderedProminent)
.tint(.red)
.alert(
"Are you sure you want to view the seed?",
isPresented: $showingShowSeedConfirmation
"Are you sure you want to stop the node?",
isPresented: $showingStopNodeConfirmation
) {
Button("Yes", role: .destructive) {
isSeedPresented = true
viewModel.stop()
}
Button("No", role: .cancel) {}
}

Button {
showingDeleteSeedConfirmation = true
showingResetAppConfirmation = true
} label: {
HStack {
Image(systemName: "minus")
Text("Delete Seed")
Image(systemName: "arrow.uturn.backward")
Text("Reset Preferences")
}
.foregroundColor(Color(uiColor: UIColor.systemBackground))
.bold()
.frame(width: 130)
.frame(width: 200)
}
.buttonBorderShape(.capsule)
.buttonStyle(.borderedProminent)
.tint(.red)
.alert(
"Are you sure you want to delete the seed?",
isPresented: $showingDeleteSeedConfirmation
"Are you sure you want to reset preferences?",
isPresented: $showingResetAppConfirmation
) {
Button("Yes", role: .destructive) {
viewModel.delete()
viewModel.onboarding()
}
Button("No", role: .cancel) {}
}

Button {
showingResetAppConfirmation = true
showingDeleteSeedConfirmation = true
} label: {
HStack {
Image(systemName: "figure.snowboarding")
Text("Reset App")
Image(systemName: "minus")
Text("Delete Seed")
}
.foregroundColor(Color(uiColor: UIColor.systemBackground))
.bold()
.frame(width: 130)
.frame(width: 200)
}
.buttonBorderShape(.capsule)
.buttonStyle(.borderedProminent)
.tint(.red)
.alert(
"Are you sure you want to reset the app?",
isPresented: $showingResetAppConfirmation
"Are you sure you want to reset preferences and delete the seed?",
isPresented: $showingDeleteSeedConfirmation
) {
Button("Yes", role: .destructive) {
viewModel.onboarding()
viewModel.delete()
}
Button("No", role: .cancel) {}
}
Expand Down

0 comments on commit 4f4f857

Please sign in to comment.