Skip to content

Commit

Permalink
Improve device settings (#869)
Browse files Browse the repository at this point in the history
This PR improves the behavior of the device settings, by: 
1) We now invoke `updatedDeviceSettings` only when the user releases the
"font size" slider, this change prevents issues with applications not
being able to handle updates in quick succession and better models how
the end user would change the font size.
2) we only send `replaysEnabled` and `showTouches` to the sim-server
when the new setting is a change compared to the previous one preventing
sim-server from logging errors about setting already being enabled like
the following:
```
sim-server: video_error replay already exists
```


### How Has This Been Tested: 

run test application and see if the `updatedDeviceSettings` is invoked
only once per slide and if sim-server is affected by changes unrelated
to it
  • Loading branch information
filip131311 authored Dec 20, 2024
1 parent 70b8723 commit 58fcf85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions packages/vscode-extension/src/project/deviceSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,21 @@ export class DeviceSession implements Disposable {
}

public async changeDeviceSettings(settings: DeviceSettings): Promise<boolean> {
this.deviceSettings = settings;
if (settings.replaysEnabled && !this.isLaunching) {
this.device.enableReplay();
} else {
this.device.disableReplays();
if (this.deviceSettings?.replaysEnabled !== settings.replaysEnabled && !this.isLaunching) {
if (settings.replaysEnabled) {
this.device.enableReplay();
} else {
this.device.disableReplays();
}
}
if (settings.showTouches && !this.isLaunching) {
this.device.showTouches();
} else {
this.device.hideTouches();
if (this.deviceSettings?.showTouches !== settings.showTouches && !this.isLaunching) {
if (settings.showTouches) {
this.device.showTouches();
} else {
this.device.hideTouches();
}
}
this.deviceSettings = settings;
return this.device.changeSettings(settings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function DeviceSettingsDropdown({ children, disabled }: DeviceSettingsDropdownPr
defaultValue={[contentSizes.indexOf(deviceSettings.contentSize)]}
max={6}
step={1}
onValueChange={([value]) => {
onValueCommit={([value]) => {
project.updateDeviceSettings({
...deviceSettings,
contentSize: contentSizes[value],
Expand Down

0 comments on commit 58fcf85

Please sign in to comment.