fix:修复添加锁之后不出现在列表的问题

This commit is contained in:
liyi 2025-05-12 09:59:48 +08:00
parent 9ac54cc971
commit cf2fd775ec
4 changed files with 37 additions and 15 deletions

View File

@ -189,6 +189,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
Get.offAllNamed(Routers.starLockMain); Get.offAllNamed(Routers.starLockMain);
} }
eventBus.fire(SuccessfulDistributionNetwork()); eventBus.fire(SuccessfulDistributionNetwork());
eventBus.fire(RefreshLockListInfoDataEvent());
}); });
// //

View File

@ -61,7 +61,7 @@ class LockListLogic extends BaseGetXController {
void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) { void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) {
this.entity = entity; this.entity = entity;
// if (entity.pageNo == 1) { // if (entity.pageNo == 1) {
_groupDataList = <GroupList>[]; _groupDataList = <GroupList>[];
// } // }
_groupDataList.addAll(entity.groupList!); _groupDataList.addAll(entity.groupList!);
update(); update();
@ -69,6 +69,7 @@ class LockListLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
late StreamSubscription _setLockListInfoGroupEntity;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = _replySubscription =
@ -336,6 +337,7 @@ class LockListLogic extends BaseGetXController {
void onReady() { void onReady() {
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
_initEventHandler();
} }
@override @override
@ -348,5 +350,14 @@ class LockListLogic extends BaseGetXController {
@override @override
void onClose() { void onClose() {
_replySubscription.cancel(); _replySubscription.cancel();
_setLockListInfoGroupEntity.cancel();
}
void _initEventHandler() {
_setLockListInfoGroupEntity = eventBus
.on<SetLockListInfoGroupEntity>()
.listen((SetLockListInfoGroupEntity event) async {
setLockListInfoGroupEntity(event.lockListInfoGroupEntity);
});
} }
} }

View File

@ -132,20 +132,21 @@ class LockMainLogic extends BaseGetXController {
state.lockListInfoGroupEntity.refresh(); state.lockListInfoGroupEntity.refresh();
// AppLog.log('entity:$entity state.lockListInfoGroupEntity.value.groupList!.length:${state.lockListInfoGroupEntity.value.groupList![0].lockList!.length}'); // AppLog.log('entity:$entity state.lockListInfoGroupEntity.value.groupList!.length:${state.lockListInfoGroupEntity.value.groupList![0].lockList!.length}');
// //
if (Get.isRegistered<LockListLogic>()) { eventBus.fire(SetLockListInfoGroupEntity(lockListInfoGroupEntity: entity));
// // if (Get.isRegistered<LockListLogic>()) {
// AppLog.log('检测控制器是否存 调用了 setLockListInfoGroupEntity'); // //
Get.find<LockListLogic>().setLockListInfoGroupEntity(entity); // // AppLog.log('检测控制器是否存 调用了 setLockListInfoGroupEntity');
} else { // Get.find<LockListLogic>().setLockListInfoGroupEntity(entity);
// // } else {
Future<dynamic>.delayed(200.milliseconds, () { // //
if (Get.isRegistered<LockListLogic>()) { // Future<dynamic>.delayed(500.milliseconds, () {
// // if (Get.isRegistered<LockListLogic>()) {
// AppLog.log('检测控制器是否存 延迟调用了 setLockListInfoGroupEntity'); // //
Get.find<LockListLogic>().setLockListInfoGroupEntity(entity); // // AppLog.log('检测控制器是否存 延迟调用了 setLockListInfoGroupEntity');
} // Get.find<LockListLogic>().setLockListInfoGroupEntity(entity);
}); // }
} // });
// }
if (state.dataLength.value == 1) { if (state.dataLength.value == 1) {
if (Get.isRegistered<LockDetailLogic>()) { if (Get.isRegistered<LockDetailLogic>()) {

View File

@ -1,4 +1,5 @@
import 'package:event_bus/event_bus.dart'; import 'package:event_bus/event_bus.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
@ -195,6 +196,7 @@ class RogerThatLockInfoDataEvent {
class GetGatewayListRefreshUI { class GetGatewayListRefreshUI {
GetGatewayListRefreshUI(); GetGatewayListRefreshUI();
} }
/// ///
class AgreePrivacyAgreement { class AgreePrivacyAgreement {
AgreePrivacyAgreement(); AgreePrivacyAgreement();
@ -204,3 +206,10 @@ class AgreePrivacyAgreement {
class SuccessfulDistributionNetwork { class SuccessfulDistributionNetwork {
SuccessfulDistributionNetwork(); SuccessfulDistributionNetwork();
} }
///
class SetLockListInfoGroupEntity {
SetLockListInfoGroupEntity({required this.lockListInfoGroupEntity});
LockListInfoGroupEntity lockListInfoGroupEntity;
}