fix: only update init if called from correct function

This commit is contained in:
Prateek Sunal
2025-03-04 13:02:16 +05:30
parent 5a2be86524
commit 33cd46583e

View File

@@ -46,7 +46,7 @@ class PreviewVideoStore {
LinkedHashMap<int, PreviewItem> get previews => _items;
late Set<int> _failureFiles;
bool initSuccess = false;
bool _initSuccess = false;
PreviewVideoStore._privateConstructor();
@@ -672,12 +672,12 @@ class PreviewVideoStore {
}
// generate stream for all files after cutoff date
Future<void> _putFilesForPreviewCreation() async {
Future<void> _putFilesForPreviewCreation([bool updateInit = false]) async {
if (!isVideoStreamingEnabled || !await canUseHighBandwidth()) return;
final cutoff = videoStreamingCutoff;
if (cutoff == null) return;
initSuccess = true;
if (updateInit) _initSuccess = true;
Map<int, String> failureFiles = {};
try {
@@ -757,9 +757,9 @@ class PreviewVideoStore {
}
void queueFiles() {
if (!initSuccess) {
_putFilesForPreviewCreation().catchError((_) {
initSuccess = false;
if (!_initSuccess) {
_putFilesForPreviewCreation(true).catchError((_) {
_initSuccess = false;
});
}
}