From 23ed345c4ba9945ac90952dd1d2eb0ad8b60d6c0 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Wed, 4 Feb 2026 22:13:29 -0500 Subject: [PATCH] refactor(ui/chat): update consts to reflect primitive name change --- internal/ui/chat/message_input.go | 12 ++++++------ internal/ui/chat/messages_list.go | 6 +++--- internal/ui/chat/view.go | 26 +++++++++++++------------- internal/ui/login/form.go | 20 ++++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/internal/ui/chat/message_input.go b/internal/ui/chat/message_input.go index 39e8717..bd6f654 100644 --- a/internal/ui/chat/message_input.go +++ b/internal/ui/chat/message_input.go @@ -108,7 +108,7 @@ func (mi *messageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey { return tcell.NewEventKey(tcell.KeyCtrlV, "", tcell.ModNone) case mi.cfg.Keybinds.MessageInput.Send: - if mi.chatView.GetVisibile(mentionsListPageName) { + if mi.chatView.GetVisibile(mentionsListLayerName) { mi.tabComplete() return nil } @@ -124,7 +124,7 @@ func (mi *messageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey { mi.openFilePicker() return nil case mi.cfg.Keybinds.MessageInput.Cancel: - if mi.chatView.GetVisibile(mentionsListPageName) { + if mi.chatView.GetVisibile(mentionsListLayerName) { mi.stopTabCompletion() } else { mi.reset() @@ -149,7 +149,7 @@ func (mi *messageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey { } if mi.cfg.AutocompleteLimit > 0 { - if mi.chatView.GetVisibile(mentionsListPageName) { + if mi.chatView.GetVisibile(mentionsListLayerName) { handler := mi.mentionsList.InputHandler() switch event.Name() { case mi.cfg.Keybinds.MentionsList.Up: @@ -534,11 +534,11 @@ func (mi *messageInput) showMentionList() { mi.chatView. AddLayer(l, - layers.WithName(mentionsListPageName), + layers.WithName(mentionsListLayerName), layers.WithResize(false), layers.WithVisible(true), ). - SendToFront(mentionsListPageName) + SendToFront(mentionsListLayerName) mi.chatView.app.SetFocus(mi) } @@ -591,7 +591,7 @@ func (mi *messageInput) addMentionUser(user *discord.User) { // used by chatView func (mi *messageInput) removeMentionsList() { mi.chatView. - RemoveLayer(mentionsListPageName) + RemoveLayer(mentionsListLayerName) } func (mi *messageInput) stopTabCompletion() { diff --git a/internal/ui/chat/messages_list.go b/internal/ui/chat/messages_list.go index 8cbe704..46742d0 100644 --- a/internal/ui/chat/messages_list.go +++ b/internal/ui/chat/messages_list.go @@ -510,7 +510,7 @@ func (ml *messagesList) showAttachmentsList(urls []string, attachments []discord SetHighlightFullLine(true). ShowSecondaryText(false). SetDoneFunc(func() { - ml.chatView.RemoveLayer(attachmentsListPageName) + ml.chatView.RemoveLayer(attachmentsListLayerName) ml.chatView.app.SetFocus(ml) }) list. @@ -549,12 +549,12 @@ func (ml *messagesList) showAttachmentsList(urls []string, attachments []discord ml.chatView. AddLayer( ui.Centered(list, 0, 0), - layers.WithName(attachmentsListPageName), + layers.WithName(attachmentsListLayerName), layers.WithResize(true), layers.WithVisible(true), layers.WithOverlay(), ). - SendToFront(attachmentsListPageName) + SendToFront(attachmentsListLayerName) } func (ml *messagesList) openAttachment(attachment discord.Attachment) { diff --git a/internal/ui/chat/view.go b/internal/ui/chat/view.go index 5921135..c5059e3 100644 --- a/internal/ui/chat/view.go +++ b/internal/ui/chat/view.go @@ -20,11 +20,11 @@ import ( const typingDuration = 10 * time.Second const ( - flexPageName = "flex" - mentionsListPageName = "mentionsList" - attachmentsListPageName = "attachmentsList" - confirmModalPageName = "confirmModal" - channelsPickerPageName = "channelsPicker" + flexLayerName = "flex" + mentionsListLayerName = "mentionsList" + attachmentsListLayerName = "attachmentsList" + confirmModalLayerName = "confirmModal" + channelsPickerLayerName = "channelsPicker" ) type View struct { @@ -103,11 +103,11 @@ func (v *View) buildLayout() { AddItem(v.guildsTree, 0, 1, true). AddItem(v.rightFlex, 0, 4, false) - v.AddLayer(v.mainFlex, layers.WithName(flexPageName), layers.WithResize(true), layers.WithVisible(true)) + v.AddLayer(v.mainFlex, layers.WithName(flexLayerName), layers.WithResize(true), layers.WithVisible(true)) } func (v *View) togglePicker() { - if v.HasLayer(channelsPickerPageName) { + if v.HasLayer(channelsPickerLayerName) { v.closePicker() } else { v.openPicker() @@ -117,16 +117,16 @@ func (v *View) togglePicker() { func (v *View) openPicker() { v.AddLayer( ui.Centered(v.channelsPicker, v.cfg.Picker.Width, v.cfg.Picker.Height), - layers.WithName(channelsPickerPageName), + layers.WithName(channelsPickerLayerName), layers.WithResize(true), layers.WithVisible(true), layers.WithOverlay(), - ).SendToFront(channelsPickerPageName) + ).SendToFront(channelsPickerLayerName) v.channelsPicker.update() } func (v *View) closePicker() { - v.RemoveLayer(channelsPickerPageName) + v.RemoveLayer(channelsPickerLayerName) v.channelsPicker.Update() } @@ -244,7 +244,7 @@ func (v *View) showConfirmModal(prompt string, buttons []string, onDone func(lab SetText(prompt). AddButtons(buttons). SetDoneFunc(func(_ int, buttonLabel string) { - v.RemoveLayer(confirmModalPageName) + v.RemoveLayer(confirmModalLayerName) v.app.SetFocus(previousFocus) if onDone != nil { @@ -254,12 +254,12 @@ func (v *View) showConfirmModal(prompt string, buttons []string, onDone func(lab v. AddLayer( ui.Centered(modal, 0, 0), - layers.WithName(confirmModalPageName), + layers.WithName(confirmModalLayerName), layers.WithResize(true), layers.WithVisible(true), layers.WithOverlay(), ). - SendToFront(confirmModalPageName) + SendToFront(confirmModalLayerName) } func (v *View) onReadUpdate(event *read.UpdateEvent) { diff --git a/internal/ui/login/form.go b/internal/ui/login/form.go index 30390cc..51a7ad8 100644 --- a/internal/ui/login/form.go +++ b/internal/ui/login/form.go @@ -15,9 +15,9 @@ import ( ) const ( - formPageName = "form" - errorPageName = "error" - qrPageName = "qr" + formLayerName = "form" + errorLayerName = "error" + qrLayerName = "qr" ) type DoneFn = func(token string) @@ -44,7 +44,7 @@ func NewForm(app *tview.Application, cfg *config.Config, done DoneFn) *Form { AddButton("Login", f.login). AddButton("Login with QR", f.loginWithQR) f.SetBackgroundLayerStyle(f.cfg.Theme.Dialog.BackgroundStyle.Style) - f.AddLayer(f.form, layers.WithName(formPageName), layers.WithResize(true), layers.WithVisible(true)) + f.AddLayer(f.form, layers.WithName(formLayerName), layers.WithResize(true), layers.WithVisible(true)) return f } @@ -73,7 +73,7 @@ func (f *Form) onError(err error) { if buttonIndex == 0 { go clipboard.Write(clipboard.FmtText, []byte(message)) } else { - f.RemoveLayer(errorPageName) + f.RemoveLayer(errorLayerName) } }) { @@ -94,12 +94,12 @@ func (f *Form) onError(err error) { f. AddLayer( ui.Centered(modal, 0, 0), - layers.WithName(errorPageName), + layers.WithName(errorLayerName), layers.WithResize(true), layers.WithVisible(true), layers.WithOverlay(), ). - SendToFront(errorPageName) + SendToFront(errorLayerName) } func (f *Form) loginWithQR() { @@ -110,18 +110,18 @@ func (f *Form) loginWithQR() { } if token == "" { - f.RemoveLayer(qrPageName) + f.RemoveLayer(qrLayerName) return } go keyring.SetToken(token) - f.RemoveLayer(qrPageName) + f.RemoveLayer(qrLayerName) if f.done != nil { f.done(token) } }) - f.AddLayer(qr, layers.WithName(qrPageName), layers.WithResize(true), layers.WithVisible(true)) + f.AddLayer(qr, layers.WithName(qrLayerName), layers.WithResize(true), layers.WithVisible(true)) qr.start() }