fix sorting recent stations

This commit is contained in:
Jonas Heinrich 2021-01-20 11:55:37 +01:00
parent 7d963e18fd
commit f550f19ce9
2 changed files with 12 additions and 4 deletions

View File

@ -2,6 +2,7 @@
### Fixed ### Fixed
- Set user agent http header for remote API - Set user agent http header for remote API
[221](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/221) @onny [221](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/221) @onny
- Update favorite and recent categories without page reload
### Changed ### Changed
- Update npm modules - Update npm modules
@ -12,6 +13,8 @@
[236](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/236) @onny [236](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/236) @onny
- Create seperate store modules for player, favorites and recent - Create seperate store modules for player, favorites and recent
[239](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/239) @onny [239](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/239) @onny
- Put player and api logic into seperate classes
[233](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/233) @onny
## 1.0.1 - 2020-12 ## 1.0.1 - 2020-12
### Added ### Added

View File

@ -33,18 +33,23 @@ export default {
}, },
}, },
mutations: { mutations: {
addRecent(state, station) { addRecent(state, station) {
state.recent.push(station)
}, // Remove station from list if already exists
removeRecent(state, station) { const existingIndex = state.recent.findIndex(_station => _station.stationuuid === station.stationuuid)
const existingIndex = state.recent.findIndex(_station => _station.id === station.id)
if (existingIndex !== -1) { if (existingIndex !== -1) {
state.recent.splice(existingIndex, 1) state.recent.splice(existingIndex, 1)
} }
// Append station at the begging of the list
state.recent.unshift(station)
}, },
setRecent(state, stations) { setRecent(state, stations) {
state.recent = stations state.recent = stations
}, },
}, },
actions: { actions: {
async loadRecent({ commit }) { async loadRecent({ commit }) {