From 5dbfdd836aa9095fe2b3559e1ab096701acfe94d Mon Sep 17 00:00:00 2001 From: rxdn <29165304+rxdn@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:34:50 +0000 Subject: [PATCH] Allow disabling of archive channel --- app/http/endpoints/api/settings/settings.go | 2 +- app/http/endpoints/api/settings/updatesettings.go | 7 ++++++- frontend/src/components/ChannelDropdown.svelte | 7 +++++++ frontend/src/components/manage/SettingsCard.svelte | 2 +- go.mod | 6 +++--- go.sum | 6 ++++++ 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/http/endpoints/api/settings/settings.go b/app/http/endpoints/api/settings/settings.go index d9afa9e..b48af4e 100644 --- a/app/http/endpoints/api/settings/settings.go +++ b/app/http/endpoints/api/settings/settings.go @@ -14,7 +14,7 @@ type Settings struct { WelcomeMessaage string `json:"welcome_message"` TicketLimit uint8 `json:"ticket_limit"` Category uint64 `json:"category,string"` - ArchiveChannel uint64 `json:"archive_channel,string"` + ArchiveChannel *uint64 `json:"archive_channel,string"` NamingScheme database.NamingScheme `json:"naming_scheme"` PingEveryone bool `json:"ping_everyone"` UsersCanClose bool `json:"users_can_close"` diff --git a/app/http/endpoints/api/settings/updatesettings.go b/app/http/endpoints/api/settings/updatesettings.go index e022523..91a316e 100644 --- a/app/http/endpoints/api/settings/updatesettings.go +++ b/app/http/endpoints/api/settings/updatesettings.go @@ -207,9 +207,14 @@ func (s *Settings) updateCategory(channels []channel.Channel, guildId uint64) bo } func (s *Settings) updateArchiveChannel(channels []channel.Channel, guildId uint64) bool { + if s.ArchiveChannel == nil { + go dbclient.Client.ArchiveChannel.Set(guildId, nil) + return true + } + var valid bool for _, ch := range channels { - if ch.Id == s.ArchiveChannel && ch.Type == channel.ChannelTypeGuildText { + if ch.Id == *s.ArchiveChannel && ch.Type == channel.ChannelTypeGuildText { valid = true break } diff --git a/frontend/src/components/ChannelDropdown.svelte b/frontend/src/components/ChannelDropdown.svelte index f74dafe..afed911 100644 --- a/frontend/src/components/ChannelDropdown.svelte +++ b/frontend/src/components/ChannelDropdown.svelte @@ -1,4 +1,9 @@ + {#if withNull} + + {/if} {#each channels as channel} {#if channel.type === 0}