Commit ceb31076 authored by onny's avatar onny

fix loading all favorites and remember sorting order

parent e0eadcd9
## 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
......
......@@ -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);
};
});
});
});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment