fix(desktop): show unsupported when non-GNOME portal bind fails (#3188)

This commit is contained in:
Hampus
2026-10-04 02:38:06 +02:00
committed by GitHub
parent 5d0c9c7cbe
commit 1544e58e76
2 changed files with 41 additions and 1 deletions
@@ -194,6 +194,38 @@ describe('LinuxPortalShortcutsManager consent', () => {
}); });
} }
for (const desktop of ['other', 'kde', 'hyprland']) {
test(`a denied bind on ${desktop} means the backend cannot bind, not a user decline`, async () => {
const harness = createHarness({consent: 'unset', desktop});
harness.bindResults.push({outcome: 'denied'});
await harness.manager.activate();
await harness.manager.setUp();
assert.equal(harness.manager.getState(), 'unsupported');
assert.equal(harness.manager.getStatus().canRecheck, true);
assert.equal(harness.consent, 'unset');
});
}
test('try again after an old stored decline on a non-GNOME desktop settles on unsupported', async () => {
const harness = createHarness({consent: 'declined', desktop: 'other'});
harness.bindResults.push({outcome: 'denied'});
await harness.manager.activate();
await harness.manager.probe();
assert.equal(harness.manager.getState(), 'declined');
await harness.manager.setUp();
assert.equal(harness.manager.getState(), 'unsupported');
assert.equal(harness.consent, 'unset');
});
test('a cancelled bind on KDE is still a user decline', async () => {
const harness = createHarness({consent: 'unset', desktop: 'kde'});
harness.bindResults.push({outcome: 'cancelled'});
await harness.manager.activate();
await harness.manager.setUp();
assert.equal(harness.manager.getState(), 'declined');
assert.equal(harness.consent, 'declined');
});
test('a failed bind is an error that keeps consent untouched', async () => { test('a failed bind is an error that keeps consent untouched', async () => {
const harness = createHarness({consent: 'unset'}); const harness = createHarness({consent: 'unset'});
harness.bindResults.push({outcome: 'failed', code: 3}); harness.bindResults.push({outcome: 'failed', code: 3});
@@ -412,8 +412,16 @@ export class LinuxPortalShortcutsManager {
this.deps.setConsent('granted'); this.deps.setConsent('granted');
this.setState('bound', null); this.setState('bound', null);
return; return;
case 'cancelled':
case 'denied': case 'denied':
if (this.deps.desktop !== 'gnome') {
this.deps.setConsent('unset');
this.setState('unsupported', null);
return;
}
this.deps.setConsent('declined');
this.setState('declined', null);
return;
case 'cancelled':
this.deps.setConsent('declined'); this.deps.setConsent('declined');
this.setState('declined', null); this.setState('declined', null);
return; return;