Skip to content

Commit f616dbd

Browse files
committed
feat: expand auto-lock options and reset timer on Nostr tab focus
Add 90-minute and 3-hour auto-lock options, rename "60 minutes" to "1 hour". Reset the auto-lock timer whenever a tab with window.nostr injected gains visibility — so actively browsing Nostr clients no longer triggers unexpected lockouts.
1 parent d0ee5f2 commit f616dbd

7 files changed

Lines changed: 35 additions & 6 deletions

File tree

distros/safari/content.build.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distros/safari/content.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ shouldInject().then(inject => {
2121
let script = document.createElement('script');
2222
script.setAttribute('src', api.runtime.getURL('nostr.build.js'));
2323
document.body.appendChild(script);
24+
25+
// Reset auto-lock timer when a Nostr-enabled tab gains focus
26+
document.addEventListener('visibilitychange', () => {
27+
if (document.visibilityState === 'visible') {
28+
api.runtime.sendMessage({ kind: 'resetAutoLock' }).catch(() => {});
29+
}
30+
});
2431
});
2532

2633
// Permission bottom sheet

distros/safari/security/security.build.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distros/safari/security/security.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ <h3 class="subsection-header">Remove Master Password</h3>
317317
<option value="5">5 minutes</option>
318318
<option value="15">15 minutes</option>
319319
<option value="30">30 minutes</option>
320-
<option value="60">60 minutes</option>
320+
<option value="60">1 hour</option>
321+
<option value="90">90 minutes</option>
322+
<option value="180">3 hours</option>
321323
<option value="0">Never</option>
322324
</select>
323325
</div>

src/content.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ shouldInject().then(inject => {
2121
let script = document.createElement('script');
2222
script.setAttribute('src', api.runtime.getURL('nostr.build.js'));
2323
document.body.appendChild(script);
24+
25+
// Reset auto-lock timer when a Nostr-enabled tab gains focus
26+
document.addEventListener('visibilitychange', () => {
27+
if (document.visibilityState === 'visible') {
28+
api.runtime.sendMessage({ kind: 'resetAutoLock' }).catch(() => {});
29+
}
30+
});
2431
});
2532

2633
// Permission bottom sheet

src/security/security.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ <h3 class="subsection-header">Remove Master Password</h3>
317317
<option value="5">5 minutes</option>
318318
<option value="15">15 minutes</option>
319319
<option value="30">30 minutes</option>
320-
<option value="60">60 minutes</option>
320+
<option value="60">1 hour</option>
321+
<option value="90">90 minutes</option>
322+
<option value="180">3 hours</option>
321323
<option value="0">Never</option>
322324
</select>
323325
</div>

src/security/security.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,13 @@ async function handleAutoLockChange() {
300300
payload: minutes,
301301
});
302302

303+
const label = minutes === 0 ? 'disabled'
304+
: minutes === 60 ? '1 hour'
305+
: minutes === 180 ? '3 hours'
306+
: `${minutes} minutes`;
303307
state.autolockSuccess = minutes === 0
304308
? 'Auto-lock disabled.'
305-
: `Auto-lock set to ${minutes} minutes.`;
309+
: `Auto-lock set to ${label}.`;
306310
render();
307311
setTimeout(() => { state.autolockSuccess = ''; render(); }, 3000);
308312
}

0 commit comments

Comments
 (0)