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

@@ -18,6 +18,8 @@ struct MutelistView: View {
@State var new_text: String = ""
@State var paddingBottom: CGFloat = 30
func RemoveAction(item: MuteItem) -> some View {
Button {
guard let mutelist = damus_state.mutelist_manager.event,
@@ -91,7 +93,7 @@ struct MutelistView: View {
}
Section(
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
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."))
.onAppear {
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
updateMuteItems()