Warn/show alert when state is not active
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Tyler 2020-01-14 23:40:02 -05:00
parent 8de69d7c40
commit c5db9d1f88
2 changed files with 17 additions and 8 deletions

View File

@ -37,12 +37,12 @@
"Author": "Meow.tf", "Author": "Meow.tf",
"Category": "OBS Replay", "Category": "OBS Replay",
"CodePathWin": "replay.exe", "CodePathWin": "replay.exe",
"Description": "Control OBS' Replays using StreamDeck.", "Description": "Control OBS' Replays using StreamDeck and obs-websocket",
"Name": "OBS Replay", "Name": "OBS Replay",
"Icon": "images/pluginIcon", "Icon": "images/pluginIcon",
"CategoryIcon": "images/pluginIcon", "CategoryIcon": "images/pluginIcon",
"URL": "https://streamdeck.meow.tf/obsreplay", "URL": "https://streamdeck.meow.tf/obsreplay",
"Version": "1.0.0", "Version": "1.0.1",
"SDKVersion": 2, "SDKVersion": 2,
"OS": [ "OS": [
{ {

View File

@ -11,16 +11,16 @@ import (
const ( const (
actionReplayToggle = "tf.meow.obsreplay.replay_toggle" actionReplayToggle = "tf.meow.obsreplay.replay_toggle"
actionReplaySave = "tf.meow.obsreplay.replay_save" actionReplaySave = "tf.meow.obsreplay.replay_save"
) )
var ( var (
contextMutex sync.RWMutex contextMutex sync.RWMutex
clientMutex sync.RWMutex clientMutex sync.RWMutex
stateMutex sync.RWMutex stateMutex sync.RWMutex
clients = make(map[string]*obsws.Client) clients = make(map[string]*obsws.Client)
contexts = make(map[string]string) contexts = make(map[string]string)
cachedStates = make(map[string]int) cachedStates = make(map[string]int)
) )
@ -52,6 +52,15 @@ func replaySave(action, context string, payload *fastjson.Value, deviceId string
return return
} }
stateMutex.RLock()
state, exists := cachedStates[context]
stateMutex.RUnlock()
if exists && state == 0 {
sdk.ShowAlert(context)
return
}
req := obsws.NewSaveReplayBufferRequest() req := obsws.NewSaveReplayBufferRequest()
if err := req.Send(c); err != nil { if err := req.Send(c); err != nil {
@ -253,4 +262,4 @@ func cleanupSockets() {
for _, client := range clients { for _, client := range clients {
client.Disconnect() client.Disconnect()
} }
} }