Skip to content

Commit

Permalink
fixed deleteitem bug, disabled haptics
Browse files Browse the repository at this point in the history
  • Loading branch information
drpeterrohde committed Dec 29, 2022
1 parent 41a1982 commit 660eeed
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion MoodSnap/Base/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
let quoteFrequency = 11

/// Haptics
let hapticsEnabled = true
let hapticsEnabled = false

/// Time windows
let influenceWindowShort = 7
Expand Down
4 changes: 2 additions & 2 deletions MoodSnap/Base/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ import SwiftUI
/**
Delete a `moodSnap` from an array of `moodSnaps`.
*/
@inline(__always) func deleteHistoryItem(data: DataStoreClass, moodSnap: MoodSnapStruct) {
data.moodSnaps = data.moodSnaps.filter { $0.id != moodSnap.id }
@inline(__always) func deleteHistoryItem(data: DataStoreClass, moodSnap: MoodSnapStruct) -> [MoodSnapStruct] {
return data.moodSnaps.filter { $0.id != moodSnap.id }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion MoodSnap/HistoryView/HistoryItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct HistoryItemView: View {
DispatchQueue.main.async {
withAnimation {
data.stopProcessing()
deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps = deleteHistoryItem(data: data, moodSnap: moodSnap)
data.startProcessing()
}
}
Expand Down
2 changes: 1 addition & 1 deletion MoodSnap/MainViews/EventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct EventView: View {
withAnimation {
data.stopProcessing()
moodSnap.snapType = .event
deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps = deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps.append(moodSnap)
data.moodSnaps = sortByDate(moodSnaps: data.moodSnaps)
data.startProcessing()
Expand Down
2 changes: 1 addition & 1 deletion MoodSnap/MainViews/MediaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct MediaView: View {
if data.settings.saveMediaToCameraRoll {
UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil)
}
deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps = deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps.append(moodSnap)
data.moodSnaps = sortByDate(moodSnaps: data.moodSnaps)
}
Expand Down
2 changes: 1 addition & 1 deletion MoodSnap/MainViews/MoodSnapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ struct MoodSnapView: View {
withAnimation {
data.stopProcessing()
moodSnap.snapType = .mood
deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps = deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps.append(moodSnap)
data.moodSnaps = sortByDate(moodSnaps: data.moodSnaps)
data.settings.addedSnaps += 1
Expand Down
2 changes: 1 addition & 1 deletion MoodSnap/MainViews/NoteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct NoteView: View {
withAnimation {
data.stopProcessing()
moodSnap.snapType = .note
deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps = deleteHistoryItem(data: data, moodSnap: moodSnap)
data.moodSnaps.append(moodSnap)
data.moodSnaps = sortByDate(moodSnaps: data.moodSnaps)
data.startProcessing()
Expand Down

0 comments on commit 660eeed

Please sign in to comment.