1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 07:25:19 +02:00

Sync completion event broadcasts

This commit is contained in:
Zach Gollwitzer 2025-05-14 21:04:20 -04:00
parent b041edb648
commit 246343a4bf
25 changed files with 237 additions and 169 deletions

View file

@ -1,7 +1,6 @@
/* Custom shadow borders used for surfaces / containers */
@utility shadow-border-xs {
box-shadow: var(--shadow-xs), 0px 0px 0px 1px var(--color-alpha-black-50);
transform: translateZ(0);
@variant theme-dark {
box-shadow: var(--shadow-xs), 0px 0px 0px 1px var(--color-alpha-white-50);
@ -10,7 +9,6 @@
@utility shadow-border-sm {
box-shadow: var(--shadow-sm), 0px 0px 0px 1px var(--color-alpha-black-50);
transform: translateZ(0);
@variant theme-dark {
box-shadow: var(--shadow-sm), 0px 0px 0px 1px var(--color-alpha-white-50);
@ -19,7 +17,6 @@
@utility shadow-border-md {
box-shadow: var(--shadow-md), 0px 0px 0px 1px var(--color-alpha-black-50);
transform: translateZ(0);
@variant theme-dark {
box-shadow: var(--shadow-md), 0px 0px 0px 1px var(--color-alpha-white-50);
@ -28,7 +25,6 @@
@utility shadow-border-lg {
box-shadow: var(--shadow-lg), 0px 0px 0px 1px var(--color-alpha-black-50);
transform: translateZ(0);
@variant theme-dark {
box-shadow: var(--shadow-lg), 0px 0px 0px 1px var(--color-alpha-white-50);
@ -37,7 +33,6 @@
@utility shadow-border-xl {
box-shadow: var(--shadow-xl), 0px 0px 0px 1px var(--color-alpha-black-50);
transform: translateZ(0);
@variant theme-dark {
box-shadow: var(--shadow-xl), 0px 0px 0px 1px var(--color-alpha-white-50);

View file

@ -11,11 +11,6 @@
<% else %>
<%= nav %>
<%= form_with url: cookie_session_path, scope: :cookie_session, method: :put, data: { tabs_target: "persistSelectionForm" } do |f| %>
<%= f.hidden_field :tab_key, value: "account_group_tab" %>
<%= f.hidden_field :tab_value, value: "all", data: { tabs_target: "selectionInput" } %>
<% end %>
<% panels.each do |panel| %>
<%= panel %>
<% end %>

View file

@ -36,8 +36,22 @@ export default class extends Controller {
// Update URL with the selected tab
if (this.sessionKeyValue) {
this.selectionInputTarget.value = selectedTabId;
this.persistSelectionFormTarget.requestSubmit();
this.#updateSessionPreference(selectedTabId);
}
}
#updateSessionPreference(selectedTabId) {
fetch("/current_session", {
method: "PUT",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"X-CSRF-Token": document.querySelector('[name="csrf-token"]').content,
Accept: "application/json",
},
body: new URLSearchParams({
"current_session[tab_key]": this.sessionKeyValue,
"current_session[tab_value]": selectedTabId,
}).toString(),
});
}
}

View file

@ -1,7 +1,7 @@
class ApplicationController < ActionController::Base
include Onboardable, Localize, AutoSync, Authentication, Invitable,
include RestoreLayoutPreferences, Onboardable, Localize, AutoSync, Authentication, Invitable,
SelfHostable, StoreLocation, Impersonatable, Breadcrumbable,
FeatureGuardable, Notifiable, AccountGroupable
FeatureGuardable, Notifiable
include Pagy::Backend

View file

@ -1,13 +1,13 @@
module AccountGroupable
module RestoreLayoutPreferences
extend ActiveSupport::Concern
included do
before_action :set_account_group_tab
before_action :restore_active_tabs
end
private
def set_account_group_tab
last_selected_tab = session["custom_account_group_tab"] || "asset"
def restore_active_tabs
last_selected_tab = Current.session&.get_preferred_tab("account_sidebar_tab") || "asset"
@account_group_tab = account_group_tab_param || last_selected_tab
end
@ -17,7 +17,7 @@ module AccountGroupable
end
def account_group_tab_param
param_value = params[:account_group_tab]
param_value = params[:account_sidebar_tab]
return nil unless param_value.in?(valid_account_group_tabs)
param_value
end

View file

@ -0,0 +1,14 @@
class CurrentSessionsController < ApplicationController
def update
if session_params[:tab_key].present? && session_params[:tab_value].present?
Current.session.set_preferred_tab(session_params[:tab_key], session_params[:tab_value])
end
head :ok
end
private
def session_params
params.require(:current_session).permit(:tab_key, :tab_value)
end
end

View file

@ -13,7 +13,7 @@ class Account::Syncer
def perform_post_sync
account.family.auto_match_transfers!
account.broadcast_refresh
account.family.broadcast_sidebar_refresh
SyncCompleteEvent.new(account.family, accounts: [ account ]).broadcast
end
private

View file

@ -54,8 +54,11 @@ class BalanceSheet
groups = account_groups.map do |accountable, accounts|
group_total = accounts.sum(&:converted_balance)
key = accountable.model_name.param_key
AccountGroup.new(
key: accountable.model_name.param_key,
id: classification ? "#{classification}_#{key}_group" : "#{key}_group",
key: key,
name: accountable.display_name,
classification: accountable.classification,
total: group_total,
@ -95,7 +98,7 @@ class BalanceSheet
private
ClassificationGroup = Struct.new(:key, :display_name, :icon, :total_money, :account_groups, :syncing?, keyword_init: true)
AccountGroup = Struct.new(:key, :name, :accountable_type, :classification, :total, :total_money, :weight, :accounts, :color, :missing_rates?, :syncing?, keyword_init: true)
AccountGroup = Struct.new(:id, :key, :name, :accountable_type, :classification, :total, :total_money, :weight, :accounts, :color, :missing_rates?, :syncing?, keyword_init: true)
def active_accounts
family.accounts.active.with_attached_logo

View file

@ -44,14 +44,6 @@ class Family < ApplicationRecord
.exists?
end
def broadcast_sidebar_refresh
broadcast_replace(
target: "account-sidebar-tabs",
partial: "accounts/sidebar_tabs",
locals: { family: self, active_account_group_tab: "all" }
)
end
def assigned_merchants
merchant_ids = transactions.where.not(merchant_id: nil).pluck(:merchant_id).uniq
Merchant.where(id: merchant_ids)

View file

@ -24,7 +24,7 @@ class PlaidItem::Syncer
def perform_post_sync
plaid_item.auto_match_categories!
plaid_item.family.broadcast_sidebar_refresh
SyncCompleteEvent.new(plaid_item.family, accounts: plaid_item.accounts).broadcast
end
private

View file

@ -9,4 +9,14 @@ class Session < ApplicationRecord
self.user_agent = Current.user_agent
self.ip_address = Current.ip_address
end
def get_preferred_tab(tab_key)
data.dig("tab_preferences", tab_key)
end
def set_preferred_tab(tab_key, tab_value)
data["tab_preferences"] ||= {}
data["tab_preferences"][tab_key] = tab_value
save!
end
end

View file

@ -49,7 +49,9 @@ class Sync < ApplicationRecord
begin
syncable.perform_sync(self)
rescue => e
fail_and_report_error(e)
fail!
update(error: e.message)
report_error(e)
ensure
finalize_if_all_children_finalized
end
@ -64,9 +66,6 @@ class Sync < ApplicationRecord
# If this is the "parent" and there are still children running, don't finalize.
return unless all_children_finalized?
# If we make it here, the sync is finalized. Run post-sync, regardless of failure/success.
perform_post_sync
if syncing?
if has_failed_children?
fail!
@ -74,6 +73,9 @@ class Sync < ApplicationRecord
complete!
end
end
# If we make it here, the sync is finalized. Run post-sync, regardless of failure/success.
perform_post_sync
end
# If this sync has a parent, try to finalize it so the child status propagates up the chain.
@ -96,12 +98,10 @@ class Sync < ApplicationRecord
def perform_post_sync
syncable.perform_post_sync
rescue => e
fail_and_report_error(e)
report_error(e)
end
def fail_and_report_error(error)
fail!
update(error: error.message)
def report_error(error)
Sentry.capture_exception(error) do |scope|
scope.set_tags(sync_id: id)
end

View file

@ -0,0 +1,37 @@
class SyncCompleteEvent
attr_reader :family, :accounts
def initialize(family, accounts: [])
@family = family
@accounts = accounts
end
def broadcast
account_groups = family.balance_sheet.account_groups.select do |group|
group.accounts.any? { |a| accounts.include?(a) }
end
account_groups.each do |account_group|
[ nil, "asset", "liability" ].each do |classification|
id = classification ? "#{classification}_#{account_group.id}" : account_group.id
family.broadcast_replace(
target: id,
partial: "accounts/accountable_group",
locals: { account_group: account_group, open: true }
)
end
end
family.broadcast_replace(
target: "balance-sheet",
partial: "pages/dashboard/balance_sheet",
locals: { balance_sheet: family.balance_sheet }
)
family.broadcast_replace(
target: "net-worth-chart",
partial: "pages/dashboard/net_worth_chart",
locals: { balance_sheet: family.balance_sheet, period: Period.last_30_days }
)
end
end

View file

@ -1,4 +1,4 @@
<%# locals: (family:, active_account_group_tab: "asset") %>
<%# locals: (family:, active_tab:, mobile: false) %>
<div id="account-sidebar-tabs">
<% if family.missing_data_provider? %>
@ -21,7 +21,7 @@
</details>
<% end %>
<%= render TabsComponent.new(active_tab: active_account_group_tab, session_key: "account_group_tab", testid: "account-sidebar-tabs") do |tabs| %>
<%= render TabsComponent.new(active_tab: active_tab, session_key: "account_sidebar_tab", testid: "account-sidebar-tabs") do |tabs| %>
<% tabs.with_nav do |nav| %>
<% nav.with_btn(id: "asset", label: "Assets") %>
<% nav.with_btn(id: "liability", label: "Debts") %>
@ -42,7 +42,7 @@
<div>
<% family.balance_sheet.account_groups("asset").each do |group| %>
<%= render "accounts/accountable_group", account_group: group %>
<%= render "accounts/accountable_group", account_group: group, mobile: mobile %>
<% end %>
</div>
</div>
@ -62,7 +62,7 @@
<div>
<% family.balance_sheet.account_groups("liability").each do |group| %>
<%= render "accounts/accountable_group", account_group: group %>
<%= render "accounts/accountable_group", account_group: group, mobile: mobile %>
<% end %>
</div>
</div>
@ -82,7 +82,7 @@
<div>
<% family.balance_sheet.account_groups.each do |group| %>
<%= render "accounts/accountable_group", account_group: group %>
<%= render "accounts/accountable_group", account_group: group, mobile: mobile %>
<% end %>
</div>
</div>

View file

@ -1,67 +1,69 @@
<%# locals: (account_group:) %>
<%# locals: (account_group:, mobile: false, open: nil, **args) %>
<%= render DisclosureComponent.new(title: account_group.name, align: :left, open: account_group.accounts.any? { |account| page_active?(account_path(account)) }) do |disclosure| %>
<% disclosure.with_summary_content do %>
<div class="ml-auto text-right grow">
<% if account_group.syncing? %>
<div class="space-y-1">
<div class="h-5 w-24 rounded ml-auto bg-loader"></div>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>
</div>
<% else %>
<%= tag.p format_money(account_group.total_money), class: "text-sm font-medium text-primary" %>
<%= turbo_frame_tag "#{account_group.key}_sparkline", src: accountable_sparkline_path(account_group.key), loading: "lazy" do %>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
<div id="<%= mobile ? "mobile_#{account_group.id}" : account_group.id %>">
<% is_open = open.nil? ? account_group.accounts.any? { |account| page_active?(account_path(account)) } : open %>
<%= render DisclosureComponent.new(title: account_group.name, align: :left, open: is_open) do |disclosure| %>
<% disclosure.with_summary_content do %>
<div class="ml-auto text-right grow">
<% if account_group.syncing? %>
<div class="space-y-1">
<div class="h-5 w-24 rounded ml-auto bg-loader"></div>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>
</div>
<% else %>
<%= tag.p format_money(account_group.total_money), class: "text-sm font-medium text-primary" %>
<%= turbo_frame_tag "#{account_group.key}_sparkline", src: accountable_sparkline_path(account_group.key), loading: "lazy" do %>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>
<% end %>
<% end %>
<% end %>
</div>
<% end %>
</div>
<% end %>
<div class="space-y-1">
<% account_group.accounts.each do |account| %>
<%= link_to account_path(account),
<div class="space-y-1">
<% account_group.accounts.each do |account| %>
<%= link_to account_path(account),
class: class_names(
"block flex items-center gap-2 px-3 py-2 rounded-lg",
page_active?(account_path(account)) ? "bg-container" : "hover:bg-surface-hover"
),
title: account.name do %>
<%= render "accounts/logo", account: account, size: "sm", color: account_group.color %>
<%= render "accounts/logo", account: account, size: "sm", color: account_group.color %>
<div class="min-w-0 grow">
<%= tag.p account.name, class: "text-sm text-primary font-medium mb-0.5 truncate" %>
<%= tag.p account.short_subtype_label, class: "text-sm text-secondary truncate" %>
</div>
<div class="min-w-0 grow">
<%= tag.p account.name, class: "text-sm text-primary font-medium mb-0.5 truncate" %>
<%= tag.p account.short_subtype_label, class: "text-sm text-secondary truncate" %>
</div>
<% if account.syncing? %>
<div class="ml-auto text-right grow h-10">
<div class="space-y-1">
<div class="h-5 w-24 bg-loader rounded ml-auto"></div>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
<% if account.syncing? %>
<div class="ml-auto text-right grow h-10">
<div class="space-y-1">
<div class="h-5 w-24 bg-loader rounded ml-auto"></div>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>
</div>
</div>
</div>
<% else %>
<div class="ml-auto text-right grow h-10">
<%= tag.p format_money(account.balance_money), class: "text-sm font-medium text-primary whitespace-nowrap" %>
<% else %>
<div class="ml-auto text-right grow h-10">
<%= tag.p format_money(account.balance_money), class: "text-sm font-medium text-primary whitespace-nowrap" %>
<%= turbo_frame_tag dom_id(account, :sparkline), src: sparkline_account_path(account), loading: "lazy" do %>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>
<% end %>
</div>
<%= turbo_frame_tag dom_id(account, :sparkline), src: sparkline_account_path(account), loading: "lazy" do %>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>
<% end %>
</div>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
</div>
<div class="my-2">
<%= render LinkComponent.new(
<div class="my-2">
<%= render LinkComponent.new(
href: new_polymorphic_path(account_group.key, step: "method_select"),
text: "New #{account_group.name.downcase.singularize}",
icon: "plus",
@ -70,5 +72,6 @@
frame: :modal,
class: "justify-start"
) %>
</div>
<% end %>
</div>
<% end %>
</div>

View file

@ -1,4 +1,4 @@
<%# locals: (account:, title: nil, tooltip: nil, chart_view: nil, **args) %>
<%# locals: (account:, tooltip: nil, chart_view: nil, **args) %>
<% period = @period || Period.last_30_days %>
<% default_value_title = account.asset? ? t(".balance") : t(".owed") %>
@ -7,10 +7,10 @@
<div class="flex justify-between flex-col-reverse lg:flex-row gap-2 px-4 pt-4 mb-2">
<div class="space-y-2 w-full">
<div class="flex items-center gap-1">
<%= tag.p title || default_value_title, class: "text-sm font-medium text-secondary" %>
<%= tag.p account.investment? ? "Total value" : default_value_title, class: "text-sm font-medium text-secondary" %>
<% unless account.syncing? %>
<%= tooltip %>
<% if !account.syncing? && account.investment? %>
<%= render "investments/value_tooltip", balance: account.balance_money, holdings: account.balance_money - account.cash_balance_money, cash: account.cash_balance_money %>
<% end %>
</div>

View file

@ -1,4 +1,4 @@
<%# locals: (account:, header: nil, chart: nil, tabs: nil) %>
<%# locals: (account:, header: nil, chart: nil, chart_view: nil, tabs: nil) %>
<%= turbo_stream_from account %>
@ -13,7 +13,7 @@
<% if chart.present? %>
<%= chart %>
<% else %>
<%= render "accounts/show/chart", account: account %>
<%= render "accounts/show/chart", account: account, chart_view: chart_view %>
<% end %>
<div class="min-h-[800px]" data-testid="account-details">

View file

@ -1,25 +1,7 @@
<%= turbo_stream_from @account %>
<%= turbo_frame_tag dom_id(@account) do %>
<%= tag.div class: "space-y-4" do %>
<%= render "accounts/show/header", account: @account %>
<%= render "accounts/show/chart",
account: @account,
title: t(".chart_title"),
chart_view: @chart_view,
tooltip: render(
"investments/value_tooltip",
balance: @account.balance_money,
holdings: @account.balance_money - @account.cash_balance_money,
cash: @account.cash_balance_money
) %>
<div class="min-h-[800px]">
<%= render "accounts/show/tabs", account: @account, tabs: [
{ key: "activity", contents: render("accounts/show/activity", account: @account) },
{ key: "holdings", contents: render("investments/holdings_tab", account: @account) },
] %>
</div>
<% end %>
<% end %>
<%= render "accounts/show/template",
account: @account,
chart_view: @chart_view,
tabs: render("accounts/show/tabs", account: @account, tabs: [
{ key: "activity", contents: render("accounts/show/activity", account: @account) },
{ key: "holdings", contents: render("investments/holdings_tab", account: @account) },
]) %>

View file

@ -26,7 +26,8 @@
<%= render(
"accounts/account_sidebar_tabs",
family: Current.family,
active_account_group_tab: @account_group_tab
active_tab: @account_group_tab,
mobile: true
) %>
</div>
@ -81,7 +82,7 @@
<% else %>
<div class="h-full flex flex-col">
<div class="overflow-y-auto grow">
<%= render "accounts/account_sidebar_tabs", family: Current.family, active_account_group_tab: @account_group_tab %>
<%= render "accounts/account_sidebar_tabs", family: Current.family, active_tab: @account_group_tab %>
</div>
<% if Current.family.trialing? && !self_hosted? %>

View file

@ -1,6 +1,6 @@
<%# locals: (balance_sheet:) %>
<%# locals: (balance_sheet:, **args) %>
<div class="space-y-4">
<div class="space-y-4" id="balance-sheet">
<% balance_sheet.classification_groups.each do |classification_group| %>
<div class="bg-container shadow-border-xs rounded-xl space-y-4 p-4">
<h2 class="text-lg font-medium inline-flex items-center gap-1.5">

View file

@ -1,54 +1,55 @@
<%# locals: (balance_sheet:, period:) %>
<%# locals: (balance_sheet:, period:, **args) %>
<% series = balance_sheet.net_worth_series(period: period) %>
<div class="flex justify-between gap-4 px-4">
<div class="space-y-2">
<div id="net-worth-chart">
<% series = balance_sheet.net_worth_series(period: period) %>
<div class="flex justify-between gap-4 px-4">
<div class="space-y-2">
<p class="text-sm text-secondary font-medium"><%= t(".title") %></p>
<div class="space-y-2">
<p class="text-sm text-secondary font-medium"><%= t(".title") %></p>
<% if balance_sheet.syncing? %>
<div class="flex flex-col gap-2">
<div class="bg-loader rounded-md h-7 w-20"></div>
<div class="bg-loader rounded-md h-5 w-32"></div>
</div>
<% else %>
<p class="text-primary -space-x-0.5 text-3xl font-medium">
<%= series.current.format %>
</p>
<% if series.trend.nil? %>
<p class="text-sm text-secondary"><%= t(".data_not_available") %></p>
<% if balance_sheet.syncing? %>
<div class="flex flex-col gap-2">
<div class="bg-loader rounded-md h-7 w-20"></div>
<div class="bg-loader rounded-md h-5 w-32"></div>
</div>
<% else %>
<%= render partial: "shared/trend_change", locals: { trend: series.trend, comparison_label: period.comparison_label } %>
<% end %>
<% end %>
</div>
</div>
<p class="text-primary -space-x-0.5 text-3xl font-medium">
<%= series.current.format %>
</p>
<%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form" } do |form| %>
<%= form.select :period,
<% if series.trend.nil? %>
<p class="text-sm text-secondary"><%= t(".data_not_available") %></p>
<% else %>
<%= render partial: "shared/trend_change", locals: { trend: series.trend, comparison_label: period.comparison_label } %>
<% end %>
<% end %>
</div>
</div>
<%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form" } do |form| %>
<%= form.select :period,
Period.as_options,
{ selected: period.key },
data: { "auto-submit-form-target": "auto" },
class: "bg-container border border-secondary font-medium rounded-lg px-3 py-2 text-sm pr-7 cursor-pointer text-primary focus:outline-hidden focus:ring-0" %>
<% end %>
</div>
<% if balance_sheet.syncing? %>
<div class="w-full flex items-center justify-center p-4 h-52">
<div class="bg-loader rounded-md h-full w-full"></div>
<% end %>
</div>
<% else %>
<% if series.any? %>
<div
<% if balance_sheet.syncing? %>
<div class="w-full flex items-center justify-center p-4 h-52">
<div class="bg-loader rounded-md h-full w-full"></div>
</div>
<% else %>
<% if series.any? %>
<div
id="netWorthChart"
class="w-full flex-1 min-h-52"
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= series.to_json %>"></div>
<% else %>
<div class="w-full h-full flex items-center justify-center">
<p class="text-secondary text-sm"><%= t(".data_not_available") %></p>
</div>
<% else %>
<div class="w-full h-full flex items-center justify-center">
<p class="text-secondary text-sm"><%= t(".data_not_available") %></p>
</div>
<% end %>
<% end %>
<% end %>
</div>

View file

@ -26,7 +26,7 @@ Rails.application.routes.draw do
get "changelog", to: "pages#changelog"
get "feedback", to: "pages#feedback"
resource :cookie_session, only: %i[update]
resource :current_session, only: %i[update]
resource :registration, only: %i[new create]
resources :sessions, only: %i[new create destroy]

View file

@ -0,0 +1,5 @@
class AddMetadataToSession < ActiveRecord::Migration[7.2]
def change
add_column :sessions, :data, :jsonb, default: {}
end
end

3
db/schema.rb generated
View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_05_13_122703) do
ActiveRecord::Schema[7.2].define(version: 2025_05_14_214242) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
@ -537,6 +537,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_05_13_122703) do
t.uuid "active_impersonator_session_id"
t.datetime "subscribed_at"
t.jsonb "prev_transaction_page_params", default: {}
t.jsonb "data", default: {}
t.index ["active_impersonator_session_id"], name: "index_sessions_on_active_impersonator_session_id"
t.index ["user_id"], name: "index_sessions_on_user_id"
end

View file

@ -0,0 +1,15 @@
require "test_helper"
class CurrentSessionsControllerTest < ActionDispatch::IntegrationTest
setup do
@user = users(:family_admin)
sign_in @user
end
test "can update the preferred tab for any namespace" do
put current_session_url, params: { current_session: { tab_key: "accounts_sidebar_tab", tab_value: "asset" } }
assert_response :success
session = Session.order(updated_at: :desc).first
assert_equal "asset", session.get_preferred_tab("accounts_sidebar_tab")
end
end