Browse Source

fix clear session active in mobile

pull/18/head
Sun 4 years ago
parent
commit
c99643276e
  1. 8
      lib/apps/chat/detail.dart
  2. 7
      lib/apps/group_chat/detail.dart
  3. 18
      lib/provider.dart

8
lib/apps/chat/detail.dart

@ -14,7 +14,7 @@ import 'package:esse/widgets/chat_message.dart'; @@ -14,7 +14,7 @@ import 'package:esse/widgets/chat_message.dart';
import 'package:esse/widgets/show_contact.dart';
import 'package:esse/global.dart';
import 'package:esse/provider.dart';
import 'package:esse/session.dart';
import 'package:esse/session.dart' show SessionType, OnlineType;
import 'package:esse/apps/primitives.dart';
import 'package:esse/apps/chat/models.dart';
@ -53,6 +53,12 @@ class _ChatDetailState extends State<ChatDetail> { @@ -53,6 +53,12 @@ class _ChatDetailState extends State<ChatDetail> {
});
}
@override
void deactivate() {
context.read<AccountProvider>().clearActivedSession(SessionType.Chat);
super.deactivate();
}
_generateRecordPath() {
this._recordName = DateTime.now().millisecondsSinceEpoch.toString() +
'_' +

7
lib/apps/group_chat/detail.dart

@ -18,6 +18,7 @@ import 'package:esse/widgets/show_contact.dart'; @@ -18,6 +18,7 @@ import 'package:esse/widgets/show_contact.dart';
import 'package:esse/rpc.dart';
import 'package:esse/global.dart';
import 'package:esse/provider.dart';
import 'package:esse/session.dart' show SessionType;
import 'package:esse/apps/primitives.dart';
import 'package:esse/apps/group_chat/models.dart';
@ -57,6 +58,12 @@ class _GroupChatDetailState extends State<GroupChatDetail> { @@ -57,6 +58,12 @@ class _GroupChatDetailState extends State<GroupChatDetail> {
});
}
@override
void deactivate() {
context.read<AccountProvider>().clearActivedSession(SessionType.Group);
super.deactivate();
}
_generateRecordPath() {
this._recordName = DateTime.now().millisecondsSinceEpoch.toString() +
'_' +

18
lib/provider.dart

@ -207,6 +207,16 @@ class AccountProvider extends ChangeNotifier { @@ -207,6 +207,16 @@ class AccountProvider extends ChangeNotifier {
notifyListeners();
}
clearActivedSession(SessionType type) {
if (this.activedSession.type == type && this.actived > 0) {
rpc.send('session-suspend', [this.actived, this.activedSession.gid,
this.activedSession.type == SessionType.Group]
);
this.actived = 0;
this.coreShowWidget = DefaultCoreShow();
}
}
updateActivedSession(int id, [SessionType type, int fid]) {
if (fid != null && fid > 0) {
for (int k in this.sessions.keys) {
@ -221,11 +231,9 @@ class AccountProvider extends ChangeNotifier { @@ -221,11 +231,9 @@ class AccountProvider extends ChangeNotifier {
if (id > 0) {
if (this.actived != id && this.actived > 0) {
bool must = false;
if (this.activedSession.type == SessionType.Group) {
must = true;
}
rpc.send('session-suspend', [this.actived, this.activedSession.gid, must]);
rpc.send('session-suspend', [this.actived, this.activedSession.gid,
this.activedSession.type == SessionType.Group]
);
}
this.actived = id;
this.activedSession.lastReaded = true;

Loading…
Cancel
Save