mirror of
https://github.com/glanceapp/glance.git
synced 2024-12-01 12:55:25 +01:00
Retain stocks order by default
This commit is contained in:
parent
58967ab758
commit
948c117f5b
@ -831,6 +831,7 @@ Preview:
|
|||||||
| Name | Type | Required |
|
| Name | Type | Required |
|
||||||
| ---- | ---- | -------- |
|
| ---- | ---- | -------- |
|
||||||
| stocks | array | yes |
|
| stocks | array | yes |
|
||||||
|
| sort | string | no |
|
||||||
|
|
||||||
##### `stocks`
|
##### `stocks`
|
||||||
An array of stocks for which to display information about.
|
An array of stocks for which to display information about.
|
||||||
@ -849,6 +850,9 @@ The symbol, as seen in Yahoo Finance.
|
|||||||
|
|
||||||
The name that will be displayed under the symbol.
|
The name that will be displayed under the symbol.
|
||||||
|
|
||||||
|
##### `sort-by`
|
||||||
|
By default the stocks are displayed in the order they were defined. You can customize their ordering by setting the `sort-by` property to `absolute-change` for descending order based on the stock's absolute price change.
|
||||||
|
|
||||||
### Twitch Channels
|
### Twitch Channels
|
||||||
Display a list of channels from Twitch.
|
Display a list of channels from Twitch.
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
type Stocks struct {
|
type Stocks struct {
|
||||||
widgetBase `yaml:",inline"`
|
widgetBase `yaml:",inline"`
|
||||||
Stocks feed.Stocks `yaml:"-"`
|
Stocks feed.Stocks `yaml:"-"`
|
||||||
|
Sort string `yaml:"sort-by"`
|
||||||
Tickers []feed.StockRequest `yaml:"stocks"`
|
Tickers []feed.StockRequest `yaml:"stocks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +29,10 @@ func (widget *Stocks) Update(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if widget.Sort == "absolute-change" {
|
||||||
stocks.SortByAbsChange()
|
stocks.SortByAbsChange()
|
||||||
|
}
|
||||||
|
|
||||||
widget.Stocks = stocks
|
widget.Stocks = stocks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user