mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 02:48:54 +01:00
List albums shared by me
This commit is contained in:
parent
0478fe3840
commit
1106dfc72f
1 changed files with 26 additions and 11 deletions
|
@ -196,25 +196,25 @@ class ListSharingBloc extends Bloc<ListSharingBlocEvent, ListSharingBlocState> {
|
||||||
path: remote_storage_util.getRemoteAlbumsDir(ev.account),
|
path: remote_storage_util.getRemoteAlbumsDir(ev.account),
|
||||||
));
|
));
|
||||||
return (await Future.wait([
|
return (await Future.wait([
|
||||||
_querySharesByMe(ev),
|
_querySharesByMe(ev, sharedAlbumFiles),
|
||||||
_querySharesWithMe(ev, sharedAlbumFiles),
|
_querySharesWithMe(ev, sharedAlbumFiles),
|
||||||
]))
|
]))
|
||||||
.reduce((value, element) => value + element);
|
.reduce((value, element) => value + element);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ListSharingItem>> _querySharesByMe(
|
Future<List<ListSharingItem>> _querySharesByMe(
|
||||||
ListSharingBlocQuery ev) async {
|
ListSharingBlocQuery ev, List<File> sharedAlbumFiles) async {
|
||||||
final shareRepo = ShareRepo(ShareRemoteDataSource());
|
final shareRepo = ShareRepo(ShareRemoteDataSource());
|
||||||
final shares = await shareRepo.listAll(ev.account);
|
final shares = await shareRepo.listAll(ev.account);
|
||||||
final futures = shares.map((e) async {
|
final futures = shares.map((s) async {
|
||||||
// include link share dirs
|
|
||||||
if (e.itemType == ShareItemType.folder) {
|
|
||||||
final webdavPath =
|
final webdavPath =
|
||||||
"${api_util.getWebdavRootUrlRelative(ev.account)}/${e.path}";
|
"${api_util.getWebdavRootUrlRelative(ev.account)}/${s.path}";
|
||||||
|
// include link share dirs
|
||||||
|
if (s.itemType == ShareItemType.folder) {
|
||||||
if (webdavPath.startsWith(
|
if (webdavPath.startsWith(
|
||||||
remote_storage_util.getRemoteLinkSharesDir(ev.account))) {
|
remote_storage_util.getRemoteLinkSharesDir(ev.account))) {
|
||||||
return ListSharingFile(
|
return ListSharingFile(
|
||||||
e,
|
s,
|
||||||
File(
|
File(
|
||||||
path: webdavPath,
|
path: webdavPath,
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
|
@ -222,8 +222,23 @@ class ListSharingBloc extends Bloc<ListSharingBlocEvent, ListSharingBlocState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// include shared albums
|
||||||
|
if (path.dirname(webdavPath) ==
|
||||||
|
remote_storage_util.getRemoteAlbumsDir(ev.account)) {
|
||||||
|
try {
|
||||||
|
final file = sharedAlbumFiles
|
||||||
|
.firstWhere((element) => element.fileId == s.itemSource);
|
||||||
|
return await _querySharedAlbum(ev, s, file);
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
_log.severe(
|
||||||
|
"[_querySharesWithMe] Shared album not found: ${s.itemSource}",
|
||||||
|
e,
|
||||||
|
stackTrace);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!file_util.isSupportedMime(e.mimeType)) {
|
if (!file_util.isSupportedMime(s.mimeType)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// show only link shares
|
// show only link shares
|
||||||
|
@ -231,14 +246,14 @@ class ListSharingBloc extends Bloc<ListSharingBlocEvent, ListSharingBlocState> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (ev.account.roots
|
if (ev.account.roots
|
||||||
.every((r) => r.isNotEmpty && !e.path.startsWith("/$r/"))) {
|
.every((r) => r.isNotEmpty && !s.path.startsWith("/$r/"))) {
|
||||||
// ignore files not under root dirs
|
// ignore files not under root dirs
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final file = await FindFile()(ev.account, e.itemSource);
|
final file = await FindFile()(ev.account, s.itemSource);
|
||||||
return ListSharingFile(e, file);
|
return ListSharingFile(s, file);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
_log.warning("[_querySharesByMe] File not found: ${e.itemSource}");
|
_log.warning("[_querySharesByMe] File not found: ${e.itemSource}");
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue