mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 10:58:50 +01:00
Compare username ignoring case
This commit is contained in:
parent
99b0286b81
commit
2ad844292a
7 changed files with 31 additions and 14 deletions
|
@ -465,7 +465,7 @@ extension FileExtension on File {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isOwned(String username) =>
|
bool isOwned(String username) =>
|
||||||
ownerId == null || ownerId?.toLowerCase() == username.toLowerCase();
|
ownerId == null || ownerId!.equalsIgnoreCase(username.toLowerCase());
|
||||||
|
|
||||||
/// Return the path of this file with the DAV part stripped
|
/// Return the path of this file with the DAV part stripped
|
||||||
///
|
///
|
||||||
|
|
|
@ -23,4 +23,6 @@ extension StringExtension on String {
|
||||||
String trimAny(String characters) {
|
String trimAny(String characters) {
|
||||||
return trimLeftAny(characters).trimRightAny(characters);
|
return trimLeftAny(characters).trimRightAny(characters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool equalsIgnoreCase(String other) => toLowerCase() == other.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:nc_photos/account.dart';
|
||||||
import 'package:nc_photos/app_db.dart';
|
import 'package:nc_photos/app_db.dart';
|
||||||
import 'package:nc_photos/entity/file.dart';
|
import 'package:nc_photos/entity/file.dart';
|
||||||
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||||
|
import 'package:nc_photos/string_extension.dart';
|
||||||
|
|
||||||
class FindFile {
|
class FindFile {
|
||||||
/// Find the [File] in the DB by [fileId]
|
/// Find the [File] in the DB by [fileId]
|
||||||
|
@ -18,7 +19,9 @@ class FindFile {
|
||||||
// find the one owned by us
|
// find the one owned by us
|
||||||
final dbItem = dbItems.firstWhere((element) {
|
final dbItem = dbItems.firstWhere((element) {
|
||||||
final e = AppDbFileDbEntry.fromJson(element.cast<String, dynamic>());
|
final e = AppDbFileDbEntry.fromJson(element.cast<String, dynamic>());
|
||||||
return file_util.getUserDirName(e.file) == account.username;
|
return file_util
|
||||||
|
.getUserDirName(e.file)
|
||||||
|
.equalsIgnoreCase(account.username);
|
||||||
});
|
});
|
||||||
final dbEntry = AppDbFileDbEntry.fromJson(dbItem.cast<String, dynamic>());
|
final dbEntry = AppDbFileDbEntry.fromJson(dbItem.cast<String, dynamic>());
|
||||||
return dbEntry.file;
|
return dbEntry.file;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:nc_photos/entity/face.dart';
|
||||||
import 'package:nc_photos/entity/file.dart';
|
import 'package:nc_photos/entity/file.dart';
|
||||||
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||||
import 'package:nc_photos/exception.dart';
|
import 'package:nc_photos/exception.dart';
|
||||||
|
import 'package:nc_photos/string_extension.dart';
|
||||||
|
|
||||||
class PopulatePerson {
|
class PopulatePerson {
|
||||||
/// Return a list of files of the faces
|
/// Return a list of files of the faces
|
||||||
|
@ -37,7 +38,9 @@ class PopulatePerson {
|
||||||
try {
|
try {
|
||||||
dbItem = dbItems.firstWhere((element) {
|
dbItem = dbItems.firstWhere((element) {
|
||||||
final e = AppDbFileDbEntry.fromJson(element.cast<String, dynamic>());
|
final e = AppDbFileDbEntry.fromJson(element.cast<String, dynamic>());
|
||||||
return file_util.getUserDirName(e.file) == account.username;
|
return file_util
|
||||||
|
.getUserDirName(e.file)
|
||||||
|
.equalsIgnoreCase(account.username);
|
||||||
});
|
});
|
||||||
} on StateError catch (_) {
|
} on StateError catch (_) {
|
||||||
// not found
|
// not found
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:nc_photos/entity/album.dart';
|
||||||
import 'package:nc_photos/entity/album/item.dart';
|
import 'package:nc_photos/entity/album/item.dart';
|
||||||
import 'package:nc_photos/entity/album/provider.dart';
|
import 'package:nc_photos/entity/album/provider.dart';
|
||||||
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||||
|
import 'package:nc_photos/string_extension.dart';
|
||||||
|
|
||||||
/// Resync files inside an album with the file db
|
/// Resync files inside an album with the file db
|
||||||
class ResyncAlbum {
|
class ResyncAlbum {
|
||||||
|
@ -52,7 +53,9 @@ class ResyncAlbum {
|
||||||
try {
|
try {
|
||||||
dbItem = dbItems.firstWhere((element) {
|
dbItem = dbItems.firstWhere((element) {
|
||||||
final e = AppDbFileDbEntry.fromJson(element.cast<String, dynamic>());
|
final e = AppDbFileDbEntry.fromJson(element.cast<String, dynamic>());
|
||||||
return file_util.getUserDirName(e.file) == account.username;
|
return file_util
|
||||||
|
.getUserDirName(e.file)
|
||||||
|
.equalsIgnoreCase(account.username);
|
||||||
});
|
});
|
||||||
} on StateError catch (_) {
|
} on StateError catch (_) {
|
||||||
// not found
|
// not found
|
||||||
|
|
|
@ -17,6 +17,7 @@ import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||||
import 'package:nc_photos/snack_bar_manager.dart';
|
import 'package:nc_photos/snack_bar_manager.dart';
|
||||||
|
import 'package:nc_photos/string_extension.dart';
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/use_case/remove.dart';
|
import 'package:nc_photos/use_case/remove.dart';
|
||||||
import 'package:nc_photos/use_case/remove_share.dart';
|
import 'package:nc_photos/use_case/remove_share.dart';
|
||||||
|
@ -127,7 +128,8 @@ class _SharedFileViewerState extends State<SharedFileViewer> {
|
||||||
title: Text(widget.file.strippedPath),
|
title: Text(widget.file.strippedPath),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.shares.first.uidOwner == widget.account.username) ...[
|
if (widget.shares.first.uidOwner
|
||||||
|
.equalsIgnoreCase(widget.account.username)) ...[
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
|
|
|
@ -19,6 +19,7 @@ import 'package:nc_photos/iterable_extension.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
import 'package:nc_photos/pref.dart';
|
import 'package:nc_photos/pref.dart';
|
||||||
import 'package:nc_photos/snack_bar_manager.dart';
|
import 'package:nc_photos/snack_bar_manager.dart';
|
||||||
|
import 'package:nc_photos/string_extension.dart';
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/use_case/import_potential_shared_album.dart';
|
import 'package:nc_photos/use_case/import_potential_shared_album.dart';
|
||||||
import 'package:nc_photos/widget/album_browser_util.dart' as album_browser_util;
|
import 'package:nc_photos/widget/album_browser_util.dart' as album_browser_util;
|
||||||
|
@ -193,7 +194,8 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
label: shares.first.share.filename,
|
label: shares.first.share.filename,
|
||||||
description: shares.first.share.uidOwner == widget.account.username
|
description:
|
||||||
|
shares.first.share.uidOwner.equalsIgnoreCase(widget.account.username)
|
||||||
? L10n.global().fileLastSharedDescription(dateStr)
|
? L10n.global().fileLastSharedDescription(dateStr)
|
||||||
: L10n.global().fileLastSharedByOthersDescription(
|
: L10n.global().fileLastSharedByOthersDescription(
|
||||||
shares.first.share.displaynameOwner, dateStr),
|
shares.first.share.displaynameOwner, dateStr),
|
||||||
|
@ -247,7 +249,8 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
label: firstItem.album.name,
|
label: firstItem.album.name,
|
||||||
description: shares.first.share.uidOwner == widget.account.username
|
description:
|
||||||
|
shares.first.share.uidOwner.equalsIgnoreCase(widget.account.username)
|
||||||
? L10n.global().fileLastSharedDescription(dateStr)
|
? L10n.global().fileLastSharedDescription(dateStr)
|
||||||
: L10n.global().albumLastSharedByOthersDescription(
|
: L10n.global().albumLastSharedByOthersDescription(
|
||||||
shares.first.share.displaynameOwner, dateStr),
|
shares.first.share.displaynameOwner, dateStr),
|
||||||
|
@ -294,7 +297,8 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
// group shares of the same file
|
// group shares of the same file
|
||||||
final map = <String, List<ListSharingItem>>{};
|
final map = <String, List<ListSharingItem>>{};
|
||||||
for (final i in items) {
|
for (final i in items) {
|
||||||
final isSharedByMe = i.share.uidOwner == widget.account.username;
|
final isSharedByMe =
|
||||||
|
i.share.uidOwner.equalsIgnoreCase(widget.account.username);
|
||||||
final groupKey = "${i.share.path}?$isSharedByMe";
|
final groupKey = "${i.share.path}?$isSharedByMe";
|
||||||
map[groupKey] ??= <ListSharingItem>[];
|
map[groupKey] ??= <ListSharingItem>[];
|
||||||
map[groupKey]!.add(i);
|
map[groupKey]!.add(i);
|
||||||
|
|
Loading…
Reference in a new issue