@@ -22,7 +22,7 @@ const StateUpdateSetShift = StateUpdateType("set_shift")
2222const StateUpdateMode = StateUpdateType ("set_mode" )
2323const StateUpdateOutputFormat = StateUpdateType ("set_output_format" )
2424const StateTogglePreview = StateUpdateType ("toggle_preview" )
25- const StateToggleBoomerMode = StateUpdateType ("toggle_boomer_mode " )
25+ const StateSetBoomerModeNumGifs = StateUpdateType ("set_boomer_mode_num_gifs " )
2626
2727type Mode string
2828
@@ -31,6 +31,7 @@ const (
3131 StickerMode Mode = "sticker"
3232 CaptionMode Mode = "caption"
3333 VideoMode Mode = "video"
34+ BoomerMode Mode = "boomer"
3435)
3536
3637type OutputFileType string
@@ -52,7 +53,7 @@ type Settings struct {
5253 SubsEnabled bool `json:"d,omitempty"`
5354 OutputFormat OutputFileType `json:"o,omitempty"`
5455 DisablePreviewImage bool `json:"n,omitempty"`
55- BoomerMode bool `json:"bm,omitempty"`
56+ BoomerModeNumGifs int `json:"bm,omitempty"`
5657}
5758
5859// rawSettings is just Settings with simple types used for encoding/decoding
@@ -66,7 +67,7 @@ type rawSettings struct {
6667 SubsEnabled bool `json:"d,omitempty"`
6768 OutputFormat OutputFileType `json:"o,omitempty"`
6869 DisablePreview bool `json:"n,omitempty"`
69- BoomerMode bool `json:"bm,omitempty"`
70+ BoomerMode int `json:"bm,omitempty"`
7071}
7172
7273func (c * Settings ) UnmarshalJSON (bytes []byte ) error {
@@ -94,7 +95,7 @@ func (c *Settings) UnmarshalJSON(bytes []byte) error {
9495 c .SubsEnabled = raw .SubsEnabled
9596 c .OutputFormat = raw .OutputFormat
9697 c .DisablePreviewImage = raw .DisablePreview
97- c .BoomerMode = raw .BoomerMode
98+ c .BoomerModeNumGifs = raw .BoomerMode
9899
99100 return nil
100101}
@@ -110,7 +111,7 @@ func (c *Settings) MarshalJSON() ([]byte, error) {
110111 SubsEnabled : c .SubsEnabled ,
111112 OutputFormat : c .OutputFormat ,
112113 DisablePreview : c .DisablePreviewImage ,
113- BoomerMode : c .BoomerMode ,
114+ BoomerMode : c .BoomerModeNumGifs ,
114115 })
115116}
116117
@@ -264,20 +265,26 @@ func (c *PreviewState) ApplyUpdate(upd StateUpdate) error {
264265 c .Settings .Shift = time .Duration (floatVal )
265266 case StateUpdateMode :
266267 if strVal , ok := upd .Value .(string ); ! ok {
267- return fmt .Errorf ("%s was not expected type (wanted Mode got %T)" , upd .Type , upd .Value )
268+ return fmt .Errorf ("%s was not expected type (wanted string got %T)" , upd .Type , upd .Value )
268269 } else {
269270 c .Settings .Mode = Mode (strVal )
270271 }
271272 case StateUpdateOutputFormat :
272273 if strVal , ok := upd .Value .(string ); ! ok {
273- return fmt .Errorf ("%s was not expected type (wanted Mode got %T)" , upd .Type , upd .Value )
274+ return fmt .Errorf ("%s was not expected type (wanted string got %T)" , upd .Type , upd .Value )
274275 } else {
275276 c .Settings .OutputFormat = OutputFileType (strVal )
276277 }
277278 case StateTogglePreview :
278279 c .Settings .DisablePreviewImage = ! c .Settings .DisablePreviewImage
279- case StateToggleBoomerMode :
280- c .Settings .BoomerMode = ! c .Settings .BoomerMode
280+ case StateSetBoomerModeNumGifs :
281+ if intVal , ok := upd .Value .(float64 ); ! ok {
282+ c .Settings .BoomerModeNumGifs = 0
283+ return fmt .Errorf ("%s was not expected type (wanted float64 got %T)" , upd .Type , upd .Value )
284+ } else {
285+ c .Settings .BoomerModeNumGifs = int (intVal )
286+ }
287+
281288 }
282289
283290 return nil
@@ -346,8 +353,8 @@ func TogglePreview() StateUpdate {
346353 return newStateUpdate (StateTogglePreview , nil )
347354}
348355
349- func ToggleBoomerMode ( ) StateUpdate {
350- return newStateUpdate (StateToggleBoomerMode , nil )
356+ func SetBoomerModeNumGifs ( num int ) StateUpdate {
357+ return newStateUpdate (StateSetBoomerModeNumGifs , num )
351358}
352359
353360func StateSetOutputFormat (format OutputFileType ) StateUpdate {
0 commit comments