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 {
|
func (a *App) StopAllChatBot(cid string) error {
|
||||||
|
if a.cb == nil {
|
||||||
|
return fmt.Errorf("Chat bot not initialized.")
|
||||||
|
}
|
||||||
|
|
||||||
err := a.cb.StopAllMessages()
|
err := a.cb.StopAllMessages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.logError.Println("error stopping all chat bot messages:", err)
|
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 {
|
func (a *App) StartAllChatBot(cid string) error {
|
||||||
|
if a.cb == nil {
|
||||||
|
return fmt.Errorf("Chat bot not initialized.")
|
||||||
|
}
|
||||||
|
|
||||||
err := a.cb.StartAllMessages()
|
err := a.cb.StartAllMessages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.logError.Println("error starting all chat bot messages:", err)
|
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()
|
defer a.cfgMu.Unlock()
|
||||||
|
|
||||||
if a.cb == nil {
|
if a.cb == nil {
|
||||||
return fmt.Errorf("Chat bot not initalized.")
|
return fmt.Errorf("Chat bot not initialized.")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := a.resetChatBot()
|
err := a.resetChatBot()
|
||||||
|
|
|
@ -65,7 +65,8 @@ function StreamChatBot(props) {
|
||||||
export default StreamChatBot;
|
export default StreamChatBot;
|
||||||
|
|
||||||
function StreamChatItem(props) {
|
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 [error, setError] = useState('');
|
||||||
const [filename, setFilename] = useState(props.chat.text_file);
|
const [filename, setFilename] = useState(props.chat.text_file);
|
||||||
|
|
||||||
|
@ -75,13 +76,13 @@ function StreamChatItem(props) {
|
||||||
setFilename(name);
|
setFilename(name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setActive(props.isMessageActive(props.chat.id));
|
// setActive(props.isMessageActive(props.chat.id));
|
||||||
}, [props]);
|
}, [props]);
|
||||||
|
|
||||||
const changeActive = (bool) => {
|
const changeActive = (bool) => {
|
||||||
// console.log('ChangeActive:', bool);
|
// console.log('ChangeActive:', bool);
|
||||||
// props.chat.active = bool;
|
// props.chat.active = bool;
|
||||||
props.activateMessage(props.chat.id, bool);
|
// props.activateMessage(props.chat.id, bool);
|
||||||
setActive(bool);
|
setActive(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue