Added error modals to dashboard

This commit is contained in:
tyler 2024-01-06 12:10:39 -05:00
parent ab3bcbb753
commit 469d0b1a1c
3 changed files with 26 additions and 6 deletions

View file

@ -17,6 +17,7 @@ import { EventsEmit, EventsOn } from '../../wailsjs/runtime/runtime';
import { Heart, Star } from '../assets/icons';
import { ChatBotModal } from '../components/ChatBot';
import Highlight from '../components/Highlight';
import { SmallModal } from '../components/Modal';
import StreamEvent from '../components/StreamEvent';
import StreamActivity from '../components/StreamActivity';
import StreamChat from '../components/StreamChat';
@ -27,6 +28,7 @@ import { StreamChatMessageItem, StreamChatMessageModal } from '../components/Str
function Dashboard() {
const location = useLocation();
const navigate = useNavigate();
const [error, setError] = useState('');
const [refresh, setRefresh] = useState(false);
const [active, setActive] = useState(false);
const [openChatBot, setOpenChatBot] = useState(false);
@ -94,6 +96,7 @@ function Dashboard() {
});
EventsOn('QueryResponseError', (error) => {
setError(error);
console.log('Query response error:', error);
setActive(false);
});
@ -109,6 +112,7 @@ function Dashboard() {
navigate(NavSignIn);
})
.catch((error) => {
setError(error);
console.log('Stop error:', error);
});
};
@ -120,6 +124,7 @@ function Dashboard() {
setActive(true);
})
.catch((error) => {
setError(error);
console.log('Start error:', error);
});
};
@ -176,10 +181,12 @@ function Dashboard() {
setChatBotMessages(messages);
})
.catch((error) => {
setError(error);
console.log('Error deleting message:', error);
});
})
.catch((error) => {
setError(error);
console.log('Error stopping message:', error);
});
};
@ -191,7 +198,10 @@ function Dashboard() {
.then((messages) => {
setChatBotMessages(messages);
})
.catch((error) => console.log('Error saving chat:', error));
.catch((error) => {
setError(error);
console.log('Error saving chat:', error);
});
return;
}
@ -201,7 +211,10 @@ function Dashboard() {
console.log(messages);
setChatBotMessages(messages);
})
.catch((error) => console.log('Error saving chat:', error));
.catch((error) => {
setError(error);
console.log('Error saving chat:', error);
});
};
const saveChatBot = (username, password, url) => {
@ -262,7 +275,6 @@ function Dashboard() {
chats={chatBotMessages}
onAdd={newChat}
onEdit={editChat}
onRefresh={() => setRefresh(!refresh)}
onSettings={() => setOpenChatBot(true)}
title={'Stream Chat'}
/>
@ -283,6 +295,17 @@ function Dashboard() {
// settings={openModal}
/>
</div>
{error !== '' && (
<SmallModal
onClose={() => setError('')}
show={error !== ''}
style={{ minWidth: '300px', maxWidth: '200px', maxHeight: '200px' }}
title={'Error'}
message={error}
submitButton={'OK'}
onSubmit={() => setError('')}
/>
)}
</>
);
}

2
go.mod
View file

@ -39,5 +39,3 @@ require (
golang.org/x/text v0.14.0 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
)
// replace github.com/wailsapp/wails/v2 v2.7.1 => /home/tyler/dev/go/pkg/mod

View file

@ -84,7 +84,6 @@ func (a *Api) query(url string) {
client := rumblelivestreamlib.Client{StreamKey: url}
resp, err := client.Request()
if err != nil {
// TODO: log error
a.logError.Println("api: error executing client request:", err)
a.Stop()
runtime.EventsEmit(a.ctx, "QueryResponseError", "Failed to query API")