Merge branch 'rewrite_device_sync' into rewrite_device_sync_remote

This commit is contained in:
Neeraj Gupta 2022-09-07 16:38:40 +05:30
commit 463a886820
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 6 additions and 42 deletions

View file

@ -7,14 +7,9 @@ import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:fluttercontactpicker/fluttercontactpicker.dart'; import 'package:fluttercontactpicker/fluttercontactpicker.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart'; import 'package:photos/core/configuration.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/db/device_files_db.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/db/public_keys_db.dart'; import 'package:photos/db/public_keys_db.dart';
import 'package:photos/ente_theme_data.dart'; import 'package:photos/ente_theme_data.dart';
import 'package:photos/events/backup_folders_updated_event.dart';
import 'package:photos/models/collection.dart'; import 'package:photos/models/collection.dart';
import 'package:photos/models/device_collection.dart';
import 'package:photos/models/public_key.dart'; import 'package:photos/models/public_key.dart';
import 'package:photos/services/collections_service.dart'; import 'package:photos/services/collections_service.dart';
import 'package:photos/services/feature_flag_service.dart'; import 'package:photos/services/feature_flag_service.dart';
@ -32,10 +27,8 @@ import 'package:photos/utils/toast_util.dart';
class SharingDialog extends StatefulWidget { class SharingDialog extends StatefulWidget {
final Collection collection; final Collection collection;
final DeviceCollection deviceCollection;
const SharingDialog(this.collection, {Key key, this.deviceCollection}) const SharingDialog(this.collection, {Key key}) : super(key: key);
: super(key: key);
@override @override
State<SharingDialog> createState() => _SharingDialogState(); State<SharingDialog> createState() => _SharingDialogState();
@ -123,18 +116,6 @@ class _SharingDialogState extends State<SharingDialog> {
if (choice != DialogUserChoice.firstChoice) { if (choice != DialogUserChoice.firstChoice) {
return; return;
} }
} else {
// Add local folder in backup patch before creating
// sharable link
if (widget.collection.type == CollectionType.folder) {
if (widget.deviceCollection != null &&
!widget.deviceCollection.shouldBackup) {
await FilesDB.instance.updateDevicePathSyncStatus(
{widget.deviceCollection.id: true},
);
Bus.instance.fire(BackupFoldersUpdatedEvent());
}
}
} }
final dialog = createProgressDialog( final dialog = createProgressDialog(
context, context,
@ -410,17 +391,7 @@ class _SharingDialogState extends State<SharingDialog> {
} else { } else {
final dialog = createProgressDialog(context, "Sharing..."); final dialog = createProgressDialog(context, "Sharing...");
await dialog.show(); await dialog.show();
final collection = widget.collection;
try { try {
if (collection.type == CollectionType.folder) {
if (widget.deviceCollection != null &&
!widget.deviceCollection.shouldBackup) {
await FilesDB.instance.updateDevicePathSyncStatus(
{widget.deviceCollection.id: true},
);
Bus.instance.fire(BackupFoldersUpdatedEvent());
}
}
await CollectionsService.instance await CollectionsService.instance
.share(widget.collection.id, email, publicKey); .share(widget.collection.id, email, publicKey);
await dialog.hide(); await dialog.hide();

View file

@ -126,8 +126,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
final List<Widget> actions = <Widget>[]; final List<Widget> actions = <Widget>[];
if (Configuration.instance.hasConfiguredAccount() && if (Configuration.instance.hasConfiguredAccount() &&
widget.selectedFiles.files.isEmpty && widget.selectedFiles.files.isEmpty &&
(widget.type == GalleryType.localFolder || widget.type == GalleryType.ownedCollection) {
widget.type == GalleryType.ownedCollection)) {
actions.add( actions.add(
Tooltip( Tooltip(
message: "Share", message: "Share",
@ -219,15 +218,10 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
final dialog = createProgressDialog(context, "Please wait..."); final dialog = createProgressDialog(context, "Please wait...");
await dialog.show(); await dialog.show();
try { try {
if (collection == null) { if (collection == null || widget.type != GalleryType.ownedCollection) {
if (widget.type == GalleryType.localFolder) { throw Exception(
collection = await CollectionsService.instance "Cannot share empty collection of type ${widget.type}",
.getOrCreateForPath(widget.deviceCollection.name); );
} else {
throw Exception(
"Cannot create a collection of type" + widget.type.toString(),
);
}
} else { } else {
final sharees = final sharees =
await CollectionsService.instance.getSharees(collection.id); await CollectionsService.instance.getSharees(collection.id);
@ -239,7 +233,6 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
builder: (BuildContext context) { builder: (BuildContext context) {
return SharingDialog( return SharingDialog(
collection, collection,
deviceCollection: widget.deviceCollection,
); );
}, },
); );