Skip to content

Commit 68120bc

Browse files
authored
Merge pull request #251 from TaskarCenterAtUW/undo-revert-action
call undo in onRevert
2 parents 9718f2b + 7984d0d commit 68120bc

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

GoInfoGame/GoInfoGame/UI/Map/MapView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct MapView: View {
147147
onRemovePreview: {
148148
},
149149
onRevert: { id, type in
150-
150+
MapUndoManager.shared.undo(for: Int64(id), type: type)
151151
}
152152
)
153153
.padding(.bottom, 24)

GoInfoGame/GoInfoGame/UI/Utils/UndoButton.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct UndoButton: View {
2323
if showSidebar {
2424
UndoSidebarView(
2525
onUndo: { id, type in
26-
MapUndoManager.shared.undo(for: Int64(id), type: type)
2726
onRevert(id, type)
2827
undoItems = MapUndoManager.shared.getUndoItems()
2928
withAnimation { showSidebar = false }
@@ -90,8 +89,7 @@ struct UndoButton: View {
9089
Spacer()
9190

9291
Button("Revert") {
93-
MapUndoManager.shared.undo(for: Int64(item.elementId), type: item.type)
94-
onRevert(item.elementId, item.type)
92+
onRevert(item.elementId, item.type)
9593
showUndoPopup = false
9694
showSidebar = false
9795
}

GoInfoGame/GoInfoGame/quests/QuestUndoManager.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ class MapUndoManager {
6666

6767
do {
6868
try realm.write {
69-
// Step 1: Clear all tags in edited
7069
edited.tags.removeAll()
7170

72-
// Step 2: Copy original tags except gig tags
7371
for entry in original.tags {
7472
let key = entry.key
7573
let value = entry.value
@@ -78,7 +76,6 @@ class MapUndoManager {
7876
}
7977
}
8078

81-
// Step 3: Restore location
8279
edited.point = original.point
8380
}
8481
} catch {

0 commit comments

Comments
 (0)