Skip to content

Commit

Permalink
Dispose unused streams
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k committed Jan 9, 2025
1 parent 9d81f7f commit 33fcdf1
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 31 deletions.
36 changes: 18 additions & 18 deletions .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@

"@_ADD_ALBUM":{},
"add_album_screen_title": "Album",
"album_tame_field_title": "Album Name",
"album_name_field_title": "Album Name",
"store_in_title": "Store In",
"store_in_device_title": "Device",

Expand Down
4 changes: 2 additions & 2 deletions app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<true/>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>FlutterDeepLinkingEnabled</key>
<false/>
<key>FlutterDeepLinkingEnabled</key>
<false/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion app/lib/ui/flow/albums/add/add_album_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _AddAlbumScreenState extends ConsumerState<AddAlbumScreen> {
child: AppTextField(
controller: state.albumNameController,
onChanged: _notifier.validateAlbumName,
label: context.l10n.album_tame_field_title,
label: context.l10n.album_name_field_title,
),
),
if ((state.googleAccount != null || state.dropboxAccount != null) &&
Expand Down
10 changes: 8 additions & 2 deletions app/lib/ui/flow/albums/add/add_album_state_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@ final addAlbumStateNotifierProvider = StateNotifierProvider.autoDispose
ref.read(loggerProvider),
state,
);
ref.listen(
final googleDriveAccountSubscription = ref.listen(
googleUserAccountProvider,
(_, googleAccount) => notifier.onGoogleDriveAccountChange(googleAccount),
);
ref.listen(
final dropboxAccountSubscription = ref.listen(
AppPreferences.dropboxCurrentUserAccount,
(_, dropboxAccount) => notifier.onDropboxAccountChange(dropboxAccount),
);

ref.onDispose(() {
googleDriveAccountSubscription.close();
dropboxAccountSubscription.close();
});

return notifier;
});

Expand Down
2 changes: 1 addition & 1 deletion app/lib/ui/flow/albums/albums_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class _AlbumsScreenState extends ConsumerState<AlbumsScreen> {

@override
void initState() {
_notifier = ref.read(albumStateNotifierProvider.notifier);
super.initState();
_notifier = ref.read(albumStateNotifierProvider.notifier);
}

void _observeError(BuildContext context) {
Expand Down
11 changes: 9 additions & 2 deletions app/lib/ui/flow/albums/albums_view_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ final albumStateNotifierProvider =
ref.read(googleUserAccountProvider),
ref.read(AppPreferences.dropboxCurrentUserAccount),
);
ref.listen(googleUserAccountProvider, (p, c) {
final googleDriveAccountSubscription =
ref.listen(googleUserAccountProvider, (p, c) {
notifier.onGoogleDriveAccountChange(c);
});
ref.listen(AppPreferences.dropboxCurrentUserAccount, (p, c) {
final dropboxAccountSubscription =
ref.listen(AppPreferences.dropboxCurrentUserAccount, (p, c) {
notifier.onDropboxAccountChange(c);
});

ref.onDispose(() {
googleDriveAccountSubscription.close();
dropboxAccountSubscription.close();
});
return notifier;
});

Expand Down
2 changes: 1 addition & 1 deletion data/.flutter-plugins-dependencies

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion data/lib/apis/network/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ final dropboxAuthenticatedDioProvider = Provider((ref) {
rawDio: ref.read(rawDioProvider),
dropboxToken: ref.read(AppPreferences.dropboxToken),
);
ref.listen(AppPreferences.dropboxToken, (previous, next) {
final subscription =
ref.listen(AppPreferences.dropboxToken, (previous, next) {
dropboxInterceptor.updateToken(next);
});

ref.onDispose(() => subscription.close());

return Dio()
..options.connectTimeout = const Duration(seconds: 60)
..options.sendTimeout = const Duration(seconds: 60)
Expand Down
7 changes: 5 additions & 2 deletions data/lib/repositories/media_process_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ final mediaProcessRepoProvider = Provider<MediaProcessRepo>((ref) {
ref.read(notificationHandlerProvider),
ref.read(AppPreferences.notifications),
);
ref.onDispose(repo.dispose);
ref.listen(
final subscription = ref.listen(
AppPreferences.notifications,
(previous, next) {
repo.updateShowNotification(next);
},
);
ref.onDispose(() {
subscription.close();
repo.dispose();
});

return repo;
});
Expand Down

0 comments on commit 33fcdf1

Please sign in to comment.