feat(Label): Use capability-aware label availability in websocket injection.

This commit is contained in:
dab246
2026-03-03 15:23:57 +07:00
committed by Dat H. Pham
parent 2e6e1fcdc8
commit b2338a1160
7 changed files with 33 additions and 25 deletions
@@ -236,7 +236,7 @@ class LabelApi
log('LabelAPI::getChanges: '
'newStateChanges=${changes.newState} | '
'newStateLabel=$newStateLabel | '
'hasMore=${changes.hasMoreChanges}'
'hasMore=${changes.hasMoreChanges} | '
'updatedFetched=${updatedResult.labels?.length} | '
'createdFetched=${createdResult.labels?.length} | '
'totalDestroyed=${allDestroyedIds.length}');
@@ -10,12 +10,17 @@ import 'package:tmail_ui_user/features/push_notification/presentation/websocket/
extension HandleLabelWebsocketExtension on LabelController {
void refreshLabelChanges({required jmap.State newState}) {
if (accountId == null ||
session == null ||
currentLabelState == null ||
currentLabelState == newState ||
isLabelSettingEnabled.isFalse) {
logWarning('HandleLabelWebsocketExtension::refreshLabelChanges: accountId or session or currentLabelState or newState or isLabelSettingEnabled is null');
final skipReasons = <String>[
if (accountId == null) 'accountId is null',
if (session == null) 'session is null',
if (currentLabelState == null) 'currentLabelState is null',
if (currentLabelState == newState) 'state unchanged',
if (isLabelSettingEnabled.isFalse) 'label setting disabled',
];
if (skipReasons.isNotEmpty) {
logWarning(
'HandleLabelWebsocketExtension::refreshLabelChanges: skip (${skipReasons.join(', ')})',
);
return;
}