Skip to content

Commit

Permalink
Use async/await
Browse files Browse the repository at this point in the history
Ref 03e2ac1.
  • Loading branch information
alexesprit committed Jun 12, 2019
1 parent a070b67 commit 5f26848
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/background/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ define((require) => {
* Called when something sent message to background script.
* @param {Any} request Message sent by the calling script
*/
function onMessage(request) {
async function onMessage(request) {
if (request.type === 'REQUEST_AUTHENTICATE') {
const scrobblerLabel = request.scrobbler;
const scrobbler = ScrobbleService.getScrobblerByLabel(scrobblerLabel);
Expand All @@ -140,15 +140,15 @@ define((require) => {

switch (request.type) {
case 'REQUEST_GET_SONG':
return Promise.resolve(ctrl.getCurrentSong());
return ctrl.getCurrentSong();

case 'REQUEST_CORRECT_SONG':
ctrl.setUserSongData(request.data);
break;

case 'REQUEST_TOGGLE_LOVE':
return ctrl.toggleLove(request.data.isLoved)
.then(() => request.data.isLoved);
await ctrl.toggleLove(request.data.isLoved);
return request.data.isLoved;

case 'REQUEST_SKIP_SONG':
ctrl.skipCurrentSong();
Expand Down

0 comments on commit 5f26848

Please sign in to comment.