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
54
55
56
57
58
59
60
61
62
|
import { sprintf } from 'sprintf-js';
import { messages } from '../../shared/gettext';
import { RoutePath } from '../../shared/routes';
import { AppVersionInfoSuggestedUpgrade } from '../daemon-rpc-types';
import {
SystemNotification,
SystemNotificationCategory,
SystemNotificationProvider,
SystemNotificationSeverityType,
} from './notification';
interface UpdateAvailableNotificationContext {
suggestedUpgrade?: AppVersionInfoSuggestedUpgrade;
suggestedIsBeta?: boolean;
}
export class UpdateAvailableNotificationProvider implements SystemNotificationProvider {
public constructor(private context: UpdateAvailableNotificationContext) {}
public mayDisplay() {
return this.context.suggestedUpgrade?.version ? true : false;
}
public getSystemNotification(): SystemNotification {
return {
message: this.systemMessage(),
category: SystemNotificationCategory.newVersion,
severity: SystemNotificationSeverityType.medium,
action: {
type: 'navigate-internal',
link: {
text: messages.pgettext('notifications', 'Upgrade'),
to: RoutePath.appUpgrade,
},
},
presentOnce: { value: true, name: this.constructor.name },
suppressInDevelopment: true,
};
}
private systemMessage(): string {
if (this.context.suggestedIsBeta) {
return sprintf(
// TRANSLATORS: The system notification that notifies the user when a beta update is
// TRANSLATORS: available.
// TRANSLATORS: Available placeholders:
// TRANSLATORS: %(version)s - The version number of the new beta version.
messages.pgettext(
'notifications',
'Beta update available. Try out the newest beta version (%(version)s).',
),
{ version: this.context.suggestedUpgrade?.version },
);
} else {
return messages.pgettext(
'notifications',
'Update available. Install the latest app version to stay up to date',
);
}
}
}
|