mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +02:00
Plaid item UI broadcasts for sync
This commit is contained in:
parent
65ab4e0089
commit
dd5292555a
4 changed files with 25 additions and 1 deletions
|
@ -61,6 +61,18 @@ class Account < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def syncing?
|
||||
self_syncing = syncs.incomplete.any?
|
||||
|
||||
# Since Plaid Items sync as a "group", if the item is syncing, even if the account
|
||||
# sync hasn't yet started (i.e. we're still fetching the Plaid data), show it as syncing in UI.
|
||||
if linked?
|
||||
plaid_account&.plaid_item&.syncing? || self_syncing
|
||||
else
|
||||
self_syncing
|
||||
end
|
||||
end
|
||||
|
||||
def institution_domain
|
||||
url_string = plaid_account&.plaid_item&.institution_url
|
||||
return nil unless url_string.present?
|
||||
|
|
|
@ -14,6 +14,12 @@ class Account::Syncer
|
|||
account.family.auto_match_transfers!
|
||||
account.broadcast_refresh
|
||||
SyncCompleteEvent.new(account.family, accounts: [ account ]).broadcast
|
||||
account.broadcast_replace_to(
|
||||
account.family,
|
||||
target: "account_#{account.id}",
|
||||
partial: "accounts/account",
|
||||
locals: { account: account }
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -6,7 +6,7 @@ module Syncable
|
|||
end
|
||||
|
||||
def syncing?
|
||||
syncs.incomplete.any?
|
||||
raise NotImplementedError, "Subclasses must implement the syncing? method"
|
||||
end
|
||||
|
||||
def sync_later(parent_sync: nil, window_start_date: nil, window_end_date: nil)
|
||||
|
|
|
@ -25,6 +25,12 @@ class PlaidItem::Syncer
|
|||
def perform_post_sync
|
||||
plaid_item.auto_match_categories!
|
||||
SyncCompleteEvent.new(plaid_item.family, accounts: plaid_item.accounts).broadcast
|
||||
plaid_item.broadcast_replace_to(
|
||||
plaid_item.family,
|
||||
target: "plaid_item_#{plaid_item.id}",
|
||||
partial: "plaid_items/plaid_item",
|
||||
locals: { plaid_item: plaid_item }
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue