From b1b2793e43e9bb643d566f2b05c17f9bbef2593b Mon Sep 17 00:00:00 2001 From: Jeff Rowberg Date: Sat, 21 Feb 2026 09:47:31 -0500 Subject: [PATCH] Skip unnecessary sync when account balance unchanged on update (#1040) The update action was calling set_current_balance (which triggers sync_later internally) on every form submission, even when the balance hadn't changed. This caused the account to enter a syncing state, replacing the visible balance with a pulsing skeleton placeholder until the sync completed. Now we compare the submitted balance against the current value and only call set_current_balance when it actually differs. Also removes a redundant sync_later call that duplicated the one already inside set_current_balance. Co-authored-by: Claude Opus 4.6 --- app/controllers/concerns/accountable_resource.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/accountable_resource.rb b/app/controllers/concerns/accountable_resource.rb index 1b8bbf6d2..007a5f33a 100644 --- a/app/controllers/concerns/accountable_resource.rb +++ b/app/controllers/concerns/accountable_resource.rb @@ -41,15 +41,14 @@ module AccountableResource end def update - # Handle balance update if provided - if account_params[:balance].present? + # Handle balance update if the value actually changed + if account_params[:balance].present? && account_params[:balance].to_d != @account.balance result = @account.set_current_balance(account_params[:balance].to_d) unless result.success? @error_message = result.error_message render :edit, status: :unprocessable_entity return end - @account.sync_later end # Update remaining account attributes