summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared/notifications/disconnected.ts
blob: 05c53148ec493c55f6b2cb86d838157530c40645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { messages } from '../../shared/gettext';
import { TunnelState } from '../daemon-rpc-types';
import { SystemNotificationProvider } from './notification';

interface DisconnectedNotificationContext {
  tunnelState: TunnelState;
  blockWhenDisconnected: boolean;
}

export class DisconnectedNotificationProvider implements SystemNotificationProvider {
  public constructor(private context: DisconnectedNotificationContext) {}

  public mayDisplay = () =>
    this.context.tunnelState.state === 'disconnected' && !this.context.blockWhenDisconnected;

  public getSystemNotification() {
    return {
      message: messages.pgettext('notifications', 'Disconnected and unsecure'),
      critical: false,
    };
  }
}