rwadurian/frontend/mobile-app/lib/features
hailin eda39b982d fix(mobile-app): 修复切换窗口期 NotificationBadge 混账号请求问题
问题(通过日志发现):
账号切换时存在一个 storage 空窗期(旧数据已清除、新数据尚未恢复完成)。
在此期间,NotificationBadgeNotifier 的 30s 定时器恰好触发,导致:
- _loadUnreadCount() 从 authProvider 内存读到旧账号 userSerialNum
- HTTP interceptor 从 storage 读到已恢复的新账号 accessToken
- 发出混账号请求:?userSerialNum=旧账号 + Authorization: Bearer 新账号token
日志证据:
  _restoreAccountData() 执行期间出现
  GET /notifications/unread-count?userSerialNum=D26022600000
  Authorization: Bearer [D26022600001的token]

修复:

1. notification_badge_provider.dart
   新增 stopAutoRefresh() 公开方法,取消 30s 定时器而不 dispose,
   Provider invalidate 重建后会自动重启定时器。

2. account_switch_page.dart - _switchToAccount
   在 onBeforeRestore 中补加:
     ref.read(notificationBadgeProvider.notifier).stopAutoRefresh()
   确保切换空窗期内 notificationBadge 定时器不触发。

   同时移除 UI 层冗余的 saveCurrentAccountData() 调用——
   switchToAccount() 内部已有此步骤,无需重复。

   日志步骤从 [1/6]...[6/6] 更新为 [1/5]...[5/5],
   并在 onBeforeRestore 注释中说明停止各定时器的原因。

切换空窗期现在所有定时器均已停止:
  ✓ walletStatusProvider (60s)
  ✓ pendingActionPollingService (4s)
  ✓ notificationBadgeProvider (30s)  ← 本次新增
  ✓ TelemetryUploader (30s)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 09:09:37 -08:00
..
account/presentation/pages fix(mobile-app): 修复切换窗口期 NotificationBadge 混账号请求问题 2026-02-25 09:09:37 -08:00
auth/presentation feat(app-assets): 应用图片管理 — 开屏图/引导图可从 admin-web 配置 2026-02-04 11:20:26 -08:00
authorization/presentation fix(mobile-app): 修复多账号切换数据串号问题,完善存储隔离与状态重置 2026-02-25 06:13:05 -08:00
contract_signing/presentation feat(mobile-app): 增强合同PDF下载可靠性和用户体验 2026-01-09 07:12:21 -08:00
deposit/presentation/pages fix(mobile-app): fetch wallet address from server API instead of local storage 2026-01-04 10:00:33 -08:00
home/presentation chore(mobile-app): 减少频繁轮询产生的调试日志 2025-12-28 06:54:16 -08:00
kyc feat(mobile-app): KYC成功后自动跳转合同签署页面 2025-12-25 07:07:43 -08:00
mining/presentation/pages feat(mobile-app): 为3个主导航页面添加下拉刷新功能 2026-02-05 21:50:43 -08:00
notification/presentation/pages feat(mobile-app,admin): 添加系统维护功能和通知徽章功能 2025-12-27 23:26:01 -08:00
pending_actions/presentation/pages fix(mobile-app): 修复认种订单解析和状态检查问题 2026-01-09 02:49:31 -08:00
planting/presentation fix(mobile-app): 修复多账号切换数据串号问题,完善存储隔离与状态重置 2026-02-25 06:13:05 -08:00
pre_planting/presentation/pages feat(pre-planting): Mobile App 预种合并详情页完整实现 2026-02-18 05:43:17 -08:00
profile/presentation chore(mobile-app): 补全多账号切换流程的关键日志,便于验证与排查 2026-02-25 09:04:14 -08:00
ranking/presentation/pages feat(mobile-app): 为3个主导航页面添加下拉刷新功能 2026-02-05 21:50:43 -08:00
security/presentation/pages feat(email): 实现邮箱绑定/解绑功能 2025-12-23 20:53:20 -08:00
share/presentation/pages feat(frontend): 多项功能改进 2025-12-15 04:04:21 -08:00
trading/presentation/pages feat(mobile-app): 为3个主导航页面添加下拉刷新功能 2026-02-05 21:50:43 -08:00
transfer/presentation/pages style(transfer): 树转让 3 页面从暗夜主题改为 App 标准浅色棕金主题 2026-02-23 20:25:25 -08:00
withdraw/presentation/pages feat(fiat-withdrawal): add complete fiat withdrawal system 2026-01-03 06:39:11 -08:00