diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php
index 420b49f5..6042fd55 100644
--- a/lib/Controller/ApiController.php
+++ b/lib/Controller/ApiController.php
@@ -277,7 +277,14 @@ class ApiController extends Controller
}
// Run actual query
- $list = $this->timelineQuery->getAlbums($user->getUID());
+ $list = [];
+ $t = intval($this->request->getParam('t'));
+ if ($t & 1) { // personal
+ $list = array_merge($list, $this->timelineQuery->getAlbums($user->getUID()));
+ }
+ if ($t & 2) { // shared
+ $list = array_merge($list, $this->timelineQuery->getAlbums($user->getUID(), true));
+ }
return new JSONResponse($list, Http::STATUS_OK);
}
diff --git a/lib/Db/TimelineQueryAlbums.php b/lib/Db/TimelineQueryAlbums.php
index 2def19f6..6f391adc 100644
--- a/lib/Db/TimelineQueryAlbums.php
+++ b/lib/Db/TimelineQueryAlbums.php
@@ -30,15 +30,24 @@ trait TimelineQueryAlbums
}
/** Get list of albums */
- public function getAlbums(string $uid)
+ public function getAlbums(string $uid, $shared=false)
{
$query = $this->connection->getQueryBuilder();
// SELECT everything from albums
$count = $query->func()->count($query->createFunction('DISTINCT m.fileid'), 'count');
- $query->select('pa.*', $count)->from('photos_albums', 'pa')->where(
- $query->expr()->eq('user', $query->createNamedParameter($uid)),
- );
+ $query->select('pa.*', $count)->from('photos_albums', 'pa');
+
+ if ($shared) {
+ $query->innerJoin('pa', 'photos_collaborators', 'pc', $query->expr()->andX(
+ $query->expr()->eq('pa.album_id', 'pc.album_id'),
+ $query->expr()->eq('pc.collaborator_id', $query->createNamedParameter($uid)),
+ ));
+ } else {
+ $query->where(
+ $query->expr()->eq('user', $query->createNamedParameter($uid)),
+ );
+ }
// WHERE these are items with this album
$query->leftJoin('pa', 'photos_albums_files', 'paf', $query->expr()->andX(
diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue
index 1fb80cfd..2fb00296 100644
--- a/src/components/Timeline.vue
+++ b/src/components/Timeline.vue
@@ -560,7 +560,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
} else if (this.$route.name === 'people' && !this.$route.params.name) {
data = await dav.getPeopleData();
} else if (this.$route.name === 'albums' && !this.$route.params.name) {
- data = await dav.getAlbumsData();
+ data = await dav.getAlbumsData('3');
} else {
// Try the cache
try {
diff --git a/src/components/frame/Tag.vue b/src/components/frame/Tag.vue
index 71d498cf..0d297f3e 100644
--- a/src/components/frame/Tag.vue
+++ b/src/components/frame/Tag.vue
@@ -9,7 +9,10 @@
@click.native="openTag(data)">
{{ data.count }}
- {{ data.name }}
+
+ {{ data.name }}
+ {{ subtitle }}
+
@@ -29,6 +32,7 @@ import { Component, Prop, Watch, Mixins, Emit } from 'vue-property-decorator';
import { IAlbum, IPhoto, ITag } from '../../types';
import { generateUrl } from '@nextcloud/router'
import { getPreviewUrl } from "../../services/FileUtils";
+import { getCurrentUser } from '@nextcloud/auth';
import { NcCounterBubble } from '@nextcloud/vue'
@@ -50,6 +54,9 @@ export default class Tag extends Mixins(GlobalMixin) {
// Error occured fetching thumbs
private error = false;
+ // Smaller subtitle
+ private subtitle = '';
+
/**
* Open tag event
* Unless noNavigate is set, the tag will be opened
@@ -84,6 +91,7 @@ export default class Tag extends Mixins(GlobalMixin) {
async refreshPreviews() {
// Reset state
this.error = false;
+ this.subtitle = '';
// Add dummy preview if face
if (this.isFace) {
@@ -97,6 +105,9 @@ export default class Tag extends Mixins(GlobalMixin) {
if (album.last_added_photo > 0) {
this.previews = [{ fileid: album.last_added_photo, etag: '', flag: 0 }];
}
+ if (album.user !== getCurrentUser()?.uid) {
+ this.subtitle = `(${album.user})`;
+ }
return;
}
@@ -160,6 +171,12 @@ export default class Tag extends Mixins(GlobalMixin) {
text-overflow: ellipsis;
line-height: 1em;
+ > .subtitle {
+ font-size: 0.7em;
+ margin-top: 2px;
+ display: block;
+ }
+
.isFace > & {
top: unset;
bottom: 10%;
diff --git a/src/components/modal/AlbumPicker.vue b/src/components/modal/AlbumPicker.vue
index 0cafcd98..800936e7 100644
--- a/src/components/modal/AlbumPicker.vue
+++ b/src/components/modal/AlbumPicker.vue
@@ -107,7 +107,7 @@ export default class AlbumPicker extends Mixins(GlobalMixin) {
async loadAlbums() {
try {
- const res = await axios.get(generateUrl('/apps/memories/api/albums'));
+ const res = await axios.get(generateUrl('/apps/memories/api/albums?t=3'));
this.albums = res.data;
} catch (e) {
console.error(e);
diff --git a/src/services/DavRequests.ts b/src/services/DavRequests.ts
index fd5f07b1..f43094c1 100644
--- a/src/services/DavRequests.ts
+++ b/src/services/DavRequests.ts
@@ -558,11 +558,12 @@ export async function* removeFaceImages(user: string, name: string, fileIds: num
/**
* Get list of albums and convert to Days response
+ * @param type Type of albums to get; 1 = personal, 2 = shared, 3 = all
*/
-export async function getAlbumsData(): Promise {
+export async function getAlbumsData(type: '1' | '2' | '3'): Promise {
let data: IAlbum[] = [];
try {
- const res = await axios.get(generateUrl('/apps/memories/api/albums'));
+ const res = await axios.get(generateUrl(`/apps/memories/api/albums?t=${type}`));
data = res.data;
} catch (e) {
throw e;