Skip to content

Commit 98270dd

Browse files
committed
feat(serverHandler): use desc sort for time and size by default
Sorting files by time and size descending are more frequently used than ascending.
1 parent 86ef7c5 commit 98270dd

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/serverHandler/sortState.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ func (info SortState) NextTypeSort() string {
8484
func (info SortState) NextSizeSort() string {
8585
var nextKey byte
8686
switch info.key {
87-
case sizeAsc:
88-
nextKey = sizeDesc
89-
default:
87+
case sizeDesc:
9088
nextKey = sizeAsc
89+
default:
90+
nextKey = sizeDesc
9191
}
9292
return info.mergeDirWithKey(nextKey)
9393
}
9494

9595
func (info SortState) NextTimeSort() string {
9696
var nextKey byte
9797
switch info.key {
98-
case timeAsc:
99-
nextKey = timeDesc
100-
default:
98+
case timeDesc:
10199
nextKey = timeAsc
100+
default:
101+
nextKey = timeDesc
102102
}
103103
return info.mergeDirWithKey(nextKey)
104104
}

src/serverHandler/sortState_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,24 @@ func TestSortState_KeyState(t *testing.T) {
5252
}
5353

5454
sortBy = state.NextSizeSort()
55-
if sortBy != "/s" {
55+
if sortBy != "/S" {
5656
t.Error(sortBy)
5757
}
5858

5959
sortBy = state.NextTimeSort()
60-
if sortBy != "/t" {
60+
if sortBy != "/T" {
6161
t.Error(sortBy)
6262
}
6363

6464
state.dirSort = dirSortMixed
6565
sortBy = state.NextTimeSort()
66-
if sortBy != "t" {
66+
if sortBy != "T" {
6767
t.Error(sortBy)
6868
}
6969

70-
state.key = 't'
70+
state.key = 'T'
7171
sortBy = state.NextTimeSort()
72-
if sortBy != "T" {
72+
if sortBy != "t" {
7373
t.Error(sortBy)
7474
}
7575
}

0 commit comments

Comments
 (0)