The personal finance app for everyone
Add post-sync UI stream updates (#1482)
Zach Gollwitzer6996a225ba6a
diff --git a/.gitignore b/.gitignoreindex dc09d53e..b75bf5d4 100644--- a/.gitignore+++ b/.gitignore@@ -6,6 +6,7 @@# Ignore bundler config./.bundle+/vendor/bundle# Ignore all environment files (except templates)./.env*diff --git a/Procfile.dev b/Procfile.devindex 18f6d0df..f3cfa172 100644--- a/Procfile.dev+++ b/Procfile.dev@@ -1,3 +1,3 @@-web: ${DEBUG:+rdbg -O -n -c --} bin/rails server -b 0.0.0.0-css: bin/rails tailwindcss:watch+web: bundle exec ${DEBUG:+rdbg -O -n -c --} bin/rails server -b 0.0.0.0+css: bundle exec bin/rails tailwindcss:watchworker: bundle exec good_job startdiff --git a/app/models/account.rb b/app/models/account.rbindex fcc9dc25..e9a6160f 100644--- a/app/models/account.rb+++ b/app/models/account.rb@@ -99,6 +99,10 @@ class Account < ApplicationRecordHolding::Syncer.new(self, start_date: start_date).runend+ def post_sync+ accountable.post_sync+ end+def original_balancebalance_amount = balances.chronological.first&.balance || balanceMoney.new(balance_amount, currency)diff --git a/app/models/account/balance/syncer.rb b/app/models/account/balance/syncer.rbindex d0e4546e..24a43f8b 100644--- a/app/models/account/balance/syncer.rb+++ b/app/models/account/balance/syncer.rb@@ -46,6 +46,6 @@ class Account::Balance::Syncerenddef is_partial_sync?- sync_start_date == provided_start_date && sync_start_date < Date.current+ sync_start_date == provided_start_dateendenddiff --git a/app/models/concerns/accountable.rb b/app/models/concerns/accountable.rbindex a7a10284..84515374 100644--- a/app/models/concerns/accountable.rb+++ b/app/models/concerns/accountable.rb@@ -33,4 +33,15 @@ module Accountablerescue Money::ConversionErrorTimeSeries.new([])end++ def post_sync+ broadcast_remove_to(account, target: "syncing-notification")++ broadcast_replace_to(+ account,+ target: "chart_account_#{account.id}",+ partial: "accounts/show/chart",+ locals: { account: account }+ )+ endenddiff --git a/app/models/investment.rb b/app/models/investment.rbindex e9df9a4f..ced62765 100644--- a/app/models/investment.rb+++ b/app/models/investment.rb@@ -54,4 +54,15 @@ class Investment < ApplicationRecorddef icon"line-chart"end++ def post_sync+ broadcast_remove_to(account, target: "syncing-notification")++ broadcast_replace_to(+ account,+ target: "chart_account_#{account.id}",+ partial: account.plaid_account_id.present? ? "investments/chart" : "accounts/show/chart",+ locals: { account: account }+ )+ endenddiff --git a/app/views/accounts/show/_chart.html.erb b/app/views/accounts/show/_chart.html.erbindex c3762c62..6b825b48 100644--- a/app/views/accounts/show/_chart.html.erb+++ b/app/views/accounts/show/_chart.html.erb@@ -1,11 +1,11 @@-<%# locals: (account:, title: nil, tooltip: nil) %>+<%# locals: (account:, title: nil, tooltip: nil, **args) %><% period = Period.from_param(params[:period]) %><% series = account.series(period: period) %><% trend = series.trend %><% default_value_title = account.asset? ? t(".balance") : t(".owed") %>-<div class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg">+<div id="<%= dom_id(account, :chart) %>" class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg"><div class="p-4 flex justify-between"><div class="space-y-2"><div class="flex items-center gap-1">diff --git a/app/views/accounts/show/_header.html.erb b/app/views/accounts/show/_header.html.erbindex 1a2b39a5..5abd0873 100644--- a/app/views/accounts/show/_header.html.erb+++ b/app/views/accounts/show/_header.html.erb@@ -21,7 +21,7 @@<div class="flex items-center gap-3 ml-auto"><% unless account.plaid_account_id.present? %>- <%= button_to sync_account_path(account), disabled: account.syncing?, class: "flex items-center gap-2", title: "Sync Account" do %>+ <%= button_to sync_account_path(account), disabled: account.syncing?, data: { turbo: false }, class: "flex items-center gap-2", title: "Sync Account" do %><%= lucide_icon "refresh-cw", class: "w-4 h-4 text-gray-500 hover:text-gray-400" %><% end %><% end %>diff --git a/app/views/investments/_chart.html.erb b/app/views/investments/_chart.html.erbindex 9f88954e..ceb7f32b 100644--- a/app/views/investments/_chart.html.erb+++ b/app/views/investments/_chart.html.erb@@ -1,10 +1,10 @@-<%# locals: (account:) %>+<%# locals: (account:, **args) %><% period = Period.from_param(params[:period]) %><% series = account.series(period: period) %><% trend = series.trend %>-<div class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg">+<div id="<%= dom_id(account, :chart) %>" class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg"><div class="p-4 flex justify-between"><div class="space-y-2"><div class="flex items-center gap-1">