diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index 01a6fd71..ef7af8f0 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -294,7 +294,7 @@ class _DynamicDetailPageState extends State resizeToAvoidBottomInset: false, appBar: AppBar( title: StreamBuilder( - stream: _titleStreamC.stream, + stream: _titleStreamC.stream.distinct(), initialData: false, builder: (context, AsyncSnapshot snapshot) { return AnimatedOpacity( diff --git a/lib/pages/dynamics/tab/view.dart b/lib/pages/dynamics/tab/view.dart index e7d10965..ca5cf1f1 100644 --- a/lib/pages/dynamics/tab/view.dart +++ b/lib/pages/dynamics/tab/view.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/pages/common/common_page.dart'; +import 'package:PiliPlus/pages/main/controller.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -31,6 +32,7 @@ class _DynamicsTabPageState with AutomaticKeepAliveClientMixin { late bool dynamicsWaterfallFlow; StreamSubscription? _listener; + late final MainController _mainController = Get.find(); DynamicsController dynamicsController = Get.put(DynamicsController()); @override @@ -43,6 +45,14 @@ class _DynamicsTabPageState @override bool get wantKeepAlive => true; + @override + void listener() { + if (_mainController.selectedIndex.value == 0) { + return; + } + super.listener(); + } + @override void initState() { super.initState(); diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 7f9dc5a4..46ceea4b 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -156,8 +156,9 @@ class _HomePageState extends State stream: _homeController.hideSearchBar ? _mainController.navSearchStreamDebounce ? _homeController.searchBarStream?.stream + .distinct() .throttle(const Duration(milliseconds: 500)) - : _homeController.searchBarStream?.stream + : _homeController.searchBarStream?.stream.distinct() : null, initialData: true, builder: (BuildContext context, AsyncSnapshot snapshot) { diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index d5eab4da..8577e87c 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -270,8 +270,9 @@ class _MainAppState extends State stream: _mainController.hideTabBar ? _mainController.navSearchStreamDebounce ? _mainController.bottomBarStream?.stream + .distinct() .throttle(const Duration(milliseconds: 500)) - : _mainController.bottomBarStream?.stream + : _mainController.bottomBarStream?.stream.distinct() : null, initialData: true, builder: (context, AsyncSnapshot snapshot) { diff --git a/lib/pages/media/view.dart b/lib/pages/media/view.dart index 09ac7db0..45b90fdd 100644 --- a/lib/pages/media/view.dart +++ b/lib/pages/media/view.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/pages/common/common_page.dart'; +import 'package:PiliPlus/pages/main/controller.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:PiliPlus/common/widgets/network_img_layer.dart'; @@ -20,10 +21,19 @@ class _MediaPageState extends CommonPageState with AutomaticKeepAliveClientMixin { @override MediaController controller = Get.put(MediaController()); + late final MainController _mainController = Get.find(); @override bool get wantKeepAlive => true; + @override + void listener() { + if (_mainController.selectedIndex.value == 0) { + return; + } + super.listener(); + } + @override Widget build(BuildContext context) { super.build(context); diff --git a/lib/pages/member/view.dart b/lib/pages/member/view.dart index 2ab6711d..dea10b98 100644 --- a/lib/pages/member/view.dart +++ b/lib/pages/member/view.dart @@ -73,7 +73,7 @@ class _MemberPageState extends State { children: [ AppBar( title: StreamBuilder( - stream: appbarStream.stream, + stream: appbarStream.stream.distinct(), initialData: false, builder: (BuildContext context, AsyncSnapshot snapshot) { return AnimatedOpacity( diff --git a/lib/pages/subscription_detail/view.dart b/lib/pages/subscription_detail/view.dart index 186fd8b6..fc3cf341 100644 --- a/lib/pages/subscription_detail/view.dart +++ b/lib/pages/subscription_detail/view.dart @@ -71,7 +71,7 @@ class _SubDetailPageState extends State { expandedHeight: 215 - MediaQuery.of(context).padding.top, pinned: true, title: StreamBuilder( - stream: titleStreamC.stream, + stream: titleStreamC.stream.distinct(), initialData: false, builder: (context, AsyncSnapshot snapshot) { return AnimatedOpacity( diff --git a/lib/pages/video/detail/reply_new/view.dart b/lib/pages/video/detail/reply_new/view.dart index 05a134b3..9ed6928a 100644 --- a/lib/pages/video/detail/reply_new/view.dart +++ b/lib/pages/video/detail/reply_new/view.dart @@ -240,7 +240,7 @@ class _VideoReplyNewDialogState extends State const Spacer(), StreamBuilder( initialData: false, - stream: _publishStream.stream, + stream: _publishStream.stream.distinct(), builder: (context, snapshot) => FilledButton.tonal( onPressed: snapshot.data == true ? submitReplyAdd : null, style: FilledButton.styleFrom( diff --git a/lib/pages/webview/webview_page.dart b/lib/pages/webview/webview_page.dart index 81356bfc..e4f8f351 100644 --- a/lib/pages/webview/webview_page.dart +++ b/lib/pages/webview/webview_page.dart @@ -82,7 +82,7 @@ class _WebviewPageNewState extends State { : AppBar( title: StreamBuilder( initialData: null, - stream: _titleStream.stream, + stream: _titleStream.stream.distinct(), builder: (context, snapshot) => Text( maxLines: 1, snapshot.hasData ? snapshot.data! : _url, @@ -93,7 +93,7 @@ class _WebviewPageNewState extends State { preferredSize: Size.zero, child: StreamBuilder( initialData: 0.0, - stream: _progressStream.stream, + stream: _progressStream.stream.distinct(), builder: (context, snapshot) => snapshot.data as double < 1 ? LinearProgressIndicator( value: snapshot.data as double,