perf(following): 追剧页不可见时不再提前拉观看历史

首页用 IndexedStack 常驻四个 tab,追剧页一启动就会发一次观看历史请求,和首页 feed 抢网络;
改为切到该 tab 时再加载,收藏列表也只在首次可见且为空时补拉。
This commit is contained in:
Vicky authored and trae-solo-agent committed 2026-10-29 11:25:47 +08:00
1 parent 63191b4692
commit 9f7301305e
2 files changed
+38 -4

No files matched your search

+23
View File
@@ -23,6 +23,29 @@ import '../support/fake_interaction_repositories.dart';
import '../support/widget_player.dart';
void main() {
testWidgets('should_defer_watch_history_until_following_tab_is_opened', (
tester,
) async {
SharedPreferencesAsyncPlatform.instance =
InMemorySharedPreferencesAsync.empty();
final catalog = FakeCatalogRepository();
final history = _IdentityWatchHistoryRepository(
device: [_historyProgress('the-signal-demo', 'Device history')],
account: const [],
);
await tester.pumpWidget(_app(catalog: catalog, history: history));
await tester.pumpAndSettle();
// 首页默认停在推荐 tab:追剧页虽在 IndexedStack 里,也不该提前拉观看历史。
// 启动时只有「我的」页会拉一次,追剧页若也拉就会变成 2。
expect(history.recentCalls, 1);
await tester.tap(find.byKey(const Key('tab-follow')));
await tester.pumpAndSettle();
expect(history.recentCalls, greaterThan(0));
});
testWidgets('should_render_following_tabs_grid_and_edit_actions', (
tester,
) async {