summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared/notifications/disconnected.ts
blob: 6a867a74528d0f4499cddad1428a0824dcff05c7 (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 unsecured'),
      critical: false,
    };
  }
}