|
@@ -37,6 +37,7 @@ export class StateService {
|
|
|
// Events
|
|
|
public evtConnectionBuildupStateChange = new AsyncEvent<threema.ConnectionBuildupStateChange>();
|
|
|
public evtGlobalConnectionStateChange = new AsyncEvent<threema.GlobalConnectionStateChange>();
|
|
|
+ public evtUnreadCountChange = new AsyncEvent<number>();
|
|
|
|
|
|
// Connection states
|
|
|
public signalingConnectionState: saltyrtc.SignalingState;
|
|
@@ -53,6 +54,9 @@ export class StateService {
|
|
|
private _state: threema.GlobalConnectionState;
|
|
|
public wasConnected: boolean;
|
|
|
|
|
|
+ // Unread messages
|
|
|
+ private _unreadCount: number = 0;
|
|
|
+
|
|
|
public static $inject = ['$log', '$interval'];
|
|
|
constructor($log: ng.ILogService, $interval: ng.IIntervalService) {
|
|
|
this.$log = $log;
|
|
@@ -241,6 +245,21 @@ export class StateService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Getters and setters for unread messages count.
|
|
|
+ */
|
|
|
+ public get unreadCount(): number {
|
|
|
+ return this._unreadCount;
|
|
|
+ }
|
|
|
+ public set unreadCount(count: number) {
|
|
|
+ if (this._unreadCount === count) {
|
|
|
+ // No need to dispatch any events
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._unreadCount = count;
|
|
|
+ this.evtUnreadCountChange.post(count);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Reset all states.
|
|
|
*/
|
|
@@ -255,5 +274,6 @@ export class StateService {
|
|
|
this.wasConnected = false;
|
|
|
this.connectionBuildupState = connectionBuildupState;
|
|
|
this.progress = 0;
|
|
|
+ this.unreadCount = 0;
|
|
|
}
|
|
|
}
|