@@ -7,17 +7,28 @@ import type {
77 IStatusIndicator ,
88} from "src/ghosttext-runner"
99import type { EmailState } from "src/ghosttext-session"
10- import type { IComposeWindow , IGhostServerPort } from "./api"
10+ import type { MessageId } from "src/util"
11+ import type { IComposeWindow , IGhostServerPort , INotificationTray } from "./api"
1112
1213export class EmailEditor implements IClientEditor , IStatusIndicator {
14+ private lastStatus : ClientStatus | undefined
15+
1316 constructor (
17+ private readonly notificationTray : INotificationTray ,
1418 private readonly composeWindow : IComposeWindow ,
1519 private readonly port : IGhostServerPort ,
1620 private readonly options : ClientOptions ,
1721 ) { }
1822
1923 update ( status : ClientStatus ) : Promise < void > {
20- return this . composeWindow . setIcon ( imageForStatus ( status ) )
24+ const icon = imageForStatus ( status )
25+
26+ if ( status !== ( this . lastStatus ?? "inactive" ) ) {
27+ this . notificationTray . showNotification ( icon , messageForStatus ( status ) )
28+ }
29+ this . lastStatus = status
30+
31+ return this . composeWindow . setIcon ( icon )
2132 }
2233
2334 async getState ( ) : Promise < EmailState > {
@@ -63,3 +74,14 @@ function imageForStatus(status: ClientStatus): string {
6374 return "red.svg"
6475 }
6576}
77+
78+ function messageForStatus ( status : ClientStatus ) : MessageId {
79+ switch ( status ) {
80+ case "active" :
81+ return "src_client_status_active"
82+ case "inactive" :
83+ return "src_client_status_inactive"
84+ case "error" :
85+ return "src_client_status_error"
86+ }
87+ }
0 commit comments