Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
38
assets/webapps/music.gaiamobile.org/js/services/artists.js
Normal file
38
assets/webapps/music.gaiamobile.org/js/services/artists.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* exported ArtistsService */
|
||||
/* global Response, ServiceWorkerWare, bridge */
|
||||
'use strict';
|
||||
|
||||
importScripts('components/bridge/client.js');
|
||||
|
||||
var client = bridge.client({
|
||||
service: 'music-service',
|
||||
endpoint: new BroadcastChannel('music-service')
|
||||
});
|
||||
|
||||
function ArtistsService(worker) {
|
||||
var stopAfter = ServiceWorkerWare.decorators.stopAfter;
|
||||
|
||||
worker.get('/api/artists/list', stopAfter((request) => {
|
||||
return new Promise((resolve) => {
|
||||
client.method('getArtists')
|
||||
.then(artists => resolve(respond(artists)));
|
||||
});
|
||||
}));
|
||||
|
||||
worker.get('/api/artists/info/:filePath', stopAfter((request) => {
|
||||
return new Promise((resolve) => {
|
||||
var filePath = decodeURIComponent(request.parameters.filePath);
|
||||
client.method('getArtist', filePath)
|
||||
.then(songs => resolve(respond(songs)))
|
||||
.catch((error) => {
|
||||
resolve(new Response('', { status: 404 }));
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
function respond(response) {
|
||||
return new Response(JSON.stringify(response), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue