File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package unpackerr
2+
3+ import (
4+ "strconv"
5+
6+ "github.com/Unpackerr/unpackerr/pkg/ui"
7+ )
8+
9+ // Safety constants.
10+ const (
11+ hist = "hist_"
12+ histNone = "hist_none"
13+ )
14+
15+ // History holds the history of extracted items.
16+ type History struct {
17+ Items []string
18+ Finished uint
19+ Retries uint
20+ Map map [string ]* Extract
21+ }
22+
23+ // This is called every time an item is queued.
24+ func (u * Unpackerr ) updateHistory (item string ) {
25+ if u .KeepHistory == 0 {
26+ return
27+ }
28+
29+ if ui .HasGUI () && item != "" {
30+ u .menu [histNone ].Hide ()
31+ }
32+
33+ u .History .Items [0 ] = item
34+
35+ // Do not process 0; this isn't an `intrange`.
36+ for idx := len (u .History .Items ) - 1 ; idx > 0 ; idx -- {
37+ // u.History.Items is a slice with a set (identical) length and capacity.
38+ switch u .History .Items [idx ] = u .History .Items [idx - 1 ]; {
39+ case ! ui .HasGUI ():
40+ continue
41+ case u .History .Items [idx ] != "" :
42+ u .menu [hist + strconv .Itoa (idx )].SetTitle (u .History .Items [idx ])
43+ u .menu [hist + strconv .Itoa (idx )].Show ()
44+ default :
45+ u .menu [hist + strconv .Itoa (idx )].Hide ()
46+ }
47+ }
48+ }
Original file line number Diff line number Diff line change @@ -85,14 +85,6 @@ type Flags struct {
8585 webhook uint
8686}
8787
88- // History holds the history of extracted items.
89- type History struct {
90- Items []string
91- Finished uint
92- Retries uint
93- Map map [string ]* Extract
94- }
95-
9688// New returns an UnpackerPoller struct full of defaults.
9789// An empty struct will surely cause you pain, so use this!
9890func New () * Unpackerr {
Original file line number Diff line number Diff line change @@ -18,12 +18,6 @@ import (
1818 "golift.io/version"
1919)
2020
21- // Safety constants.
22- const (
23- hist = "hist_"
24- histNone = "hist_none"
25- )
26-
2721// startTray Run()s readyTray to bring up the web server and the GUI app.
2822func (u * Unpackerr ) startTray () {
2923 if ! ui .HasGUI () {
@@ -254,34 +248,3 @@ func (u *Unpackerr) checkForUpdate() {
254248 _ = ui .OpenURL (update .CurrURL )
255249 }
256250}
257-
258- // This is called every time an item is queued.
259- func (u * Unpackerr ) updateHistory (item string ) {
260- if u .KeepHistory == 0 {
261- return
262- }
263-
264- if ui .HasGUI () && item != "" {
265- u .menu [histNone ].Hide ()
266- }
267-
268- // u.History.Items is a slice with a set (identical) length and capacity.
269- for idx := range u .History .Items {
270- if idx == 0 {
271- u .History .Items [0 ] = item
272- } else {
273- u .History .Items [idx ] = u .History .Items [idx - 1 ]
274- }
275-
276- if ! ui .HasGUI () {
277- continue
278- }
279-
280- if u .History .Items [idx ] != "" {
281- u .menu [hist + strconv .Itoa (idx )].SetTitle (u .History .Items [idx ])
282- u .menu [hist + strconv .Itoa (idx )].Show ()
283- } else {
284- u .menu [hist + strconv .Itoa (idx )].Hide ()
285- }
286- }
287- }
Original file line number Diff line number Diff line change @@ -18,15 +18,3 @@ func (u *Unpackerr) startTray() {
1818func (u * Unpackerr ) updateTray (_ * Stats , _ uint ) {
1919 // there is no tray.
2020}
21-
22- func (u * Unpackerr ) updateHistory (item string ) {
23- if u .KeepHistory == 0 {
24- return
25- }
26-
27- u .History .Items [0 ] = item
28- // u.History.Items is a slice with a set (identical) length and capacity.
29- for idx := range u .History .Items {
30- u .History .Items [idx ] = u .History .Items [idx - 1 ]
31- }
32- }
You can’t perform that action at this time.
0 commit comments