summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared/notifications/reconnecting.ts
blob: 43491322f02abb0337dfe8e54c407820d10e2675 (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
import { messages } from '../../shared/gettext';
import { TunnelState } from '../daemon-rpc-types';
import {
  InAppNotification,
  InAppNotificationProvider,
  SystemNotification,
  SystemNotificationCategory,
  SystemNotificationProvider,
  SystemNotificationSeverityType,
} from './notification';

export class ReconnectingNotificationProvider
  implements SystemNotificationProvider, InAppNotificationProvider {
  public constructor(private context: TunnelState) {}

  public mayDisplay() {
    return this.context.state === 'disconnecting' && this.context.details === 'reconnect';
  }

  public getSystemNotification(): SystemNotification | undefined {
    return {
      message: messages.pgettext('notifications', 'Reconnecting'),
      severity: SystemNotificationSeverityType.info,
      category: SystemNotificationCategory.tunnelState,
      throttle: true,
    };
  }

  public getInAppNotification(): InAppNotification {
    return {
      title: messages.pgettext('in-app-notifications', 'BLOCKING INTERNET'),
    };
  }
}