From d1948341104296d956778ba7909481295e827fad Mon Sep 17 00:00:00 2001 From: qdust41 Date: Thu, 9 Apr 2026 17:44:13 -0400 Subject: [PATCH] claude fix for making the avatars properly get re-fetched if they are newer than the old avatars --- lib/mixer_web/controllers/upload_controller.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/mixer_web/controllers/upload_controller.ex b/lib/mixer_web/controllers/upload_controller.ex index 5ee7c41..6bc3814 100644 --- a/lib/mixer_web/controllers/upload_controller.ex +++ b/lib/mixer_web/controllers/upload_controller.ex @@ -62,8 +62,10 @@ defmodule MixerWeb.UploadController do case AvatarUploader.store({upload, scope}) do {:ok, _file_name} -> - # The thumb is always stored as avatars/:user_id/thumb.webp - thumb_key = "avatars/#{actor.id}/thumb.webp" + # The thumb is always stored as avatars/:user_id/thumb.webp. + # Append a timestamp so the browser doesn't serve a stale cached image + # when the user updates their avatar (the URL changes, S3 ignores the param). + thumb_key = "avatars/#{actor.id}/thumb.webp?v=#{System.system_time(:millisecond)}" actor |> Ash.Changeset.for_update(:update_avatar, %{avatar_url: thumb_key}, actor: actor)