Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Minor fixes (#1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
ua741 authored Feb 20, 2024
2 parents a37cbba + 54750cc commit ceb4a00
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PODS:
- background_fetch (1.2.1):
- Flutter
- battery_info (0.0.1):
- Flutter
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
Expand Down Expand Up @@ -213,6 +215,7 @@ PODS:

DEPENDENCIES:
- background_fetch (from `.symlinks/plugins/background_fetch/ios`)
- battery_info (from `.symlinks/plugins/battery_info/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- file_saver (from `.symlinks/plugins/file_saver/ios`)
Expand Down Expand Up @@ -286,6 +289,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
background_fetch:
:path: ".symlinks/plugins/background_fetch/ios"
battery_info:
:path: ".symlinks/plugins/battery_info/ios"
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
device_info_plus:
Expand Down Expand Up @@ -377,6 +382,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
background_fetch: 896944864b038d2837fc750d470e9841e1e6a363
battery_info: 09f5c9ee65394f2291c8c6227bedff345b8a730c
connectivity_plus: 53efb943fc2882c8512d84c45707bcabc4c36076
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
file_saver: 503e386464dbe118f630e17b4c2e1190fa0cf808
Expand Down
2 changes: 2 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"${BUILT_PRODUCTS_DIR}/SentryPrivate/SentryPrivate.framework",
"${BUILT_PRODUCTS_DIR}/Toast/Toast.framework",
"${BUILT_PRODUCTS_DIR}/background_fetch/background_fetch.framework",
"${BUILT_PRODUCTS_DIR}/battery_info/battery_info.framework",
"${BUILT_PRODUCTS_DIR}/connectivity_plus/connectivity_plus.framework",
"${BUILT_PRODUCTS_DIR}/device_info_plus/device_info_plus.framework",
"${BUILT_PRODUCTS_DIR}/file_saver/file_saver.framework",
Expand Down Expand Up @@ -357,6 +358,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SentryPrivate.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Toast.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/background_fetch.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/battery_info.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/connectivity_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_saver.framework",
Expand Down
12 changes: 1 addition & 11 deletions lib/ui/payment/subscription.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/services/feature_flag_service.dart';
import 'package:photos/services/update_service.dart';
import "package:photos/ui/payment/store_subscription_page.dart";
Expand All @@ -9,18 +8,9 @@ StatefulWidget getSubscriptionPage({bool isOnBoarding = false}) {
if (UpdateService.instance.isIndependentFlavor()) {
return StripeSubscriptionPage(isOnboarding: isOnBoarding);
}
if (FeatureFlagService.instance.enableStripe() &&
_isUserCreatedPostStripeSupport()) {
if (FeatureFlagService.instance.enableStripe()) {
return StripeSubscriptionPage(isOnboarding: isOnBoarding);
} else {
return StoreSubscriptionPage(isOnboarding: isOnBoarding);
}
}

// return true if the user was created after we added support for stripe payment
// on frame. We do this check to avoid showing Stripe payment option for earlier
// users who might have paid via playStore. This method should be removed once
// we have better handling for active play/app store subscription & stripe plans.
bool _isUserCreatedPostStripeSupport() {
return Configuration.instance.getUserID()! > 1580559962386460;
}
12 changes: 8 additions & 4 deletions lib/ui/viewer/file/video_widget_new.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,14 @@ class _VideoWidgetNewState extends State<VideoWidgetNew>

void _setVideoController(String url) {
if (mounted) {
setState(() {
player.setPlaylistMode(PlaylistMode.single);
controller = VideoController(player);
player.open(Media(url), play: _isAppInFG);
setState(() async {
try {
await player.setPlaylistMode(PlaylistMode.single);
controller = VideoController(player);
await player.open(Media(url), play: _isAppInFG);
} catch (e, s) {
_logger.severe("failed to set video url", e, s);
}
});
}
}
Expand Down
36 changes: 31 additions & 5 deletions lib/utils/file_uploader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart';
import "package:photos/core/constants.dart";
import 'package:photos/core/errors.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/core/network/network.dart';
Expand All @@ -34,6 +35,7 @@ import "package:photos/services/user_service.dart";
import 'package:photos/utils/crypto_util.dart';
import 'package:photos/utils/file_download_util.dart';
import 'package:photos/utils/file_uploader_util.dart';
import "package:photos/utils/file_util.dart";
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tuple/tuple.dart';
import "package:uuid/uuid.dart";
Expand Down Expand Up @@ -307,12 +309,36 @@ class FileUploader {
return file.path.contains(kUploadTempPrefix) &&
file.path.contains(".encrypted");
});
if (filesToDelete.isEmpty) {
return;
if (filesToDelete.isNotEmpty) {
_logger.info('cleaning up state files ${filesToDelete.length}');
for (final file in filesToDelete) {
await file.delete();
}
}
_logger.info('cleaning up state files ${filesToDelete.length}');
for (final file in filesToDelete) {
await file.delete();

if (Platform.isAndroid) {
final sharedMediaDir =
Configuration.instance.getSharedMediaDirectory() + "/";
final sharedFiles = await Directory(sharedMediaDir).list().toList();
if (sharedFiles.isNotEmpty) {
_logger.info('Shared media directory cleanup ${sharedFiles.length}');
final int ownerID = Configuration.instance.getUserID()!;
final existingLocalFileIDs =
await FilesDB.instance.getExistingLocalFileIDs(ownerID);
final Set<String> trackedSharedFilePaths = {};
for (String localID in existingLocalFileIDs) {
if (localID.contains(sharedMediaIdentifier)) {
trackedSharedFilePaths
.add(getSharedMediaPathFromLocalID(localID));
}
}
for (final file in sharedFiles) {
if (!trackedSharedFilePaths.contains(file.path)) {
_logger.info('Deleting stale shared media file ${file.path}');
await file.delete();
}
}
}
}
} catch (e, s) {
_logger.severe("Failed to remove stale files", e, s);
Expand Down

0 comments on commit ceb4a00

Please sign in to comment.