[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 ( type (
configEditorGeneralConfig struct { configEditorGeneralConfig struct {
BotEditors []string `json:"bot_editors"` BotEditors []string `json:"bot_editors"`
BotName string `json:"bot_name"` BotName *string `json:"bot_name,omitempty"`
Channels []string `json:"channels"` Channels []string `json:"channels"`
ChannelHasScopes map[string]bool `json:"channel_has_scopes"` 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...) elevated[ch] = store.UserHasGrantedScopes(ch, channelDefaultScopes...)
} }
uName, err := twitchClient.GetAuthorizedUsername() var uName *string
if err != nil { if n, err := twitchClient.GetAuthorizedUsername(); err == nil {
http.Error(w, err.Error(), http.StatusInternalServerError) uName = &n
return
} }
if err := json.NewEncoder(w).Encode(configEditorGeneralConfig{ if err := json.NewEncoder(w).Encode(configEditorGeneralConfig{

View file

@ -222,13 +222,33 @@
/> />
Bot Connection Bot Connection
</span> </span>
<code id="botUserName">{{ generalConfig.bot_name }}</code> <template v-if="generalConfig.bot_name">
<b-tooltip <code
target="botUserName" id="botUserName"
triggers="hover" >
> {{ generalConfig.bot_name }}
Twitch Login-Name of the bot user currently authorized <b-tooltip
</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-header>
<b-card-body> <b-card-body>