Fixed muting so that it should be consistant. meaning, if a muted user leaves and comes back they should still be muted. Channel mute and unmute now specifically sets mute/unmute for each user so the whole channel is in deed muted or unmuted.
This commit is contained in:
19
barnard.go
19
barnard.go
@ -79,10 +79,19 @@ func (b *Barnard) TreeItemKeyPress(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm
|
|||||||
// Handle mute toggle
|
// Handle mute toggle
|
||||||
if treeItem.Channel != nil {
|
if treeItem.Channel != nil {
|
||||||
if key == *b.Hotkeys.MuteToggle {
|
if key == *b.Hotkeys.MuteToggle {
|
||||||
// Toggle mute for all users in channel
|
// Determine new channel mute state
|
||||||
|
channelWillBeMuted := !b.MutedChannels[treeItem.Channel.ID]
|
||||||
|
|
||||||
|
// Set all users in channel to the same mute state
|
||||||
users := makeUsersArray(treeItem.Channel.Users)
|
users := makeUsersArray(treeItem.Channel.Users)
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
|
// Explicitly set user mute state to match channel state
|
||||||
|
if channelWillBeMuted && !u.LocallyMuted {
|
||||||
b.UserConfig.ToggleMute(u)
|
b.UserConfig.ToggleMute(u)
|
||||||
|
} else if !channelWillBeMuted && u.LocallyMuted {
|
||||||
|
b.UserConfig.ToggleMute(u)
|
||||||
|
}
|
||||||
|
|
||||||
if u.AudioSource != nil {
|
if u.AudioSource != nil {
|
||||||
if u.LocallyMuted {
|
if u.LocallyMuted {
|
||||||
u.AudioSource.SetGain(0)
|
u.AudioSource.SetGain(0)
|
||||||
@ -92,15 +101,15 @@ func (b *Barnard) TreeItemKeyPress(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle channel mute state
|
// Update channel mute state
|
||||||
if b.MutedChannels[treeItem.Channel.ID] {
|
if channelWillBeMuted {
|
||||||
delete(b.MutedChannels, treeItem.Channel.ID)
|
|
||||||
} else {
|
|
||||||
b.MutedChannels[treeItem.Channel.ID] = true
|
b.MutedChannels[treeItem.Channel.ID] = true
|
||||||
// If this is the current channel, stop transmission
|
// If this is the current channel, stop transmission
|
||||||
if b.Client.Self.Channel.ID == treeItem.Channel.ID && b.Tx {
|
if b.Client.Self.Channel.ID == treeItem.Channel.ID && b.Tx {
|
||||||
b.StopTransmission()
|
b.StopTransmission()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
delete(b.MutedChannels, treeItem.Channel.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
b.UiTree.Rebuild()
|
b.UiTree.Rebuild()
|
||||||
|
@ -142,9 +142,12 @@ func (b *Barnard) OnUserChange(e *gumble.UserChangeEvent) {
|
|||||||
|
|
||||||
// Check if user is joining a muted channel
|
// Check if user is joining a muted channel
|
||||||
if e.Type.Has(gumble.UserChangeConnected) || e.Type.Has(gumble.UserChangeChannel) {
|
if e.Type.Has(gumble.UserChangeConnected) || e.Type.Has(gumble.UserChangeChannel) {
|
||||||
// If the channel is muted, mute the new user
|
// If the channel is muted, ensure the user is muted
|
||||||
if b.MutedChannels[e.User.Channel.ID] {
|
if b.MutedChannels[e.User.Channel.ID] {
|
||||||
|
// Only mute if not already muted
|
||||||
|
if !e.User.LocallyMuted {
|
||||||
b.UserConfig.ToggleMute(e.User)
|
b.UserConfig.ToggleMute(e.User)
|
||||||
|
}
|
||||||
if e.User.AudioSource != nil {
|
if e.User.AudioSource != nil {
|
||||||
e.User.AudioSource.SetGain(0)
|
e.User.AudioSource.SetGain(0)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user