fix loading all favorites and remember sorting order

This commit is contained in:
Jonas Heinrich 2018-08-21 22:24:04 +02:00
parent e0eadcd950
commit ceb3107643
2 changed files with 27 additions and 10 deletions

View File

@ -1,5 +1,9 @@
## 0.6.2
## 0.6.3
### Fixed
- Fix loading all favorites
[#58](https://git.project-insanity.org/onny/nextcloud-app-radio/issues/58) @onny
- Remember favorite stations sort order
[#64](https://git.project-insanity.org/onny/nextcloud-app-radio/issues/64) @onny
- Split up javascript file
[#67](https://git.project-insanity.org/onny/nextcloud-app-radio/issues/67) @onny

View File

@ -196,20 +196,33 @@ var MODULE = (function (radio) {
radio.query_stations = function(station_ids){
var station_array = [];
var station_array_new = [];
station_ids.forEach(function (station_id, idx) {
var url = "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[idx];
$.getJSON( url , function( data ) {
$.ajax({
method: "GET",
url: "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[idx],
dataType: 'json',
}).success( function(data){
station_array = station_array.concat(data);
if (station_ids.length == (idx+1)){
radio.render_results(station_array);
if (data.length === 0) {
station_array = station_array.concat([{'id': station_id, 'name': 'Broken radio station entry :(', 'favicon': '', 'url': ''}])
} else {
station_array = station_array.concat(data);
};
});
if (station_ids.length == station_array.length){
// sorting results array
station_ids.forEach( function (station_id) {
station_array.forEach( function (station) {
if (station_id === station['id']) {
station_array_new = station_array_new.concat(station);
};
});
});
radio.render_results(station_array_new);
};
});
});
};