Ability to find your "Likes" on the Site Gallery

This commit is contained in:
Noah Petherbridge 2024-04-27 19:06:17 -07:00
parent 04f1c56809
commit 2f352f8664
3 changed files with 22 additions and 1 deletions

View File

@ -64,7 +64,7 @@ func SiteGallery() http.HandlerFunc {
// They didn't post a "Whose photos" filter, restore it from their last saved default. // They didn't post a "Whose photos" filter, restore it from their last saved default.
who = currentUser.GetProfileField("site_gallery_default") who = currentUser.GetProfileField("site_gallery_default")
} }
if who != "friends" && who != "everybody" && who != "friends+private" { if who != "friends" && who != "everybody" && who != "friends+private" && who != "likes" {
// Default Who setting should be Friends-only, unless you have no friends. // Default Who setting should be Friends-only, unless you have no friends.
if myFriendCount > 0 { if myFriendCount > 0 {
who = "friends" who = "friends"
@ -94,6 +94,7 @@ func SiteGallery() http.HandlerFunc {
AdminView: adminView, AdminView: adminView,
FriendsOnly: who == "friends", FriendsOnly: who == "friends",
IsShy: isShy || who == "friends+private", IsShy: isShy || who == "friends+private",
MyLikes: who == "likes",
}, pager) }, pager)
// Bulk load the users associated with these photos. // Bulk load the users associated with these photos.

View File

@ -474,6 +474,7 @@ type Gallery struct {
AdminView bool // Show all images AdminView bool // Show all images
IsShy bool // Current user is like a Shy Account (or: show self/friends and private photo grants only) IsShy bool // Current user is like a Shy Account (or: show self/friends and private photo grants only)
FriendsOnly bool // Only show self/friends instead of everybody's pics FriendsOnly bool // Only show self/friends instead of everybody's pics
MyLikes bool // Filter to photos I have liked
} }
/* /*
@ -577,6 +578,20 @@ func PaginateGalleryPhotos(user *User, conf Gallery, pager *Pagination) ([]*Phot
wheres = append(wheres, "gallery = ?") wheres = append(wheres, "gallery = ?")
placeholders = append(placeholders, true) placeholders = append(placeholders, true)
// Filter by photos the user has liked.
if conf.MyLikes {
wheres = append(wheres, `
EXISTS (
SELECT 1
FROM likes
WHERE user_id = ?
AND table_name = 'photos'
AND table_id = photos.id
)
`)
placeholders = append(placeholders, user.ID)
}
// Filter blocked users. // Filter blocked users.
if len(blocklist) > 0 { if len(blocklist) > 0 {
wheres = append(wheres, "user_id NOT IN ?") wheres = append(wheres, "user_id NOT IN ?")

View File

@ -336,6 +336,10 @@
as any <strong>private photos shared with you</strong> by others on the site (if they are as any <strong>private photos shared with you</strong> by others on the site (if they are
marked to appear in the Site Gallery). marked to appear in the Site Gallery).
</div> </div>
{{else if eq .FilterWho "likes"}}
<div class="notification is-success is-light">
Showing you photos that you have <i class="fa fa-heart"></i> <strong>Liked.</strong>
</div>
{{end}} {{end}}
<!-- Filters --> <!-- Filters -->
@ -365,6 +369,7 @@
<select id="who" name="who"> <select id="who" name="who">
<option value="friends"{{if eq .FilterWho "friends"}} selected{{end}}>Myself &amp; friends only</option> <option value="friends"{{if eq .FilterWho "friends"}} selected{{end}}>Myself &amp; friends only</option>
<option value="friends+private"{{if eq .FilterWho "friends+private"}} selected{{end}}>Myself, friends, &amp; private photo grants</option> <option value="friends+private"{{if eq .FilterWho "friends+private"}} selected{{end}}>Myself, friends, &amp; private photo grants</option>
<option value="likes"{{if eq .FilterWho "likes"}} selected{{end}}>Photos I have 'liked'</option>
<option value="everybody"{{if eq .FilterWho "everybody"}} selected{{end}}>All certified members</option> <option value="everybody"{{if eq .FilterWho "everybody"}} selected{{end}}>All certified members</option>
</select> </select>
</div> </div>