-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package unpackerr | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/Unpackerr/unpackerr/pkg/ui" | ||
) | ||
|
||
// Safety constants. | ||
const ( | ||
hist = "hist_" | ||
histNone = "hist_none" | ||
) | ||
|
||
// History holds the history of extracted items. | ||
type History struct { | ||
Items []string | ||
Finished uint | ||
Retries uint | ||
Map map[string]*Extract | ||
} | ||
|
||
// This is called every time an item is queued. | ||
func (u *Unpackerr) updateHistory(item string) { | ||
if u.KeepHistory == 0 { | ||
return | ||
} | ||
|
||
if ui.HasGUI() && item != "" { | ||
u.menu[histNone].Hide() | ||
} | ||
|
||
u.History.Items[0] = item | ||
|
||
//nolint:intrange // Do not process 0; this isn't an `intrange`. | ||
for idx := len(u.History.Items) - 1; idx > 0; idx-- { | ||
// u.History.Items is a slice with a set (identical) length and capacity. | ||
switch u.History.Items[idx] = u.History.Items[idx-1]; { | ||
case !ui.HasGUI(): | ||
continue | ||
case u.History.Items[idx] != "": | ||
u.menu[hist+starr.Itoa(idx)].SetTitle(u.History.Items[idx]) | ||
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / golangci-lint (freebsd)
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / golangci-lint (freebsd)
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / golangci-lint (darwin)
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / golangci-lint (darwin)
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / Make macOS DMG
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / Make Release Assets
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / gotest (ubuntu)
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / golangci-lint (linux)
Check failure on line 42 in pkg/unpackerr/history.go GitHub Actions / golangci-lint (linux)
|
||
u.menu[hist+strconv.Itoa(idx)].Show() | ||
default: | ||
u.menu[hist+strconv.Itoa(idx)].Hide() | ||
} | ||
} | ||
} |