Skip to content

Commit

Permalink
reverse the default sort order of the spots list (lower frequencies b…
Browse files Browse the repository at this point in the history
…elow higher frequencies) for a more natural feeling
  • Loading branch information
ftl committed Aug 18, 2024
1 parent 41c6f29 commit c7e7c1e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion core/bandmap/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (l *Entries) insert(entry *Entry) {

func (l *Entries) findIndexForInsert(entry *Entry) int {
less := func(a, b *Entry) bool {
return l.order(a.BandmapEntry, b.BandmapEntry)
return l.order(b.BandmapEntry, a.BandmapEntry)
}
left := 0
right := len(l.entries) - 1
Expand Down
63 changes: 32 additions & 31 deletions core/bandmap/entries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,50 +188,50 @@ func TestEntries_findIndexForInsert(t *testing.T) {
},
{
desc: "before first",
fixture: []int{2, 3, 4},
value: 1,
fixture: []int{4, 3, 2},
value: 5,
expected: 0,
},
{
desc: "at the first",
fixture: []int{2, 3, 4},
value: 2,
fixture: []int{4, 3, 2},
value: 4,
expected: 0,
},
{
desc: "after the first",
fixture: []int{2, 4, 5},
value: 3,
fixture: []int{5, 3, 2},
value: 4,
expected: 1,
},
{
desc: "at the center",
fixture: []int{2, 3, 5, 6},
fixture: []int{6, 5, 3, 2},
value: 4,
expected: 2,
},
{
desc: "at the existing center",
fixture: []int{2, 3, 4, 5, 6},
fixture: []int{6, 5, 4, 3, 2},
value: 4,
expected: 2,
},
{
desc: "before the last",
fixture: []int{2, 3, 5},
value: 4,
fixture: []int{5, 4, 2},
value: 3,
expected: 2,
},
{
desc: "at the last",
fixture: []int{2, 3, 4},
value: 4,
fixture: []int{4, 3, 1},
value: 2,
expected: 2,
},
{
desc: "after last",
fixture: []int{2, 3, 4},
value: 5,
fixture: []int{4, 3, 2},
value: 1,
expected: 3,
},
}
Expand Down Expand Up @@ -269,50 +269,50 @@ func TestEntries_insert(t *testing.T) {
},
{
desc: "before first",
fixture: []int{2, 3, 4},
value: 1,
fixture: []int{4, 3, 2},
value: 5,
expected: 0,
},
{
desc: "at the first",
fixture: []int{2, 3, 4},
value: 2,
fixture: []int{4, 3, 2},
value: 4,
expected: 0,
},
{
desc: "after the first",
fixture: []int{2, 4, 5},
value: 3,
fixture: []int{5, 3, 2},
value: 4,
expected: 1,
},
{
desc: "at the center",
fixture: []int{2, 3, 5, 6},
fixture: []int{6, 5, 3, 2},
value: 4,
expected: 2,
},
{
desc: "at the existing center",
fixture: []int{2, 3, 4, 5, 6},
fixture: []int{6, 5, 4, 3, 2},
value: 4,
expected: 2,
},
{
desc: "before the last",
fixture: []int{2, 3, 5},
value: 4,
fixture: []int{5, 4, 2},
value: 3,
expected: 2,
},
{
desc: "at the last",
fixture: []int{2, 3, 4},
value: 4,
fixture: []int{4, 3, 1},
value: 2,
expected: 2,
},
{
desc: "after last",
fixture: []int{2, 3, 4},
value: 5,
fixture: []int{4, 3, 2},
value: 1,
expected: 3,
},
}
Expand Down Expand Up @@ -354,9 +354,10 @@ func TestEntries_CleanOutOldEntries(t *testing.T) {
entries.Add(core.Spot{Call: callsign.MustParse("dl2abc"), Frequency: 3535500, Time: now.Add(-10 * time.Hour)}, now, defaultWeights)

assert.Equal(t, 2, entries.Len())
assert.Equal(t, "DL1ABC", entries.entries[0].Call.String())
assert.Equal(t, 3, entries.entries[0].Len())
assert.Equal(t, now.Add(-10*time.Minute), entries.entries[0].LastHeard)
assert.Equal(t, "DL2ABC", entries.entries[0].Call.String())
assert.Equal(t, "DL1ABC", entries.entries[1].Call.String())
assert.Equal(t, 3, entries.entries[1].Len())
assert.Equal(t, now.Add(-10*time.Minute), entries.entries[1].LastHeard)

entries.CleanOut(30*time.Minute, now, defaultWeights)

Expand Down
4 changes: 2 additions & 2 deletions ui/glade/contest.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ For more details see <a href="https://github.com/ftl/hellocontest/wiki/Main-W
<property name="can-focus">False</property>
<property name="label" translatable="yes">Go to Next Spot Up</property>
<property name="use-underline">True</property>
<accelerator key="Down" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="Up" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
Expand All @@ -1821,7 +1821,7 @@ For more details see &lt;a href="https://github.com/ftl/hellocontest/wiki/Main-W
<property name="can-focus">False</property>
<property name="label" translatable="yes">Go to Next Spot Down</property>
<property name="use-underline">True</property>
<accelerator key="Up" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="Down" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
Expand Down

0 comments on commit c7e7c1e

Please sign in to comment.