Update JackServerSettingsDialog.tsx
More time on trying to make sure that Ok behaves correctly.
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
import { Theme } from '@mui/material/styles';
|
import { Theme } from '@mui/material/styles';
|
||||||
@@ -303,32 +303,32 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
|
|
||||||
constructor(props: JackServerSettingsDialogProps) {
|
constructor(props: JackServerSettingsDialogProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.model = PiPedalModelFactory.getInstance();
|
this.model = PiPedalModelFactory.getInstance();
|
||||||
|
|
||||||
|
|
||||||
this.suppressDeviceWarning = localStorage.getItem("suppressSeparateDeviceWarning") === "1";
|
this.suppressDeviceWarning = localStorage.getItem("suppressSeparateDeviceWarning") === "1";
|
||||||
this.state = {
|
this.state = {
|
||||||
latencyText: getLatencyText(props.jackServerSettings),
|
latencyText: getLatencyText(props.jackServerSettings),
|
||||||
jackServerSettings: props.jackServerSettings.clone(), // invalid, but not nullish
|
jackServerSettings: props.jackServerSettings.clone(), // invalid, but not nullish
|
||||||
alsaDevices: undefined,
|
alsaDevices: undefined,
|
||||||
okEnabled: false,
|
okEnabled: false,
|
||||||
fullScreen: this.getFullScreen(),
|
fullScreen: this.getFullScreen(),
|
||||||
compactWidth: document.documentElement.clientWidth < 600,
|
compactWidth: document.documentElement.clientWidth < 600,
|
||||||
jackStatus: undefined,
|
jackStatus: undefined,
|
||||||
showDeviceWarning: false,
|
showDeviceWarning: false,
|
||||||
dontShowWarningAgain: false
|
dontShowWarningAgain: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
mounted: boolean = false;
|
mounted: boolean = false;
|
||||||
statusTimer?: number = undefined;
|
statusTimer?: number = undefined;
|
||||||
|
|
||||||
suppressDeviceWarning: boolean;
|
suppressDeviceWarning: boolean;
|
||||||
/**
|
/**
|
||||||
* Copy of the settings when the dialog is opened. Pressing Apply only tests these settings temporarily. Closing the dialog without OK re-applies the saved copy so the audio driver returns to its previous configuration.
|
* Copy of the settings when the dialog is opened. Pressing Apply only tests these settings temporarily. Closing the dialog without OK re-applies the saved copy so the audio driver returns to its previous configuration.
|
||||||
*/
|
*/
|
||||||
originalJackServerSettings?: JackServerSettings;
|
originalJackServerSettings?: JackServerSettings;
|
||||||
|
|
||||||
getFullScreen() {
|
getFullScreen() {
|
||||||
return document.documentElement.clientWidth < 420 ||
|
return document.documentElement.clientWidth < 420 ||
|
||||||
document.documentElement.clientHeight < 700;
|
document.documentElement.clientHeight < 700;
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
// Error requesting ALSA info.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,9 +495,10 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
if (this.props.open) {
|
if (this.props.open) {
|
||||||
this.requestAlsaInfo();
|
this.requestAlsaInfo();
|
||||||
this.startStatusTimer();
|
this.startStatusTimer();
|
||||||
|
this.saveSettingsTemporary(this.props.jackServerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(oldProps: JackServerSettingsDialogProps) {
|
componentDidUpdate(oldProps: JackServerSettingsDialogProps) {
|
||||||
if ((this.props.open && !oldProps.open) && this.mounted) {
|
if ((this.props.open && !oldProps.open) && this.mounted) {
|
||||||
this.ignoreClose = false;
|
this.ignoreClose = false;
|
||||||
@@ -512,7 +513,7 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
this.setState({
|
this.setState({
|
||||||
jackServerSettings: settings,
|
jackServerSettings: settings,
|
||||||
latencyText: getLatencyText(settings),
|
latencyText: getLatencyText(settings),
|
||||||
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
||||||
});
|
});
|
||||||
if (!this.state.alsaDevices) {
|
if (!this.state.alsaDevices) {
|
||||||
this.requestAlsaInfo();
|
this.requestAlsaInfo();
|
||||||
@@ -535,12 +536,8 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
this.saveSettings(this.originalJackServerSettings);
|
this.saveSettings(this.originalJackServerSettings);
|
||||||
this.originalJackServerSettings = undefined;
|
this.originalJackServerSettings = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedDevice(deviceId: string): AlsaDeviceInfo | undefined {
|
getSelectedDevice(deviceId: string): AlsaDeviceInfo | undefined {
|
||||||
if (!this.state.alsaDevices) return undefined;
|
if (!this.state.alsaDevices) return undefined;
|
||||||
for (let i = 0; i < this.state.alsaDevices.length; ++i) {
|
for (let i = 0; i < this.state.alsaDevices.length; ++i) {
|
||||||
@@ -609,22 +606,29 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
this.startStatusTimer();
|
this.startStatusTimer();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleOk() {
|
handleOk() {
|
||||||
if (!this.state.okEnabled) return;
|
if (!this.state.okEnabled) return;
|
||||||
|
|
||||||
|
const proceedWithOk = () => {
|
||||||
|
this.ignoreClose = true; // Indicate that the closing is intentional
|
||||||
|
this.releaseDevices(); // Release devices
|
||||||
|
this.applySettings(); // Apply current settings
|
||||||
|
this.saveSettings(); // Save settings permanently
|
||||||
|
this.originalJackServerSettings = undefined;
|
||||||
|
if (this.props.onApply) {
|
||||||
|
this.props.onApply(this.state.jackServerSettings.clone());
|
||||||
|
}
|
||||||
|
this.props.onClose(); // Close the dialog
|
||||||
|
};
|
||||||
|
|
||||||
if (this.state.jackServerSettings.alsaInputDevice !== this.state.jackServerSettings.alsaOutputDevice
|
if (this.state.jackServerSettings.alsaInputDevice !== this.state.jackServerSettings.alsaOutputDevice
|
||||||
&& !this.suppressDeviceWarning) {
|
&& !this.suppressDeviceWarning) {
|
||||||
this.setState({ showDeviceWarning: true });
|
this.setState({ showDeviceWarning: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// apply and persist the selected settings
|
|
||||||
this.ignoreClose = true;
|
proceedWithOk();
|
||||||
this.releaseDevices();
|
|
||||||
this.applySettings();
|
|
||||||
this.saveSettings();
|
|
||||||
this.originalJackServerSettings = undefined;
|
|
||||||
if (this.props.onApply) {
|
|
||||||
this.props.onApply(this.state.jackServerSettings.clone());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handleWarningProceed() {
|
handleWarningProceed() {
|
||||||
@@ -641,9 +645,10 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
if (this.props.onApply) {
|
if (this.props.onApply) {
|
||||||
this.props.onApply(this.state.jackServerSettings.clone());
|
this.props.onApply(this.state.jackServerSettings.clone());
|
||||||
}
|
}
|
||||||
|
this.props.onClose(); // Close the dialog after the warning
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleWarningCancel() {
|
handleWarningCancel() {
|
||||||
this.setState({ showDeviceWarning: false, dontShowWarningAgain: false });
|
this.setState({ showDeviceWarning: false, dontShowWarningAgain: false });
|
||||||
}
|
}
|
||||||
@@ -687,7 +692,7 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
if (this.ignoreClose) {
|
if (this.ignoreClose) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.releaseDevices();
|
this.releaseDevices();
|
||||||
if (this.originalJackServerSettings) {
|
if (this.originalJackServerSettings) {
|
||||||
// Revert any applied settings
|
// Revert any applied settings
|
||||||
this.applySettings(this.originalJackServerSettings);
|
this.applySettings(this.originalJackServerSettings);
|
||||||
|
|||||||
Reference in New Issue
Block a user