summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Milde <daniel@milde.cz>2024-04-29 12:33:00 +0200
committerDaniel Milde <daniel@milde.cz>2024-04-29 12:33:00 +0200
commit2e5825a380d31712a2b018d541bc2ef326024345 (patch)
tree739389fc6fbd4c175e5278ab902d8365a0422c3d
parent8902628f416af389a44848991f368426917427d4 (diff)
refactor: constants for action and acting
-rw-r--r--tui/actions.go16
-rw-r--r--tui/background.go6
-rw-r--r--tui/marked.go14
3 files changed, 21 insertions, 15 deletions
diff --git a/tui/actions.go b/tui/actions.go
index d09216b..04e931b 100644
--- a/tui/actions.go
+++ b/tui/actions.go
@@ -25,6 +25,12 @@ import (
const (
defaultLinesCount = 500
linesTreshold = 20
+
+ actionEmpty = "empty"
+ actionDelete = "delete"
+
+ actingEmpty = "emptying"
+ actingDelete = "deleting"
)
// ListDevices lists mounted devices and shows their disk usage
@@ -178,11 +184,11 @@ func (ui *UI) deleteSelected(shouldEmpty bool) {
var action, acting string
if shouldEmpty {
- action = "empty "
- acting = "emptying"
+ action = actionEmpty
+ acting = actingEmpty
} else {
- action = "delete "
- acting = "deleting"
+ action = actionDelete
+ acting = actingDelete
}
modal := tview.NewModal().SetText(
// nolint: staticcheck // Why: fixed string
@@ -214,7 +220,7 @@ func (ui *UI) deleteSelected(shouldEmpty bool) {
go func() {
for _, item := range deleteItems {
if err := deleteFun(currentDir, item); err != nil {
- msg := "Can't " + action + tview.Escape(selectedItem.GetName())
+ msg := "Can't " + action + " " + tview.Escape(selectedItem.GetName())
ui.app.QueueUpdateDraw(func() {
ui.pages.RemovePage(acting)
ui.showErr(msg, err)
diff --git a/tui/background.go b/tui/background.go
index f373f23..8974def 100644
--- a/tui/background.go
+++ b/tui/background.go
@@ -35,9 +35,9 @@ func (ui *UI) deleteItem(item fs.Item, shouldEmpty bool) {
var action, acting string
if shouldEmpty {
- action = "empty "
+ action = actionEmpty
} else {
- action = "delete "
+ action = actionDelete
}
var deleteFun func(fs.Item, fs.Item) error
@@ -61,7 +61,7 @@ func (ui *UI) deleteItem(item fs.Item, shouldEmpty bool) {
for _, toDelete := range deleteItems {
if err := deleteFun(parentDir, toDelete); err != nil {
- msg := "Can't " + action + tview.Escape(toDelete.GetName())
+ msg := "Can't " + action + " " + tview.Escape(toDelete.GetName())
ui.app.QueueUpdateDraw(func() {
ui.pages.RemovePage(acting)
ui.showErr(msg, err)
diff --git a/tui/marked.go b/tui/marked.go
index db9d3e9..129b53e 100644
--- a/tui/marked.go
+++ b/tui/marked.go
@@ -24,11 +24,11 @@ func (ui *UI) fileItemMarked(row int) {
func (ui *UI) deleteMarked(shouldEmpty bool) {
var action, acting string
if shouldEmpty {
- action = "empty "
- acting = "emptying"
+ action = actionEmpty
+ acting = actingEmpty
} else {
- action = "delete "
- acting = "deleting"
+ action = actionDelete
+ acting = actingDelete
}
var currentDir fs.Item
@@ -81,7 +81,7 @@ func (ui *UI) deleteMarked(shouldEmpty bool) {
for _, item := range deleteItems {
if err := deleteFun(currentDir, item); err != nil {
- msg := "Can't " + action + tview.Escape(one.GetName())
+ msg := "Can't " + action + " " + tview.Escape(one.GetName())
ui.app.QueueUpdateDraw(func() {
ui.pages.RemovePage(acting)
ui.showErr(msg, err)
@@ -112,9 +112,9 @@ func (ui *UI) deleteMarked(shouldEmpty bool) {
func (ui *UI) confirmDeletionMarked(shouldEmpty bool) {
var action string
if shouldEmpty {
- action = "empty"
+ action = actionEmpty
} else {
- action = "delete"
+ action = actionDelete
}
modal := tview.NewModal().