TF-4384 Fix page not found 404 error when refreshing label views (#4390)

This commit is contained in:
Dat Vu
2026-03-21 17:23:18 +07:00
committed by GitHub
parent 8d82eac16f
commit 8a9901a0a4
13 changed files with 220 additions and 21 deletions
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/utils/app_logger.dart';
import 'package:dartz/dartz.dart' hide State;
import 'package:flutter/material.dart' hide State;
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/session/session.dart';
@@ -38,6 +39,8 @@ class LabelController extends BaseController with LabelContextMenuMixin {
final labels = <Label>[].obs;
final labelListExpandMode = Rx(ExpandMode.EXPAND);
final isLabelSettingEnabled = RxBool(false);
final isLabelsLoaded = RxBool(false);
final GlobalKey labelAppBarKey = GlobalKey();
GetAllLabelInteractor? _getAllLabelInteractor;
CreateNewLabelInteractor? _createNewLabelInteractor;
@@ -72,11 +75,17 @@ class LabelController extends BaseController with LabelContextMenuMixin {
isLabelSettingEnabled.value = false;
isLabelSettingEnabled.refresh();
_clearLabelData();
setLabelLoaded();
}
}
void setLabelLoaded() {
isLabelsLoaded.value = true;
}
void _clearLabelData() {
labels.clear();
isLabelsLoaded.value = false;
}
void injectLabelsBindings() {
@@ -114,7 +123,11 @@ class LabelController extends BaseController with LabelContextMenuMixin {
}
void getAllLabels(AccountId accountId) {
if (_getAllLabelInteractor == null) return;
if (_getAllLabelInteractor == null) {
labels.value = [];
setLabelLoaded();
return;
}
consumeState(_getAllLabelInteractor!.execute(accountId));
}
@@ -173,6 +186,9 @@ class LabelController extends BaseController with LabelContextMenuMixin {
if (isEnabled) {
injectLabelsBindings();
getAllLabels(accountId);
} else {
_clearLabelData();
setLabelLoaded();
}
}
@@ -181,6 +197,7 @@ class LabelController extends BaseController with LabelContextMenuMixin {
if (success is GetAllLabelSuccess) {
labels.value = success.labels..sortByAlphabetically();
setCurrentLabelState(success.newState);
setLabelLoaded();
} else if (success is CreateNewLabelSuccess) {
_handleCreateNewLabelSuccess(success);
} else if (success is GetLabelSettingStateSuccess) {
@@ -198,12 +215,14 @@ class LabelController extends BaseController with LabelContextMenuMixin {
void handleFailureViewState(Failure failure) {
if (failure is GetAllLabelFailure) {
labels.value = [];
setLabelLoaded();
} else if (failure is CreateNewLabelFailure) {
_handleCreateNewLabelFailure(failure);
} else if (failure is GetLabelSettingStateFailure) {
isLabelSettingEnabled.value = false;
isLabelSettingEnabled.refresh();
_clearLabelData();
setLabelLoaded();
} else if (failure is EditLabelFailure) {
handleEditLabelFailure(failure);
} else if (failure is DeleteALabelFailure) {