Skip to content

Commit

Permalink
Default allow screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Dec 24, 2024
1 parent 9b40772 commit fee13ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apps/desktop/src/app/accounts/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ <h2>
type="checkbox"
aria-describedby="allowScreenshotsHelp"
formControlName="allowScreenshots"
(change)="saveAllowScreenshots()"
(change)="savePreventScreenshots()"
/>
{{ "allowScreenshots" | i18n }}
</label>
Expand Down
14 changes: 4 additions & 10 deletions apps/desktop/src/app/accounts/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
}),
enableHardwareAcceleration: true,
enableSshAgent: false,
allowScreenshots: true,
allowScreenshots: false,
enableDuckDuckGoBrowserIntegration: false,
theme: [null as ThemeType | null],
locale: [null as string | null],
Expand Down Expand Up @@ -283,7 +283,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
this.desktopSettingsService.hardwareAcceleration$,
),
enableSshAgent: await firstValueFrom(this.desktopSettingsService.sshAgentEnabled$),
allowScreenshots: await firstValueFrom(this.desktopSettingsService.allowScreenshots$),
allowScreenshots: !(await firstValueFrom(this.desktopSettingsService.preventScreenshots$)),
theme: await firstValueFrom(this.themeStateService.selectedTheme$),
locale: await firstValueFrom(this.i18nService.userSetLocale$),
};
Expand Down Expand Up @@ -748,14 +748,8 @@ export class SettingsComponent implements OnInit, OnDestroy {
await this.desktopSettingsService.setSshAgentEnabled(this.form.value.enableSshAgent);
}

async saveEnableScreenshotProtection() {
await this.desktopSettingsService.setScreenshotProtection(
this.form.value.enableScreenshotProtection,
);
}

async saveAllowScreenshots() {
await this.desktopSettingsService.setAllowScreenshots(this.form.value.allowScreenshots);
async savePreventScreenshots() {
await this.desktopSettingsService.setPreventScreenshots(!this.form.value.allowScreenshots);

Check warning on line 752 in apps/desktop/src/app/accounts/settings.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/accounts/settings.component.ts#L752

Added line #L752 was not covered by tests
}

private async generateVaultTimeoutOptions(): Promise<VaultTimeoutOption[]> {
Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/main/window.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ export class WindowMain {
}
});

this.desktopSettingsService.allowScreenshots$.subscribe((allowed) => {
this.desktopSettingsService.preventScreenshots$.subscribe((prevent) => {

Check warning on line 79 in apps/desktop/src/main/window.main.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/main/window.main.ts#L79

Added line #L79 was not covered by tests
if (this.win == null) {
return;

Check warning on line 81 in apps/desktop/src/main/window.main.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/main/window.main.ts#L81

Added line #L81 was not covered by tests
}
this.win.setContentProtection(!allowed);
this.win.setContentProtection(prevent);

Check warning on line 83 in apps/desktop/src/main/window.main.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/main/window.main.ts#L83

Added line #L83 was not covered by tests
});

return new Promise<void>((resolve, reject) => {
Expand Down Expand Up @@ -284,9 +284,9 @@ export class WindowMain {
});
});

firstValueFrom(this.desktopSettingsService.allowScreenshots$)
.then((allowScreenshots) => {
this.win.setContentProtection(!allowScreenshots);
firstValueFrom(this.desktopSettingsService.preventScreenshots$)

Check warning on line 287 in apps/desktop/src/main/window.main.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/main/window.main.ts#L287

Added line #L287 was not covered by tests
.then((preventScreenshots) => {
this.win.setContentProtection(preventScreenshots);

Check warning on line 289 in apps/desktop/src/main/window.main.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/main/window.main.ts#L289

Added line #L289 was not covered by tests
})
.catch((e) => {
this.logService.error(e);

Check warning on line 292 in apps/desktop/src/main/window.main.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/main/window.main.ts#L292

Added line #L292 was not covered by tests
Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/platform/services/desktop-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const MINIMIZE_ON_COPY = new UserKeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "
clearOn: [], // User setting, no need to clear
});

const ALLOW_SCREENSHOTS = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "allowAppScreenshots", {
const PEVENT_SCREENSHOTS = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "preventScreenshots", {
deserializer: (b) => b,

Check warning on line 79 in apps/desktop/src/platform/services/desktop-settings.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/platform/services/desktop-settings.service.ts#L78-L79

Added lines #L78 - L79 were not covered by tests
});

Expand Down Expand Up @@ -151,12 +151,12 @@ export class DesktopSettingsService {

sshAgentEnabled$ = this.sshAgentEnabledState.state$.pipe(map(Boolean));

private readonly allowScreenshotState = this.stateProvider.getGlobal(ALLOW_SCREENSHOTS);
private readonly preventScreenshotState = this.stateProvider.getGlobal(PEVENT_SCREENSHOTS);

Check warning on line 154 in apps/desktop/src/platform/services/desktop-settings.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/platform/services/desktop-settings.service.ts#L154

Added line #L154 was not covered by tests

/**
* The application setting for whether or not to allow screenshots of the app.
*/
allowScreenshots$ = this.allowScreenshotState.state$.pipe(map(Boolean));
preventScreenshots$ = this.preventScreenshotState.state$.pipe(map(Boolean));

Check warning on line 159 in apps/desktop/src/platform/services/desktop-settings.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/platform/services/desktop-settings.service.ts#L159

Added line #L159 was not covered by tests

private readonly minimizeOnCopyState = this.stateProvider.getActive(MINIMIZE_ON_COPY);

Expand Down Expand Up @@ -286,7 +286,7 @@ export class DesktopSettingsService {
* Sets the setting for whether or not the screenshot protection is enabled.
* @param value `true` if the screenshot protection is enabled, `false` if it is not.
*/
async setAllowScreenshots(value: boolean) {
await this.allowScreenshotState.update(() => value);
async setPreventScreenshots(value: boolean) {
await this.preventScreenshotState.update(() => value);

Check warning on line 290 in apps/desktop/src/platform/services/desktop-settings.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/platform/services/desktop-settings.service.ts#L290

Added line #L290 was not covered by tests
}
}

0 comments on commit fee13ea

Please sign in to comment.