[editor] Display disconnected status instead of error

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-12-31 19:09:29 +01:00
parent 192dcb7f46
commit 9150ec6311
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 31 additions and 12 deletions

View file

@ -18,7 +18,7 @@ import (
type (
configEditorGeneralConfig struct {
BotEditors []string `json:"bot_editors"`
BotName string `json:"bot_name"`
BotName *string `json:"bot_name,omitempty"`
Channels []string `json:"channels"`
ChannelHasScopes map[string]bool `json:"channel_has_scopes"`
}
@ -189,10 +189,9 @@ func configEditorHandleGeneralGet(w http.ResponseWriter, r *http.Request) {
elevated[ch] = store.UserHasGrantedScopes(ch, channelDefaultScopes...)
}
uName, err := twitchClient.GetAuthorizedUsername()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
var uName *string
if n, err := twitchClient.GetAuthorizedUsername(); err == nil {
uName = &n
}
if err := json.NewEncoder(w).Encode(configEditorGeneralConfig{

View file

@ -222,13 +222,33 @@
/>
Bot Connection
</span>
<code id="botUserName">{{ generalConfig.bot_name }}</code>
<b-tooltip
target="botUserName"
triggers="hover"
>
Twitch Login-Name of the bot user currently authorized
</b-tooltip>
<template v-if="generalConfig.bot_name">
<code
id="botUserName"
>
{{ generalConfig.bot_name }}
<b-tooltip
target="botUserName"
triggers="hover"
>
Twitch Login-Name of the bot user currently authorized
</b-tooltip>
</code>
</template>
<template v-else>
<font-awesome-icon
id="botUserNameDC"
fixed-width
class="mr-1 text-danger"
:icon="['fas', 'unlink']"
/>
<b-tooltip
target="botUserNameDC"
triggers="hover"
>
Bot is not currently authorized!
</b-tooltip>
</template>
</b-card-header>
<b-card-body>