blob: c97b0a201fa1aa176559f1dfb636ba221c71d0b3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import delegate, {DelegateEvent} from 'delegate-it';
import features from '../feature-manager.js';
const hasNotificationBar = (): boolean =>
location.search.startsWith('?notification_referrer_id=')
|| JSON.parse(sessionStorage.getItem('notification_shelf') ?? '{}').pathname === location.pathname;
function handleClick(event: DelegateEvent<MouseEvent, HTMLButtonElement>): void {
// Disable the redirect to the Notifications inbox if either:
// 1. The alt key was held down during click (user choice)
// 2. The notification has been opened in a new tab (the inbox is still open in the previous tab)
const redirectDisabled = event.altKey || sessionStorage.rghIsNewTab === 'true';
event.delegateTarget.form!.toggleAttribute('data-redirect-to-inbox-on-submit', !redirectDisabled);
}
function init(signal: AbortSignal): void {
sessionStorage.rghIsNewTab = history.length === 1;
delegate('.notification-shelf .js-notification-action button', 'click', handleClick, {signal});
}
void features.add(import.meta.url, {
include: [
hasNotificationBar,
],
init,
});
|