@@ -50,7 +50,11 @@ export const useStatusStore = create((set, get) => ({
5050 applyPlayerVol ( vol , zones , sourceId , ( zone_id , new_vol ) => {
5151 for ( const i in s . status . zones ) {
5252 if ( s . status . zones [ i ] . id === zone_id ) {
53- s . status . zones [ i ] . vol_f = new_vol ;
53+ let true_vol = Math . round ( ( new_vol + s . status . zones [ i ] . vol_f_buffer ) * 100 ) / 100 ;
54+ let clamped = Math . min ( Math . max ( true_vol , 0 ) , 1 ) ;
55+
56+ s . status . zones [ i ] . vol_f = clamped ;
57+ s . status . zones [ i ] . vol_f_buffer = true_vol - clamped ;
5458 }
5559 }
5660 } ) ;
@@ -61,11 +65,17 @@ export const useStatusStore = create((set, get) => ({
6165 setZonesMute : ( mute , zones , source_id ) => {
6266 set (
6367 produce ( ( s ) => {
64- for ( const i of getSourceZones ( source_id , zones ) ) {
65- for ( const j of s . status . zones ) {
66- if ( j . id === i . id ) {
67- j . mute = mute ;
68- }
68+ const affectedZones = getSourceZones ( source_id , zones ) . map ( z => z . id ) ;
69+ for ( const j of s . status . zones ) {
70+ if ( affectedZones . includes ( j . id ) ) {
71+ j . mute = mute ;
72+ }
73+ }
74+
75+ // Also update groups that consist entirely of affected zones
76+ for ( const g of s . status . groups ) {
77+ if ( g . zones . every ( zid => affectedZones . includes ( zid ) ) ) {
78+ g . mute = mute ;
6979 }
7080 }
7181 } )
@@ -131,7 +141,7 @@ export const useStatusStore = create((set, get) => ({
131141 if ( get ( ) . skipUpdate ) {
132142 // Does .then() into skipUpdate and ignores api output to help avoid race conditions
133143 set ( { skipUpdate : false } ) ;
134- } else {
144+ } else if ( get ( ) . status == null ) {
135145 set ( { status : s , loaded : true , disconnected : false } ) ;
136146 }
137147 } ) ;
@@ -164,7 +174,7 @@ export const useStatusStore = create((set, get) => ({
164174 const g = s . status . groups . filter ( ( g ) => g . id === groupId ) [ 0 ] ;
165175 for ( const i of g . zones ) {
166176 s . skipUpdate = true ;
167- s . status . zones [ i ] . vol_f = new_vol ;
177+ s . status . zones [ i ] . vol_f = new_vol + s . status . zones [ i ] . vol_f_buffer ;
168178 }
169179
170180 updateGroupVols ( s ) ;
@@ -198,7 +208,7 @@ export const useStatusStore = create((set, get) => ({
198208const updateGroupVols = ( s ) => {
199209 s . status . groups . forEach ( ( g ) => {
200210 if ( g . zones . length > 1 ) {
201- const vols = g . zones . map ( ( id ) => s . status . zones [ id ] . vol_f ) ;
211+ const vols = g . zones . map ( ( id ) => s . status . zones [ id ] . vol_f + s . status . zones [ id ] . vol_f_buffer ) ;
202212 let calculated_vol = Math . min ( ...vols ) * 0.5 + Math . max ( ...vols ) * 0.5 ;
203213 g . vol_f = calculated_vol ;
204214 } else if ( g . zones . length == 1 ) {
@@ -226,14 +236,14 @@ Page.propTypes = {
226236
227237const App = ( { selectedPage } ) => {
228238 return (
229- < div className = "app" >
239+ < div className = "app" >
230240 < DisconnectedIcon />
231241 < div className = "background-gradient" > </ div > { /* Used to make sure the background doesn't stretch or stop prematurely on scrollable pages */ }
232- < div className = "app-body" >
233- < Page selectedPage = { selectedPage } />
234- </ div >
235- < MenuBar pageNumber = { selectedPage } />
242+ < div className = "app-body" >
243+ < Page selectedPage = { selectedPage } />
236244 </ div >
245+ < MenuBar pageNumber = { selectedPage } />
246+ </ div >
237247 ) ;
238248} ;
239249App . propTypes = {
0 commit comments