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

Commit

Permalink
Merge branch 'main' into independent
Browse files Browse the repository at this point in the history
  • Loading branch information
ua741 committed Nov 28, 2023
2 parents a81942b + b1716b0 commit 08047d1
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 146 deletions.
6 changes: 6 additions & 0 deletions lib/generated/intl/messages_zh.dart

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

6 changes: 5 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1152,5 +1152,9 @@
},
"contacts": "联系人",
"noInternetConnection": "无互联网连接",
"pleaseCheckYourInternetConnectionAndTryAgain": "请检查您的互联网连接,然后重试。"
"pleaseCheckYourInternetConnectionAndTryAgain": "请检查您的互联网连接,然后重试。",
"signOutFromOtherDevices": "从其他设备退出登录",
"signOutOtherBody": "如果你认为有人可能知道你的密码,你可以强制所有使用你账户的其他设备退出登录。",
"signOutOtherDevices": "登出其他设备",
"doNotSignOut": "不要退登"
}
15 changes: 13 additions & 2 deletions lib/services/local_file_update_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,29 @@ class LocalFileUpdateService {
Future<void> _checkAndMarkFilesWithDifferentHashForFileUpdate(
List<String> localIDsToProcess,
) async {
_logger.info("files to process ${localIDsToProcess.length} for reupload");
final int userID = Configuration.instance.getUserID()!;
final List<EnteFile> result =
await FilesDB.instance.getLocalFiles(localIDsToProcess);
final List<EnteFile> localFilesForUser = [];
final Set<String> localIDsWithFile = {};
for (EnteFile file in result) {
if (file.ownerID == null || file.ownerID == userID) {
localFilesForUser.add(file);
localIDsWithFile.add(file.localID!);
}
}

final Set<String> processedIDs = {};
// if a file for localID doesn't exist, then mark it as processed
// otherwise the app will be stuck in retrying same set of ids
for (String localID in localIDsToProcess) {
if (!localIDsWithFile.contains(localID)) {
processedIDs.add(localID);
}
}
_logger.info("files to process ${localIDsToProcess.length} for reupload, "
"missing localFile cnt ${processedIDs.length}");

for (EnteFile file in localFilesForUser) {
if (processedIDs.contains(file.localID)) {
continue;
Expand Down Expand Up @@ -156,7 +168,6 @@ class LocalFileUpdateService {
} on InvalidFileError catch (e) {
if (e.reason == InvalidReason.livePhotoToImageTypeChanged ||
e.reason == InvalidReason.imageToLivePhotoTypeChanged) {

late FileType fileType;
if (e.reason == InvalidReason.livePhotoToImageTypeChanged) {
fileType = FileType.image;
Expand Down
39 changes: 35 additions & 4 deletions lib/states/all_sections_examples_state.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import "dart:async";

import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
import "package:logging/logging.dart";
import "package:photos/core/constants.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/files_updated_event.dart";
import "package:photos/events/tab_changed_event.dart";
import "package:photos/models/search/search_result.dart";
import "package:photos/models/search/search_types.dart";
import "package:photos/utils/debouncer.dart";
Expand All @@ -29,24 +31,52 @@ class _AllSectionsExamplesProviderState
Future<List<List<SearchResult>>> allSectionsExamplesFuture = Future.value([]);

late StreamSubscription<FilesUpdatedEvent> _filesUpdatedEvent;
late StreamSubscription<TabChangedEvent> _tabChangeEvent;
bool hasPendingUpdate = false;
bool isOnSearchTab = false;
final _logger = Logger("AllSectionsExamplesProvider");

final _debouncer =
Debouncer(const Duration(seconds: 3), executionInterval: 6000);
final _debouncer = Debouncer(
const Duration(seconds: 4),
executionIntervalInMilliSeconds: 15000,
);

@override
void initState() {
super.initState();
//add all common events for all search sections to reload to here.
_filesUpdatedEvent = Bus.instance.on<FilesUpdatedEvent>().listen((event) {
reloadAllSections();
if (!isOnSearchTab) {
if (kDebugMode) {
_logger.finest('Skip reload till user clicks on search tab');
}
hasPendingUpdate = true;
return;
} else {
hasPendingUpdate = false;
reloadAllSections();
}
});
_tabChangeEvent = Bus.instance.on<TabChangedEvent>().listen((event) {
if (event.source == TabChangedEventSource.pageView &&
event.selectedIndex == 3) {
isOnSearchTab = true;
if (hasPendingUpdate) {
hasPendingUpdate = false;
reloadAllSections();
}
} else {
isOnSearchTab = false;
}
});
reloadAllSections();
}

void reloadAllSections() {
_logger.info('queue reload all sections');
_debouncer.run(() async {
setState(() {
_logger.info("reloading all sections in search tab");
_logger.info("'_debounceTimer: reloading all sections in search tab");
final allSectionsExamples = <Future<List<SearchResult>>>[];
for (SectionType sectionType in SectionType.values) {
if (sectionType == SectionType.face ||
Expand All @@ -66,6 +96,7 @@ class _AllSectionsExamplesProviderState
@override
void dispose() {
_filesUpdatedEvent.cancel();
_tabChangeEvent.cancel();
_debouncer.cancelDebounce();
super.dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/map/map_gallery_tile_badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MapGalleryTileBadge extends StatelessWidget {
if (number <= 99) {
return number.toString();
} else if (number <= 999) {
return '${(number / 100).toStringAsFixed(0)}00+';
return '${(number / 100).floor().toStringAsFixed(0)}00+';
} else if (number >= 1000 && number < 2000) {
return '1K+';
} else {
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/map/map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ class MapView extends StatefulWidget {

class _MapViewState extends State<MapView> {
late List<Marker> _markers;
final _debouncer =
Debouncer(const Duration(milliseconds: 300), executionInterval: 750);
final _debouncer = Debouncer(
const Duration(milliseconds: 300),
executionIntervalInMilliSeconds: 750,
);

@override
void initState() {
Expand Down
79 changes: 10 additions & 69 deletions lib/ui/notification/update/change_log_page.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import 'package:flutter/material.dart';
import "package:flutter_animate/flutter_animate.dart";
import "package:photos/generated/l10n.dart";
import 'package:photos/services/update_service.dart';
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
import 'package:photos/ui/components/divider_widget.dart';
import 'package:photos/ui/components/models/button_type.dart';
import "package:photos/ui/components/notification_widget.dart";
import 'package:photos/ui/components/title_bar_title_widget.dart';
import 'package:photos/ui/notification/update/change_log_entry.dart';
import "package:photos/utils/black_friday_util.dart";
import "package:url_launcher/url_launcher_string.dart";

class ChangeLogPage extends StatefulWidget {
const ChangeLogPage({
Expand Down Expand Up @@ -67,36 +63,6 @@ class _ChangeLogPageState extends State<ChangeLogPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
shouldShowBfBanner()
? RepaintBoundary(
child: Padding(
padding: const EdgeInsets.only(bottom: 8),
child: NotificationWidget(
isBlackFriday: true,
startIcon: Icons.celebration,
actionIcon: Icons.arrow_forward_outlined,
text: S.of(context).blackFridaySale,
subText: S.of(context).upto50OffUntil4thDec,
type: NotificationType.goldenBanner,
onTap: () async {
launchUrlString(
"https://ente.io/blackfriday",
mode: LaunchMode.platformDefault,
);
},
),
)
.animate(
onPlay: (controller) => controller.repeat(),
)
.shimmer(
duration: 1000.ms,
delay: 3200.ms,
size: 0.6,
),
)
: const SizedBox.shrink(),

ButtonWidget(
buttonType: ButtonType.trailingIconPrimary,
buttonSize: ButtonSize.large,
Expand All @@ -112,33 +78,16 @@ class _ChangeLogPageState extends State<ChangeLogPage> {
const SizedBox(
height: 8,
),
// ButtonWidget(
// buttonType: ButtonType.trailingIconSecondary,
// buttonSize: ButtonSize.large,
// labelText: S.of(context).rateTheApp,
// icon: Icons.favorite_rounded,
// iconColor: enteColorScheme.primary500,
// onTap: () async {
// await UpdateService.instance.launchReviewUrl();
// },
// ),

shouldShowBfBanner()
? const SizedBox.shrink()
: ButtonWidget(
buttonType: ButtonType.trailingIconSecondary,
buttonSize: ButtonSize.large,
labelText: "Join the ente community",
icon: Icons.people_alt_rounded,
iconColor: enteColorScheme.primary500,
onTap: () async {
launchUrlString(
"https://ente.io/community",
mode: LaunchMode.externalApplication,
);
},
),

ButtonWidget(
buttonType: ButtonType.trailingIconSecondary,
buttonSize: ButtonSize.large,
labelText: S.of(context).rateTheApp,
icon: Icons.favorite_rounded,
iconColor: enteColorScheme.primary500,
onTap: () async {
await UpdateService.instance.launchReviewUrl();
},
),
const SizedBox(height: 8),
],
),
Expand All @@ -160,14 +109,6 @@ class _ChangeLogPageState extends State<ChangeLogPage> {
'\nYou can now discover items that come under different Locations, Moments, Contacts, Photo descriptions, Albums and File types with ease.\n',
),
);
items.add(
ChangeLogEntry(
"Black Friday Sale 🎉",
"You can now purchase Ente's plans for 3 years at 30% off and 5 years at 50% off!\n"
'\nThe storage you purchase will be stacked on top of your current plan.\n'
'\nThis is the lowest our prices will ever be, so do consider upgrading!\n',
),
);

return Container(
padding: const EdgeInsets.only(left: 16),
Expand Down
43 changes: 12 additions & 31 deletions lib/ui/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import 'package:photos/ui/settings/storage_card_widget.dart';
import 'package:photos/ui/settings/support_section_widget.dart';
import 'package:photos/ui/settings/theme_switch_widget.dart';
import "package:photos/ui/sharing/verify_identity_dialog.dart";
import "package:photos/utils/black_friday_util.dart";
import "package:photos/utils/navigation_util.dart";
import "package:url_launcher/url_launcher_string.dart";

class SettingsPage extends StatelessWidget {
final ValueNotifier<String?> emailNotifier;
Expand Down Expand Up @@ -86,42 +84,25 @@ class SettingsPage extends StatelessWidget {
const sectionSpacing = SizedBox(height: 8);
contents.add(const SizedBox(height: 8));
if (hasLoggedIn) {
final shouldShowBFBanner = shouldShowBfBanner();
final showStorageBonusBanner =
StorageBonusService.instance.shouldShowStorageBonus();
contents.addAll([
const StorageCardWidget(),
(shouldShowBFBanner || showStorageBonusBanner)
(showStorageBonusBanner)
? RepaintBoundary(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: shouldShowBFBanner
? NotificationWidget(
isBlackFriday: true,
startIcon: Icons.celebration,
actionIcon: Icons.arrow_forward_outlined,
text: S.of(context).blackFridaySale,
subText: S.of(context).upto50OffUntil4thDec,
type: NotificationType.goldenBanner,
onTap: () async {
launchUrlString(
"https://ente.io/blackfriday",
mode: LaunchMode.platformDefault,
);
},
)
: NotificationWidget(
startIcon: Icons.auto_awesome,
actionIcon: Icons.arrow_forward_outlined,
text: S.of(context).doubleYourStorage,
subText: S.of(context).referFriendsAnd2xYourPlan,
type: NotificationType.goldenBanner,
onTap: () async {
StorageBonusService.instance
.markStorageBonusAsDone();
routeToPage(context, const ReferralScreen());
},
),
child: NotificationWidget(
startIcon: Icons.auto_awesome,
actionIcon: Icons.arrow_forward_outlined,
text: S.of(context).doubleYourStorage,
subText: S.of(context).referFriendsAnd2xYourPlan,
type: NotificationType.goldenBanner,
onTap: () async {
StorageBonusService.instance.markStorageBonusAsDone();
routeToPage(context, const ReferralScreen());
},
),
).animate(onPlay: (controller) => controller.repeat()).shimmer(
duration: 1000.ms,
delay: 3200.ms,
Expand Down
21 changes: 0 additions & 21 deletions lib/utils/black_friday_util.dart

This file was deleted.

Loading

0 comments on commit 08047d1

Please sign in to comment.