From 469d0b1a1c759042fab46a05a2f17af0e42707b0 Mon Sep 17 00:00:00 2001 From: tyler Date: Sat, 6 Jan 2024 12:10:39 -0500 Subject: [PATCH] Added error modals to dashboard --- frontend/src/screens/Dashboard.jsx | 29 ++++++++++++++++++++++++++--- go.mod | 2 -- internal/api/api.go | 1 - 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/frontend/src/screens/Dashboard.jsx b/frontend/src/screens/Dashboard.jsx index b679cdd..7e7036d 100644 --- a/frontend/src/screens/Dashboard.jsx +++ b/frontend/src/screens/Dashboard.jsx @@ -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} /> + {error !== '' && ( + setError('')} + show={error !== ''} + style={{ minWidth: '300px', maxWidth: '200px', maxHeight: '200px' }} + title={'Error'} + message={error} + submitButton={'OK'} + onSubmit={() => setError('')} + /> + )} ); } diff --git a/go.mod b/go.mod index e319a77..dbe7c77 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/internal/api/api.go b/internal/api/api.go index f98395c..188c115 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -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")