Fixed bug that caused crash when using start all/stop all button when chat bot not initialized; changed chat bot message active state to only use wails events
This commit is contained in:
parent
5c3fa663a1
commit
cdbaf8ff14
10
app.go
10
app.go
|
@ -339,6 +339,10 @@ func (a *App) LoginChatBot(cid string, username string, password string, streamU
|
|||
}
|
||||
|
||||
func (a *App) StopAllChatBot(cid string) error {
|
||||
if a.cb == nil {
|
||||
return fmt.Errorf("Chat bot not initialized.")
|
||||
}
|
||||
|
||||
err := a.cb.StopAllMessages()
|
||||
if err != nil {
|
||||
a.logError.Println("error stopping all chat bot messages:", err)
|
||||
|
@ -349,6 +353,10 @@ func (a *App) StopAllChatBot(cid string) error {
|
|||
}
|
||||
|
||||
func (a *App) StartAllChatBot(cid string) error {
|
||||
if a.cb == nil {
|
||||
return fmt.Errorf("Chat bot not initialized.")
|
||||
}
|
||||
|
||||
err := a.cb.StartAllMessages()
|
||||
if err != nil {
|
||||
a.logError.Println("error starting all chat bot messages:", err)
|
||||
|
@ -365,7 +373,7 @@ func (a *App) UpdateChatBotUrl(cid string, streamUrl string) error {
|
|||
defer a.cfgMu.Unlock()
|
||||
|
||||
if a.cb == nil {
|
||||
return fmt.Errorf("Chat bot not initalized.")
|
||||
return fmt.Errorf("Chat bot not initialized.")
|
||||
}
|
||||
|
||||
err := a.resetChatBot()
|
||||
|
|
|
@ -65,7 +65,8 @@ function StreamChatBot(props) {
|
|||
export default StreamChatBot;
|
||||
|
||||
function StreamChatItem(props) {
|
||||
const [active, setActive] = useState(props.isMessageActive(props.chat.id));
|
||||
// const [active, setActive] = useState(props.isMessageActive(props.chat.id));
|
||||
const [active, setActive] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [filename, setFilename] = useState(props.chat.text_file);
|
||||
|
||||
|
@ -75,13 +76,13 @@ function StreamChatItem(props) {
|
|||
setFilename(name);
|
||||
});
|
||||
}
|
||||
setActive(props.isMessageActive(props.chat.id));
|
||||
// setActive(props.isMessageActive(props.chat.id));
|
||||
}, [props]);
|
||||
|
||||
const changeActive = (bool) => {
|
||||
// console.log('ChangeActive:', bool);
|
||||
// props.chat.active = bool;
|
||||
props.activateMessage(props.chat.id, bool);
|
||||
// props.activateMessage(props.chat.id, bool);
|
||||
setActive(bool);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue