-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: separate reload timeline function
- Loading branch information
1 parent
f83897a
commit 6b9f8c1
Showing
3 changed files
with
29 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
|
||
import '../model/tab_settings.dart'; | ||
import '../provider/api/timeline_notes_after_note_notifier_provider.dart'; | ||
import '../provider/api/timeline_notes_notifier_provider.dart'; | ||
import '../provider/streaming/timeline_stream_notifier.dart'; | ||
import '../provider/streaming/web_socket_channel_provider.dart'; | ||
import '../provider/timeline_center_notifier_provider.dart'; | ||
import '../provider/timeline_last_viewed_note_id_notifier_provider.dart'; | ||
|
||
Future<void> reloadTimeline(WidgetRef ref, TabSettings tabSettings) async { | ||
if (!tabSettings.disableStreaming) { | ||
ref.invalidate(webSocketChannelProvider(tabSettings.account)); | ||
} | ||
ref.read(timelineCenterNotifierProvider(tabSettings).notifier).reset(); | ||
await Future.wait([ | ||
ref.refresh(timelineNotesAfterNoteNotifierProvider(tabSettings).future), | ||
ref.refresh(timelineNotesNotifierProvider(tabSettings).future), | ||
ref | ||
.read(timelineLastViewedNoteIdNotifierProvider(tabSettings).notifier) | ||
.saveFromDate(DateTime.now()), | ||
if (!tabSettings.disableStreaming) | ||
ref.read(timelineStreamNotifierProvider(tabSettings).notifier).connect(), | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters