Add unmute option in profile view

Changelog-Added: Add unmute option in profile view
Closes: #1050
This commit is contained in:
Joshua Jiang
2023-04-29 18:09:53 -07:00
committed by William Casarin
parent 5f64f54ef5
commit 94a29e2c2f
2 changed files with 23 additions and 2 deletions

View File

@@ -44,6 +44,9 @@ struct MutelistView: View {
}
}
.navigationTitle(NSLocalizedString("Muted Users", comment: "Navigation title of view to see list of muted users."))
.onAppear {
users = get_mutelist_users(damus_state.contacts.mutelist)
}
}
}

View File

@@ -205,8 +205,26 @@ struct ProfileView: View {
notify(.report, target)
}
Button(NSLocalizedString("Mute", comment: "Button to mute a profile."), role: .destructive) {
notify(.mute, profile.pubkey)
if damus_state.contacts.is_muted(profile.pubkey) {
Button(NSLocalizedString("Unmute", comment: "Button to unmute a profile.")) {
guard
let keypair = damus_state.keypair.to_full(),
let mutelist = damus_state.contacts.mutelist
else {
return
}
guard let new_ev = remove_from_mutelist(keypair: keypair, prev: mutelist, to_remove: profile.pubkey) else {
return
}
damus_state.contacts.set_mutelist(new_ev)
damus_state.postbox.send(new_ev)
}
} else {
Button(NSLocalizedString("Mute", comment: "Button to mute a profile."), role: .destructive) {
notify(.mute, profile.pubkey)
}
}
}
}