Remove ability to toggle the chatheader
MODIFY
app/app.go
app/app.go
@@ -111,7 +111,6 @@ func Run() {
window.RegisterCommand(commandimpls.NewAccount(runNext, window))
window.RegisterCommand(commandimpls.NewManualCommand(window))
window.RegisterCommand(commandimpls.NewFixLayoutCommand(window))
- window.RegisterCommand(commandimpls.NewChatHeaderCommand(window))
window.RegisterCommand(commandimpls.NewFriendsCommand(discord))
userSetCmd := commandimpls.NewUserSetCommand(window, discord)
userGetCmd := commandimpls.NewUserGetCommand(window, discord)

DELETE
commands/commandimpls/chatheader.go
-package commandimpls
-
-import (
- "fmt"
- "io"
- "strconv"
-
- "github.com/Bios-Marcel/cordless/config"
- "github.com/Bios-Marcel/cordless/ui"
-)
-
-const chatHeaderDocumentation = `[orange]# chatheader[white]
-
-The chatheader command [green]shows[white] or [red]hides[white] the chatheader
-and saves the new state to the user configuration.
-
-The chatheader is the textbox above the message container. It contains the
-channel name and optionally a topic if the channel has one.
-
-Usage: chatheader <[green]true[white]/[red]false[white]>`
-
-// ChatHeader is the command that allows toggling the chatheader.
-type ChatHeader struct {
- window *ui.Window
-}
-
-// NewChatHeaderCommand creates a new ready-to-use ChatHeader command.
-func NewChatHeaderCommand(window *ui.Window) *ChatHeader {
- return &ChatHeader{
- window: window,
- }
-}
-
-// Execute runs the command piping its output into the supplied writer.
-func (chatHeader *ChatHeader) Execute(writer io.Writer, parameters []string) {
- if len(parameters) == 1 {
- choice, parseError := strconv.ParseBool(parameters[0])
- if parseError != nil {
- chatHeader.PrintHelp(writer)
- return
- }
-
- config.GetConfig().ShowChatHeader = choice
- chatHeader.window.RefreshChannelTitle()
-
- persistError := config.PersistConfig()
- if persistError != nil {
- fmt.Fprintf(writer, "Error saving configuration: %s\n", persistError.Error())
- return
- }
-
- if choice {
- fmt.Fprintln(writer, "Chatheader has been enabled")
- } else {
- fmt.Fprintln(writer, "Chatheader has been disabled")
- }
- } else {
- chatHeader.PrintHelp(writer)
- }
-}
-
-func (chatHeader *ChatHeader) Name() string {
- return "chatheader"
-}
-
-func (chatHeader *ChatHeader) Aliases() []string {
- return []string{"chat-header", "chat-title"}
-}
-
-// PrintHelp prints a static help page for this command
-func (chatHeader *ChatHeader) PrintHelp(writer io.Writer) {
- fmt.Fprintln(writer, chatHeaderDocumentation)
-}

MODIFY
config/config.go
config/config.go
@@ -39,7 +39,6 @@ var (
Times: HourMinuteAndSeconds,
UseRandomUserColors: false,
ShowUserContainer: true,
- ShowChatHeader: true,
UseFixedLayout: false,
FixedSizeLeft: 12,
FixedSizeRight: 12,
@@ -72,9 +71,6 @@ type Config struct {
//move over to the message input widget after channel selection
FocusMessageInputAfterChannelSelection bool
- //ShowChatHeader decides whether the box above the chat will be shown
- //or not.
- ShowChatHeader bool
//ShowUserContainer decides whether the user container is part of the
//layout or not.
ShowUserContainer bool

MODIFY
ui/window.go
ui/window.go
@@ -217,7 +217,6 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
}
window.LoadChannel(channel)
- window.UpdateChatHeader(channel)
if channel.Type == discordgo.ChannelTypeGroupDM {
loadError := window.userList.LoadGroup(channel.ID)
if loadError != nil {
@@ -234,7 +233,6 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
if userChannel.Type == discordgo.ChannelTypeDM &&
(userChannel.Recipients[0].ID == userID) {
window.LoadChannel(userChannel)
- window.UpdateChatHeader(userChannel)
window.RefreshLayout()
return
}
@@ -249,7 +247,6 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
}
}
window.LoadChannel(newChannel)
- window.UpdateChatHeader(newChannel)
window.RefreshLayout()
}
})
@@ -2087,19 +2084,15 @@ func (window *Window) LoadChannel(channel *discordgo.Channel) error {
return nil
}
-// RefreshChannelTitle calls UpdateChannelTitle using the current channel.
-func (window *Window) RefreshChannelTitle() {
- window.UpdateChatHeader(window.selectedChannel)
-}
-
// UpdateChatHeader updates the bordertitle of the chatviews container.o
// The title consist of the channel name and its topic for guild channels.
// For private channels it's either the recipient in a dm, or all recipients
// in a group dm channel. If the channel has a nickname, that is chosen.
func (window *Window) UpdateChatHeader(channel *discordgo.Channel) {
- if !config.GetConfig().ShowChatHeader || channel == nil {
- window.chatView.SetTitle("")
- } else {
+ if channel == nil {
+ return
+ }
+
if channel.Type == discordgo.ChannelTypeGuildText {
if channel.Topic != "" {
window.chatView.SetTitle(channel.Name + " - " + channel.Topic)
@@ -2112,7 +2105,6 @@ func (window *Window) UpdateChatHeader(channel *discordgo.Channel) {
window.chatView.SetTitle(discordutil.GetPrivateChannelName(channel))
}
}
-}
// RegisterCommand register a command. That makes the command available for
// being called from the message input field, in case the user-defined prefix

Remove ability to toggle the chatheader