Added error modals to dashboard
This commit is contained in:
parent
ab3bcbb753
commit
469d0b1a1c
|
@ -17,6 +17,7 @@ import { EventsEmit, EventsOn } from '../../wailsjs/runtime/runtime';
|
||||||
import { Heart, Star } from '../assets/icons';
|
import { Heart, Star } from '../assets/icons';
|
||||||
import { ChatBotModal } from '../components/ChatBot';
|
import { ChatBotModal } from '../components/ChatBot';
|
||||||
import Highlight from '../components/Highlight';
|
import Highlight from '../components/Highlight';
|
||||||
|
import { SmallModal } from '../components/Modal';
|
||||||
import StreamEvent from '../components/StreamEvent';
|
import StreamEvent from '../components/StreamEvent';
|
||||||
import StreamActivity from '../components/StreamActivity';
|
import StreamActivity from '../components/StreamActivity';
|
||||||
import StreamChat from '../components/StreamChat';
|
import StreamChat from '../components/StreamChat';
|
||||||
|
@ -27,6 +28,7 @@ import { StreamChatMessageItem, StreamChatMessageModal } from '../components/Str
|
||||||
function Dashboard() {
|
function Dashboard() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const [error, setError] = useState('');
|
||||||
const [refresh, setRefresh] = useState(false);
|
const [refresh, setRefresh] = useState(false);
|
||||||
const [active, setActive] = useState(false);
|
const [active, setActive] = useState(false);
|
||||||
const [openChatBot, setOpenChatBot] = useState(false);
|
const [openChatBot, setOpenChatBot] = useState(false);
|
||||||
|
@ -94,6 +96,7 @@ function Dashboard() {
|
||||||
});
|
});
|
||||||
|
|
||||||
EventsOn('QueryResponseError', (error) => {
|
EventsOn('QueryResponseError', (error) => {
|
||||||
|
setError(error);
|
||||||
console.log('Query response error:', error);
|
console.log('Query response error:', error);
|
||||||
setActive(false);
|
setActive(false);
|
||||||
});
|
});
|
||||||
|
@ -109,6 +112,7 @@ function Dashboard() {
|
||||||
navigate(NavSignIn);
|
navigate(NavSignIn);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
setError(error);
|
||||||
console.log('Stop error:', error);
|
console.log('Stop error:', error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -120,6 +124,7 @@ function Dashboard() {
|
||||||
setActive(true);
|
setActive(true);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
setError(error);
|
||||||
console.log('Start error:', error);
|
console.log('Start error:', error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -176,10 +181,12 @@ function Dashboard() {
|
||||||
setChatBotMessages(messages);
|
setChatBotMessages(messages);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
setError(error);
|
||||||
console.log('Error deleting message:', error);
|
console.log('Error deleting message:', error);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
setError(error);
|
||||||
console.log('Error stopping message:', error);
|
console.log('Error stopping message:', error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -191,7 +198,10 @@ function Dashboard() {
|
||||||
.then((messages) => {
|
.then((messages) => {
|
||||||
setChatBotMessages(messages);
|
setChatBotMessages(messages);
|
||||||
})
|
})
|
||||||
.catch((error) => console.log('Error saving chat:', error));
|
.catch((error) => {
|
||||||
|
setError(error);
|
||||||
|
console.log('Error saving chat:', error);
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +211,10 @@ function Dashboard() {
|
||||||
console.log(messages);
|
console.log(messages);
|
||||||
setChatBotMessages(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) => {
|
const saveChatBot = (username, password, url) => {
|
||||||
|
@ -262,7 +275,6 @@ function Dashboard() {
|
||||||
chats={chatBotMessages}
|
chats={chatBotMessages}
|
||||||
onAdd={newChat}
|
onAdd={newChat}
|
||||||
onEdit={editChat}
|
onEdit={editChat}
|
||||||
onRefresh={() => setRefresh(!refresh)}
|
|
||||||
onSettings={() => setOpenChatBot(true)}
|
onSettings={() => setOpenChatBot(true)}
|
||||||
title={'Stream Chat'}
|
title={'Stream Chat'}
|
||||||
/>
|
/>
|
||||||
|
@ -283,6 +295,17 @@ function Dashboard() {
|
||||||
// settings={openModal}
|
// settings={openModal}
|
||||||
/>
|
/>
|
||||||
</div>
|
</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
2
go.mod
|
@ -39,5 +39,3 @@ require (
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
gopkg.in/sourcemap.v1 v1.0.5 // indirect
|
gopkg.in/sourcemap.v1 v1.0.5 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
// replace github.com/wailsapp/wails/v2 v2.7.1 => /home/tyler/dev/go/pkg/mod
|
|
||||||
|
|
|
@ -84,7 +84,6 @@ func (a *Api) query(url string) {
|
||||||
client := rumblelivestreamlib.Client{StreamKey: url}
|
client := rumblelivestreamlib.Client{StreamKey: url}
|
||||||
resp, err := client.Request()
|
resp, err := client.Request()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: log error
|
|
||||||
a.logError.Println("api: error executing client request:", err)
|
a.logError.Println("api: error executing client request:", err)
|
||||||
a.Stop()
|
a.Stop()
|
||||||
runtime.EventsEmit(a.ctx, "QueryResponseError", "Failed to query API")
|
runtime.EventsEmit(a.ctx, "QueryResponseError", "Failed to query API")
|
||||||
|
|
Loading…
Reference in a new issue