Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,198 changes: 600 additions & 598 deletions l10n/de.js

Large diffs are not rendered by default.

1,198 changes: 600 additions & 598 deletions l10n/de_DE.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions lib/ClustersBackend/AlbumsBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,22 @@ public function getClustersInternal(int $fileid = 0): array
$this->albumsQuery->transformSharedFlag($query);
};

// Transformation to get the date range of photos in the album
$dateRange = function (IQueryBuilder &$query): void {
$this->albumsQuery->transformDateRange($query);
};

// Transformations to apply to own albums
$transformOwned = [
$sharedFlag,
$dateRange,
$materialize, $ownCover,
$materialize, $etag('last_added_photo'), $etag('cover'),
];

// Transformations to apply to shared albums
$transformShared = [
$dateRange,
$materialize, $ownCover, $shareCover,
$materialize, $etag('last_added_photo'), $etag('cover'), $etag('cover_owner'),
];
Expand Down
12 changes: 12 additions & 0 deletions lib/Db/AlbumsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public function getList(
$row['album_id'] = (int) $row['album_id'];
$row['created'] = (int) $row['created'];
$row['last_added_photo'] = (int) $row['last_added_photo'];
if (null !== $row['oldest_date']) {
$row['oldest_date'] = strtotime($row['oldest_date']);
}
if (null !== $row['newest_date']) {
$row['newest_date'] = strtotime($row['newest_date']);
}
}

return $albums;
Expand Down Expand Up @@ -314,6 +320,12 @@ public function transformSharedFlag(IQueryBuilder &$query): void
$query->selectAlias(SQL::exists($query, $sSq), 'shared');
}

public function transformDateRange(IQueryBuilder &$query): void
{
$query->selectAlias($query->func()->min('m.datetaken'), 'oldest_date');
$query->selectAlias($query->func()->max('m.datetaken'), 'newest_date');
}

/**
* Get the various collaborator IDs that a user has.
* This includes the groups the user is in and the user itself.
Expand Down
24 changes: 23 additions & 1 deletion src/components/top-matter/AlbumTopMatter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@
{{ t('memories', 'Creation date') }}
</NcActionRadio>

<NcActionRadio
name="sort"
:aria-label="t('memories', 'Oldest photo')"
:checked="!!(config.album_list_sort & c.ALBUM_SORT_FLAGS.OLDEST)"
@change="changeSort(c.ALBUM_SORT_FLAGS.OLDEST)"
close-after-click
>
{{ t('memories', 'Oldest photo') }}
</NcActionRadio>

<NcActionRadio
name="sort"
:aria-label="t('memories', 'Newest photo')"
:checked="!!(config.album_list_sort & c.ALBUM_SORT_FLAGS.NEWEST)"
@change="changeSort(c.ALBUM_SORT_FLAGS.NEWEST)"
close-after-click
>
{{ t('memories', 'Newest photo') }}
</NcActionRadio>

<NcActionRadio
name="sort"
:aria-label="t('memories', 'Album name')"
Expand Down Expand Up @@ -223,7 +243,9 @@ export default defineComponent({
isDateSort(): boolean {
return (
!!(this.config.album_list_sort & this.c.ALBUM_SORT_FLAGS.CREATED) ||
!!(this.config.album_list_sort & this.c.ALBUM_SORT_FLAGS.LAST_UPDATE)
!!(this.config.album_list_sort & this.c.ALBUM_SORT_FLAGS.LAST_UPDATE) ||
!!(this.config.album_list_sort & this.c.ALBUM_SORT_FLAGS.OLDEST) ||
!!(this.config.album_list_sort & this.c.ALBUM_SORT_FLAGS.NEWEST)
);
},

Expand Down
4 changes: 4 additions & 0 deletions src/services/dav/albums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export async function getAlbums(fileid?: number) {
data.sort((a, b) => a.name.localeCompare(b.name, getLanguage(), { numeric: true }));
} else if (sort & utils.constants.ALBUM_SORT_FLAGS.LAST_UPDATE) {
data.sort((a, b) => (a.update_id ?? Number.MAX_SAFE_INTEGER) - (b.update_id ?? Number.MAX_SAFE_INTEGER));
} else if (sort & utils.constants.ALBUM_SORT_FLAGS.NEWEST) {
data.sort((a, b) => (a.newest_date ?? Number.MAX_SAFE_INTEGER) - (b.newest_date ?? Number.MAX_SAFE_INTEGER));
} else if (sort & utils.constants.ALBUM_SORT_FLAGS.OLDEST) {
data.sort((a, b) => (a.oldest_date ?? Number.MAX_SAFE_INTEGER) - (b.oldest_date ?? Number.MAX_SAFE_INTEGER));
} else {
// fall back to created date
data.sort((a, b) => a.created - b.created);
Expand Down
2 changes: 2 additions & 0 deletions src/services/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const constants = Object.freeze({
LAST_UPDATE: 1 << 1, // default
CREATED: 1 << 2,
NAME: 1 << 3,
OLDEST: 1 << 4, // sort by oldest photo in album
NEWEST: 1 << 5, // ditto for newest
},
});

Expand Down
3 changes: 3 additions & 0 deletions src/typings/cluster.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ declare module '@typings' {
update_id: number;
/** Album is shared with other users */
shared: boolean;
/** Date range of photos in album */
oldest_date: number;
newest_date: number;
}

export interface IFace extends ICluster {
Expand Down