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:
@@ -17,6 +17,8 @@ struct MutelistView: View {
|
||||
@State var words: [MuteItem] = []
|
||||
|
||||
@State var new_text: String = ""
|
||||
|
||||
@State var paddingBottom: CGFloat = 30
|
||||
|
||||
func RemoveAction(item: MuteItem) -> some View {
|
||||
Button {
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user