From 2ab34a39a316e3cb7ec05f6cd6e05ce2ab2d60a7 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 29 Mar 2024 20:35:41 -0700 Subject: [PATCH] Better UX for Who's Nearby feature --- pkg/controller/account/search.go | 2 +- pkg/controller/account/signup.go | 1 - pkg/models/user.go | 2 +- web/templates/account/search.html | 30 ++++++++++++++++++------------ web/templates/base.html | 5 +++++ 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/pkg/controller/account/search.go b/pkg/controller/account/search.go index a9c26cb..bc02758 100644 --- a/pkg/controller/account/search.go +++ b/pkg/controller/account/search.go @@ -101,7 +101,7 @@ func Search() http.HandlerFunc { AgeMax: ageMax, }, pager) if err != nil { - session.FlashError(w, r, "Couldn't search users: %s", err) + session.FlashError(w, r, "An error has occurred: %s.", err) } // Who's Nearby feature, get some data. diff --git a/pkg/controller/account/signup.go b/pkg/controller/account/signup.go index 4cb509f..ea320bc 100644 --- a/pkg/controller/account/signup.go +++ b/pkg/controller/account/signup.go @@ -60,7 +60,6 @@ func Signup() http.HandlerFunc { } var token SignupToken - log.Info("SignupToken: %s", tokenStr) if tokenStr != "" { // Validate it. if err := redis.Get(fmt.Sprintf(config.SignupTokenRedisKey, tokenStr), &token); err != nil || token.Token != tokenStr { diff --git a/pkg/models/user.go b/pkg/models/user.go index f7c70a3..1758dda 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -267,7 +267,7 @@ func SearchUsers(user *User, search *UserSearch, pager *Pagination) ([]*User, er // If the current user doesn't have their location on file, they can't do this. if myLocation.Source == LocationSourceNone || (myLocation.Latitude == 0 && myLocation.Longitude == 0) { - return users, errors.New("can not order by distance because your location is not known") + return users, errors.New("can not sort members by distance because your location is not known") } // Only query for users who have locations. diff --git a/web/templates/account/search.html b/web/templates/account/search.html index 2a98f9d..fb5366b 100644 --- a/web/templates/account/search.html +++ b/web/templates/account/search.html @@ -43,20 +43,26 @@ {{end}} {{else}} -
- Showing you Who's Nearby. +
+

+ Showing you Who's Nearby. +

- {{if eq .MyLocation.Source "geoip"}} - You set your location automatically by your IP address (currently {{.GeoIPInsights.Short}}). - Update settings? - {{else if eq .MyLocation.Source "gps"}} - Your location was set by your GPS location. - Refresh your location now? - {{else if eq .MyLocation.Source "pin"}} - You set your location by pin on a map. - Update your location? - {{end}} +

+ {{if eq .MyLocation.Source "geoip"}} + You had set your location to update automatically by your IP address (currently {{.GeoIPInsights.Short}}). + Change your location settings? + {{else if eq .MyLocation.Source "gps"}} + You once set your location via your device's GPS coordinates. + Refresh to your current location now? + {{else if eq .MyLocation.Source "pin"}} + You had set your location by dropping a pin on a map. + Update your location? + {{else if eq .MyLocation.Source ""}} + You will need to set your location first before we can sort people by distance from you. + {{end}} +

{{end}} diff --git a/web/templates/base.html b/web/templates/base.html index cd73df5..e82aa68 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -95,6 +95,11 @@