Fix AttributeGraph cycle

Closes: https://github.com/damus-io/damus/issues/3342
Changelog-Fixed: Fixed an issue where the mute list view may occasionally freeze the app
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-11-26 15:40:39 -08:00
parent 7eafe973d9
commit 44dfda8d33

View File

@@ -17,6 +17,8 @@ struct MutelistView: View {
@State var words: [MuteItem] = [] @State var words: [MuteItem] = []
@State var new_text: String = "" @State var new_text: String = ""
@State var paddingBottom: CGFloat = 30
func RemoveAction(item: MuteItem) -> some View { func RemoveAction(item: MuteItem) -> some View {
Button { Button {
@@ -91,7 +93,7 @@ struct MutelistView: View {
} }
Section( Section(
header: Text(NSLocalizedString("Users", comment: "Section header title for a list of muted users.")), header: Text(NSLocalizedString("Users", comment: "Section header title for a list of muted users.")),
footer: Text("").padding(.bottom, 10 + tabHeight + getSafeAreaBottom()) footer: VStack { EmptyView() }.padding(.bottom, paddingBottom)
) { ) {
ForEach(users, id: \.self) { user in ForEach(users, id: \.self) { user in
if case let MuteItem.user(pubkey, _) = user { if case let MuteItem.user(pubkey, _) = user {
@@ -110,6 +112,9 @@ struct MutelistView: View {
.navigationTitle(NSLocalizedString("Muted", comment: "Navigation title of view to see list of muted users & phrases.")) .navigationTitle(NSLocalizedString("Muted", comment: "Navigation title of view to see list of muted users & phrases."))
.onAppear { .onAppear {
updateMuteItems() updateMuteItems()
// Note: Do not place this calculation on the view body, otherwise AttributeGraph cycles may occur, freezing the entire app
// FUTURE FIXME: The way the floating tab bar layout was setup feels a bit hacky. Can't we make that work without introspecting sizes of objects and manually computing layout numbers?
paddingBottom = 10 + tabHeight + getSafeAreaBottom()
} }
.onReceive(handle_notify(.new_mutes)) { new_mutes in .onReceive(handle_notify(.new_mutes)) { new_mutes in
updateMuteItems() updateMuteItems()