summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared/notifications/inconsistentVersion.ts
blob: 94c33bd925606c579c4773c6cfcfec7dcdf7f93e (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
import { messages } from '../../shared/gettext';
import {
  InAppNotification,
  InAppNotificationProvider,
  SystemNotification,
  SystemNotificationProvider,
} from './notification';

interface InconsistentVersionNotificationContext {
  consistent: boolean;
}

export class InconsistentVersionNotificationProvider
  implements SystemNotificationProvider, InAppNotificationProvider {
  public constructor(private context: InconsistentVersionNotificationContext) {}

  public mayDisplay = () => !this.context.consistent;

  public getSystemNotification(): SystemNotification {
    return {
      message: messages.pgettext(
        'notifications',
        'Inconsistent internal version information, please restart the app',
      ),
      critical: true,
      presentOnce: { value: true, name: this.constructor.name },
      suppressInDevelopment: true,
    };
  }

  public getInAppNotification(): InAppNotification {
    return {
      indicator: 'error',
      title: messages.pgettext('in-app-notifications', 'INCONSISTENT VERSION'),
      subtitle: messages.pgettext(
        'in-app-notifications',
        'Inconsistent internal version information, please restart the app',
      ),
    };
  }
}