mirror of
https://github.com/Linloir/Simple-TCP-Client.git
synced 2025-12-18 17:28:11 +08:00
Bug Fix:
- Fix not updating user info after fetch contact
This commit is contained in:
parent
04846da2c3
commit
e184544750
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-10-13 14:01:45
|
||||
* @LastEditTime : 2022-10-20 16:36:05
|
||||
* @LastEditTime : 2022-10-23 12:09:26
|
||||
* @Description :
|
||||
*/
|
||||
|
||||
@ -22,7 +22,7 @@ class ContactCubit extends Cubit<ContactState> {
|
||||
}): super(ContactState.empty()) {
|
||||
subscription = tcpRepository.responseStreamBroadcast.listen(_onResponse);
|
||||
updateContacts();
|
||||
timer = Timer.periodic(const Duration(seconds: 20), (timer) {updateContacts();});
|
||||
timer = Timer.periodic(const Duration(seconds: 60), (timer) {updateContacts();});
|
||||
}
|
||||
|
||||
final LocalServiceRepository localServiceRepository;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-10-10 08:04:53
|
||||
* @LastEditTime : 2022-10-23 11:36:04
|
||||
* @LastEditTime : 2022-10-23 12:09:34
|
||||
* @Description :
|
||||
*/
|
||||
import 'package:flutter/gestures.dart';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-10-13 20:18:14
|
||||
* @LastEditTime : 2022-10-20 11:50:26
|
||||
* @LastEditTime : 2022-10-23 12:06:33
|
||||
* @Description : Repository to cache user info
|
||||
*/
|
||||
|
||||
@ -46,6 +46,36 @@ class UserRepository {
|
||||
_userInfoStreamController.add(response.userInfo!);
|
||||
localServiceRepository.storeUserInfo(userInfo: response.userInfo!);
|
||||
}
|
||||
else if(response.type == TCPResponseType.fetchContact && response.status == TCPResponseStatus.ok) {
|
||||
response as FetchContactResponse;
|
||||
for(var user in response.addedContacts) {
|
||||
users.update(
|
||||
user.userID,
|
||||
(value) => user,
|
||||
ifAbsent: () => user
|
||||
);
|
||||
localServiceRepository.storeUserInfo(userInfo: user);
|
||||
_userInfoStreamController.add(user);
|
||||
}
|
||||
for(var user in response.pendingContacts) {
|
||||
users.update(
|
||||
user.userID,
|
||||
(value) => user,
|
||||
ifAbsent: () => user
|
||||
);
|
||||
localServiceRepository.storeUserInfo(userInfo: user);
|
||||
_userInfoStreamController.add(user);
|
||||
}
|
||||
for(var user in response.requestingContacts) {
|
||||
users.update(
|
||||
user.userID,
|
||||
(value) => user,
|
||||
ifAbsent: () => user
|
||||
);
|
||||
localServiceRepository.storeUserInfo(userInfo: user);
|
||||
_userInfoStreamController.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Fetch user info
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user