feat: implement scroll position restoration for mobile tabs and add double-tap home navigation to refresh feed views.

This commit is contained in:
2026-08-29 15:02:56 -07:00
parent cd98c0120e
commit 271a542196
18 changed files with 1446 additions and 240 deletions
+44
View File
@@ -134,6 +134,50 @@ func (h *Handler) UpdatePassword(w http.ResponseWriter, r *http.Request) {
h.writeJSON(w, http.StatusOK, map[string]string{"message": "password updated successfully"})
}
// User Preferences Handlers
func (h *Handler) GetUserPreferences(w http.ResponseWriter, r *http.Request) {
claims, ok := r.Context().Value(auth.UserContextKey).(*auth.Claims)
if !ok {
h.writeError(w, http.StatusUnauthorized, "unauthorized")
return
}
user, err := h.db.GetUserByUsername(claims.Username)
if err != nil {
h.writeError(w, http.StatusNotFound, "user not found")
return
}
h.writeJSON(w, http.StatusOK, user.Preferences)
}
func (h *Handler) UpdateUserPreferences(w http.ResponseWriter, r *http.Request) {
claims, ok := r.Context().Value(auth.UserContextKey).(*auth.Claims)
if !ok {
h.writeError(w, http.StatusUnauthorized, "unauthorized")
return
}
user, err := h.db.GetUserByUsername(claims.Username)
if err != nil {
h.writeError(w, http.StatusNotFound, "user not found")
return
}
var newPrefs map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&newPrefs); err != nil {
h.writeError(w, http.StatusBadRequest, "invalid request payload")
return
}
if user.Preferences == nil {
user.Preferences = make(map[string]interface{})
}
for k, v := range newPrefs {
user.Preferences[k] = v
}
if err := h.db.UpdateUserPreferences(user.ID, user.Preferences); err != nil {
h.writeError(w, http.StatusInternalServerError, err.Error())
return
}
h.writeJSON(w, http.StatusOK, user.Preferences)
}
// Stats Handler
func (h *Handler) GetStats(w http.ResponseWriter, r *http.Request) {
stats, err := h.db.GetStats()
+2
View File
@@ -45,6 +45,8 @@ func NewRouter(h *Handler, authService *auth.AuthService, staticDir string) http
r.Get("/auth/me", h.GetMe)
r.Put("/auth/password", h.UpdatePassword)
r.Get("/user/preferences", h.GetUserPreferences)
r.Put("/user/preferences", h.UpdateUserPreferences)
r.Get("/stats", h.GetStats)
// Categories