blob: 3b574dad1888c093b66ee94fc0a0faa75b115447 (
plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import { sprintf } from 'sprintf-js';
import { messages } from '../../shared/gettext';
import { TunnelState } from '../daemon-rpc-types';
import {
InAppNotification,
InAppNotificationProvider,
SystemNotificationProvider,
} from './notification';
interface ConnectingNotificationContext {
tunnelState: TunnelState;
reconnecting?: boolean;
}
export class ConnectingNotificationProvider
implements SystemNotificationProvider, InAppNotificationProvider {
public constructor(private context: ConnectingNotificationContext) {}
public mayDisplay() {
return this.context.tunnelState.state === 'connecting' && !this.context.reconnecting;
}
public getSystemNotification() {
if (this.context.tunnelState.state === 'connecting') {
let message = messages.pgettext('notifications', 'Connecting');
const location = this.context.tunnelState.details?.location?.hostname;
if (location) {
message = sprintf(
// TRANSLATORS: The message showed when a server is being connected to.
// TRANSLATORS: Available placeholder:
// TRANSLATORS: %(location) - name of the server location we're connecting to (e.g. "se-got-003")
messages.pgettext('notifications', 'Connecting to %(location)s'),
{
location,
},
);
}
return {
message,
critical: false,
};
} else {
return undefined;
}
}
public getInAppNotification(): InAppNotification {
return {
title: messages.pgettext('in-app-notifications', 'BLOCKING INTERNET'),
};
}
}
|