Devlog: January 25, 2023

I’ll be brief because kids are crying and we need to eat dinner soon.

I did a small revamp of history. I was storing each time a comparison ran, even if the two movies or shows were exactly the same. So first, I added a toggle to hide duplicates. Then I started on deletion. I wanted to show all items when you went to delete them. It started to get a bit unwieldy. So I removed that setting. Back to seeing all your comparisons. Then I decided, instead of adding a new entry each time, if there is an existing one, update the history item. Maybe I can add a counter for the number of times those two were compared or something.

Anyway, came full circle a couple times, but happy where I landed.

Did have a strange issue with EditMode where the environment was not being set how I would expect. I ended up having to declare my own EditMode state and then pass that as an environment to EditButton and my List. Otherwise, my History View had no idea if the list was editing or not.

struct History: View {
    @State var editMode: EditMode = .inactive
    
    var body: some View {
        List {
            ForEach(historyItems) { historyItem in
                ...
            }
            .onDelete { indexSet in
                ...
            }
        }
        .environment(\.editMode, $editMode)
        .navigationTitle("History")
        .toolbar {
            ToolbarItem(placement: .primaryAction) {
                EditButton()
                    .environment(\.editMode, $editMode)
            }
        }
    }
}


Date
January 25, 2023