Skip to content

Commit

Permalink
5.3.2: re-add middleware hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
kirainmoe committed Sep 3, 2017
1 parent 17d07b7 commit a13848b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dist/assets/muse-player-react-lite.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/assets/muse-player.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/config/base.js
Expand Up @@ -2,5 +2,5 @@

// Settings configured here will be merged into the final config object.
export default {
MUSE_VERSION: '5.3.1'
MUSE_VERSION: '5.3.2'
}
52 changes: 31 additions & 21 deletions src/models/PlayerModel.js
@@ -1,4 +1,5 @@
import { observable, action } from 'mobx';
import { applyMiddleware } from '../utils';

export default class PlayerModel {
@observable id = undefined;
Expand Down Expand Up @@ -28,39 +29,44 @@ export default class PlayerModel {

@action
togglePlay(state = undefined) {
if (state != undefined) {
return (this.isPlaying = state);
}
return (this.isPlaying = !this.isPlaying);
this.isPlaying = state == undefined ? !this.isPlaying : state;
applyMiddleware('onTogglePlay', this, {
isPlaying: this.isPlaying
});
return this.isPlaying;
}

@action
toggleLoop(state) {
if (state != undefined) {
return (this.isLoop = state);
}
return (this.isLoop = !this.isLoop);
toggleLoop(state = undefined) {
this.isLoop = state == undefined ? !this.isLoop : state;
return this.isLoop;
}

@action
toggleDrawer(state) {
if (state != undefined) {
return (this.isDrawerOpen = state);
}
return (this.isDrawerOpen = !this.isDrawerOpen);
toggleDrawer(state = undefined) {
this.isDrawerOpen = state == undefined ? !this.isDrawerOpen : state;
applyMiddleware('onToggleDrawer', this, {
isDrawerOpen: this.isDrawerOpen
});
return this.isDrawerOpen;
}

@action
toggleMenu(state = undefined) {
if (state != undefined) {
return (this.isMenuOpen = state);
}
return (this.isMenuOpen = !this.isMenuOpen);
this.isMenuOpen = state == undefined ? !this.isMenuOpen : state;
applyMiddleware('onToggleMenu', this, {
isMenuOpen: this.isMenuOpen
});
return this.isMenuOpen;
}

@action
toggleFullscreen() {
return (this.isFullscreen = !this.isFullscreen);
toggleFullscreen(state = undefined) {
this.isFullscreen = state == undefined ? !this.isFullscreen : state;
applyMiddleware('onToggleFullscreen', this, {
isFullscreen: this.isFullscreen
});
return this.isFullscreen;
}

@action
Expand Down Expand Up @@ -91,7 +97,11 @@ export default class PlayerModel {

@action
setCurrentMusic(index) {
return (this.currentMusicIndex = index);
this.currentMusicIndex = index;
applyMiddleware('onMusicChange', this, {
index: index,
detail: this.playList[index]
});
}

@action
Expand Down

0 comments on commit a13848b

Please sign in to comment.