Skip to content

Commit

Permalink
Photos: Skip related albums from which a photo was removed #3095
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mayer <michael@photoprism.app>
  • Loading branch information
lastzero committed Jun 15, 2023
1 parent 1776728 commit 90a18f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions frontend/src/dialog/photo/edit/info.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
</td>
<td>{{ model.getDateString() }}</td>
</tr>
<tr v-if="model.Albums && model.Albums.length">
<tr v-if="albums.length > 0">
<td>
<translate>Albums</translate>
</td>
<td>
<a v-for="(m, i) in model.Albums" :key="i" :href="albumUrl(m)" class="primary--text text-link" target="_blank"><span v-if="i > 0">, </span>{{ m.Title }}</a>
<a v-for="(a, i) in albums" :key="i" :href="a.url" class="primary--text text-link" target="_blank"><span v-if="i > 0">, </span>{{ a.title }}</a>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -311,6 +311,17 @@ export default {
return result;
},
albums() {
if (!this.model || !this.model.Albums || this.model.Albums.length < 1) {
return [];
}
const results = [];
this.model.Albums.forEach(a => results.push({"title": a.Title, "url": this.albumUrl(a)}));
return results;
},
},
methods: {
formatTime(s) {
Expand Down
4 changes: 2 additions & 2 deletions internal/entity/photo.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func (m *Photo) PreloadKeywords() {
q := Db().NewScope(nil).DB().
Table("keywords").
Select(`keywords.*`).
Joins("JOIN photos_keywords ON photos_keywords.keyword_id = keywords.id AND photos_keywords.photo_id = ?", m.ID).
Joins("JOIN photos_keywords pk ON pk.keyword_id = keywords.id AND pk.photo_id = ?", m.ID).
Order("keywords.keyword ASC")

Log("photo", "preload files", q.Scan(&m.Keywords).Error)
Expand All @@ -511,7 +511,7 @@ func (m *Photo) PreloadAlbums() {
q := Db().NewScope(nil).DB().
Table("albums").
Select(`albums.*`).
Joins("JOIN photos_albums ON photos_albums.album_uid = albums.album_uid AND photos_albums.photo_uid = ?", m.PhotoUID).
Joins("JOIN photos_albums pa ON pa.album_uid = albums.album_uid AND pa.photo_uid = ? AND pa.hidden = 0", m.PhotoUID).
Where("albums.deleted_at IS NULL").
Order("albums.album_title ASC")

Expand Down

0 comments on commit 90a18f6

Please sign in to comment.