From 7aa1d512fc00cb916b5f0c62a7809f78385e6472 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Thu, 26 Sep 2024 20:32:04 -0700 Subject: [PATCH] Photo view count tweaks * The owner of a photo no longer counts any views on it. * Add event handlers to mark animated GIFs viewed on the gallery page: if the user mouse overs or pauses the video. --- pkg/models/photo.go | 5 +++++ web/templates/photo/gallery.html | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/pkg/models/photo.go b/pkg/models/photo.go index db854a3..70715db 100644 --- a/pkg/models/photo.go +++ b/pkg/models/photo.go @@ -194,6 +194,11 @@ func PaginateUserPhotos(userID uint64, conf UserGallery, pager *Pagination) ([]* // View a photo, incrementing its Views count but not its UpdatedAt. // Debounced with a Redis key. func (p *Photo) View(userID uint64) error { + // The owner of the photo does not count views. + if p.UserID == userID { + return nil + } + // Debounce this. var redisKey = fmt.Sprintf(config.PhotoViewDebounceRedisKey, userID, p.ID) if redis.Exists(redisKey) { diff --git a/web/templates/photo/gallery.html b/web/templates/photo/gallery.html index 1fa19bb..6fbfa90 100644 --- a/web/templates/photo/gallery.html +++ b/web/templates/photo/gallery.html @@ -542,6 +542,8 @@ {{if HasSuffix .Filename ".mp4"}}