This repository was archived by the owner on Mar 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import TooltipsPlugin from './plugins/TooltipsPlugin';
1919import GuestPlugin from './plugins/GuestPlugin' ;
2020import SocketEventsPlugin from './plugins/SocketEventsPlugin' ;
2121import WaitlistEventsPlugin from './plugins/WaitlistEventsPlugin' ;
22+ import PlugSettingsPlugin from './plugins/PlugSettingsPlugin' ;
2223
2324import * as _package from './package' ;
2425
@@ -89,7 +90,8 @@ const ExtPlug = Plugin.extend({
8990 new EmojiDataPlugin ( 'extplug:emoji-data' , this ) ,
9091 new TooltipsPlugin ( 'extplug:tooltips' , this ) ,
9192 new SocketEventsPlugin ( 'extplug:socket-events' , this ) ,
92- new WaitlistEventsPlugin ( 'extplug:waitlist-events' , this )
93+ new WaitlistEventsPlugin ( 'extplug:waitlist-events' , this ) ,
94+ new PlugSettingsPlugin ( 'extplug:plug-settings' , this )
9395 ] ;
9496
9597 this . _guest = new GuestPlugin ( 'extplug:guest' , this ) ;
@@ -249,7 +251,6 @@ const ExtPlug = Plugin.extend({
249251
250252 this . upgrade ( ) ;
251253
252- settings . update ( ) ;
253254 this . appView = getApplicationView ( ) ;
254255
255256 // install extra events
Original file line number Diff line number Diff line change 11import * as apiEarlyHook from './api-early' ;
22import * as playbackHook from './playback' ;
3- import * as settingsHook from './settings' ;
43import * as popoutStyleHook from './popout-style' ;
54
65export default [
76 apiEarlyHook ,
87 playbackHook ,
9- settingsHook ,
108 popoutStyleHook
119] ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import Plugin from '../Plugin' ;
2+ import { before } from 'meld' ;
3+ import plugSettings from 'plug/store/settings' ;
4+ import extMirror from '../store/settings' ;
5+
6+ const PlugSettingsPlugin = Plugin . extend ( {
7+ name : 'Plug.dj Settings Sync' ,
8+ description : 'Mirrors plug.dj settings to the ExtPlug settings model, firing change events.' ,
9+
10+ enable ( ) {
11+ this . advice = before ( plugSettings , 'save' , this . sync . bind ( this ) ) ;
12+ this . sync ( ) ;
13+ } ,
14+
15+ disable ( ) {
16+ this . advice . remove ( ) ;
17+ this . advice = null ;
18+ } ,
19+
20+ sync ( ) {
21+ const newSettings = _ . extend ( { } , plugSettings . settings ) ;
22+ const muted = $ ( '#volume .icon' ) . hasClass ( 'icon-volume-off' ) ;
23+ // when you mute a song using the volume button, plug.dj does not change the associated setting.
24+ // here we fake a volume of 0% anyway if the volume is muted, so ExtPlug modules can just
25+ // use volume throughout and have it work.
26+ if ( newSettings . volume !== 0 && muted ) {
27+ newSettings . volume = 0 ;
28+ }
29+ newSettings . muted = muted ;
30+ extMirror . set ( newSettings ) ;
31+ }
32+ } ) ;
33+
34+ export default PlugSettingsPlugin ;
Original file line number Diff line number Diff line change 1- import _ from 'underscore' ;
2- import plugSettings from 'plug/store/settings' ;
31import Settings from '../models/Settings' ;
42
5- const settings = new Settings ( ) ;
6-
7- function sync ( ) {
8- let newSettings = _ . extend ( { } , plugSettings . settings ) ;
9- let muted = $ ( '#volume .icon' ) . hasClass ( 'icon-volume-off' ) ;
10- // when you mute a song using the volume button, plug.dj does not change the associated setting.
11- // here we fake a volume of 0% anyway if the volume is muted, so ExtPlug modules can just
12- // use volume throughout and have it work.
13- if ( newSettings . volume !== 0 && muted ) {
14- newSettings . volume = 0 ;
15- }
16- newSettings . muted = muted ;
17- settings . set ( newSettings ) ;
18- }
19-
20- settings . update = sync ;
21-
22- export default settings ;
3+ export default new Settings ( ) ;
You can’t perform that action at this time.
0 commit comments