Skip to content

Commit 17354fa

Browse files
slugaliskjbpratt
authored andcommitted
update viewer state when opt in/out changes
1 parent 5969c97 commit 17354fa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

viewerstate.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ type ViewerState struct {
4848
Channel *StreamChannel `json:"channel"`
4949
}
5050

51+
// Equals check if two ViewerStates are identical
52+
func (s *ViewerState) Equals(o *ViewerState) bool {
53+
if s == nil || o == nil {
54+
return s == o
55+
}
56+
return s.Online == o.Online && s.EnablePublicState == o.EnablePublicState && s.Channel.Equals(o.Channel)
57+
}
58+
5159
// StreamChannel rustla channel definition
5260
type StreamChannel struct {
5361
Channel string `json:"channel"`
@@ -147,7 +155,7 @@ func (v *ViewerStateStore) updatePublicState(state *ViewerState) {
147155
return
148156
}
149157

150-
if ok && prev.Channel.Equals(state.Channel) {
158+
if ok && prev.Equals(state) {
151159
return
152160
}
153161

0 commit comments

Comments
 (0)