-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: last track of queue keeps repeating #718
- Loading branch information
Showing
5 changed files
with
44 additions
and
38 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:device_info_plus/device_info_plus.dart'; | ||
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:permission_handler/permission_handler.dart'; | ||
import 'package:spotube/components/library/user_local_tracks.dart'; | ||
import 'package:spotube/hooks/use_async_effect.dart'; | ||
|
||
void useGetStoragePermissions(WidgetRef ref) { | ||
final isMounted = useIsMounted(); | ||
|
||
useAsyncEffect( | ||
() async { | ||
if (!DesktopTools.platform.isMobile) return; | ||
|
||
final androidInfo = await DeviceInfoPlugin().androidInfo; | ||
|
||
final hasNoStoragePerm = androidInfo.version.sdkInt < 33 && | ||
!await Permission.storage.isGranted && | ||
!await Permission.storage.isLimited; | ||
|
||
final hasNoAudioPerm = androidInfo.version.sdkInt >= 33 && | ||
!await Permission.audio.isGranted && | ||
!await Permission.audio.isLimited; | ||
|
||
if (hasNoStoragePerm) { | ||
await Permission.storage.request(); | ||
if (isMounted()) ref.refresh(localTracksProvider); | ||
} | ||
if (hasNoAudioPerm) { | ||
await Permission.audio.request(); | ||
if (isMounted()) ref.refresh(localTracksProvider); | ||
} | ||
}, | ||
null, | ||
[], | ||
); | ||
} |
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