diff --git a/internal/control/home_subscription_accounts.go b/internal/control/home_subscription_accounts.go index 975aa87c..c7aedaa3 100644 --- a/internal/control/home_subscription_accounts.go +++ b/internal/control/home_subscription_accounts.go @@ -17,9 +17,8 @@ import ( ) const ( - homeSubscriptionAccountLimit = 4 - homeSubscriptionAccountWindow = 24 * time.Hour - homeSubscriptionAccountCacheTTL = time.Minute + homeSubscriptionAccountLimit = 4 + homeSubscriptionAccountWindow = 24 * time.Hour ) type HomeSubscriptionAccountsResponse struct { @@ -37,11 +36,6 @@ type HomeSubscriptionAccountResponse struct { Credential CredentialItemResponse `json:"credential"` } -type homeSubscriptionAccountsCache struct { - expiresAt time.Time - response HomeSubscriptionAccountsResponse -} - type homeSubscriptionActivityRow struct { IdentityFingerprint string `gorm:"column:identity_fingerprint"` ChannelID string `gorm:"column:channel_id"` @@ -75,25 +69,7 @@ func (s *Service) ReadHomeSubscriptionAccounts( if err := ctx.Err(); err != nil { return HomeSubscriptionAccountsResponse{}, err } - s.homeSubscriptionMu.Lock() - defer s.homeSubscriptionMu.Unlock() - if err := ctx.Err(); err != nil { - return HomeSubscriptionAccountsResponse{}, err - } - now := s.now().UTC() - if cached := s.homeSubscriptionCache; cached != nil && now.Before(cached.expiresAt) { - return cloneHomeSubscriptionAccountsResponse(cached.response), nil - } - - response, err := s.readHomeSubscriptionAccounts(ctx, now) - if err != nil { - return HomeSubscriptionAccountsResponse{}, err - } - s.homeSubscriptionCache = &homeSubscriptionAccountsCache{ - expiresAt: now.Add(homeSubscriptionAccountCacheTTL), - response: cloneHomeSubscriptionAccountsResponse(response), - } - return response, nil + return s.readHomeSubscriptionAccounts(ctx, s.now().UTC()) } func (s *Server) handleHomeSubscriptionAccounts(c *gin.Context) { @@ -367,10 +343,3 @@ func homeSubscriptionRepresentativeLess( func homeSubscriptionIdentityKey(channelID, identityFingerprint string) string { return channelID + "\x00" + identityFingerprint } - -func cloneHomeSubscriptionAccountsResponse( - value HomeSubscriptionAccountsResponse, -) HomeSubscriptionAccountsResponse { - value.Items = append([]HomeSubscriptionAccountResponse(nil), value.Items...) - return value -} diff --git a/internal/control/home_subscription_accounts_test.go b/internal/control/home_subscription_accounts_test.go index e7c95537..6e8d7094 100644 --- a/internal/control/home_subscription_accounts_test.go +++ b/internal/control/home_subscription_accounts_test.go @@ -99,7 +99,7 @@ func TestReadHomeSubscriptionAccountsUsesBoundedHourlyActivityAndDeduplicates(t } } -func TestReadHomeSubscriptionAccountsCachesRankingForOneMinute(t *testing.T) { +func TestReadHomeSubscriptionAccountsReflectsLatestRankingOnEveryRead(t *testing.T) { t.Parallel() fixture := newServiceFixture(t) now := time.Date(2026, time.August, 31, 12, 30, 0, 0, time.UTC) @@ -124,14 +124,9 @@ func TestReadHomeSubscriptionAccountsCachesRankingForOneMinute(t *testing.T) { t.Fatal(err) } - cached, err := fixture.service.ReadHomeSubscriptionAccounts(t.Context()) - if err != nil || cached.Items[0].Credential.Account.Email != "first@example.com" { - t.Fatalf("cached read = %#v, %v", cached, err) - } - now = now.Add(time.Minute) - refreshed, err := fixture.service.ReadHomeSubscriptionAccounts(t.Context()) - if err != nil || refreshed.Items[0].Credential.Account.Email != "second@example.com" { - t.Fatalf("refreshed read = %#v, %v", refreshed, err) + latest, err := fixture.service.ReadHomeSubscriptionAccounts(t.Context()) + if err != nil || latest.Items[0].Credential.Account.Email != "second@example.com" { + t.Fatalf("latest read = %#v, %v", latest, err) } } diff --git a/internal/control/service.go b/internal/control/service.go index 3eca94e2..0ec71860 100644 --- a/internal/control/service.go +++ b/internal/control/service.go @@ -88,8 +88,6 @@ type Service struct { observationMu sync.Mutex observationFlights map[observationFlightKey]*observationFlight observationSemaphore chan struct{} - homeSubscriptionMu sync.Mutex - homeSubscriptionCache *homeSubscriptionAccountsCache } type credentialRuntimeRetirer interface { diff --git a/web/src/app/resources/home.ts b/web/src/app/resources/home.ts index f212b438..dfc701fe 100644 --- a/web/src/app/resources/home.ts +++ b/web/src/app/resources/home.ts @@ -663,7 +663,6 @@ export function homeSubscriptionAccountsQueryOptions( queryKey: controlQueryKeys.home.subscriptionAccounts(), queryFn: ({ signal }) => getHomeSubscriptionAccounts(client, signal), enabled: computed(() => toValue(enabled)), - staleTime: 60_000, refetchOnMount: 'always', }) } diff --git a/web/src/features/home/HomeSubscriptionAccounts.vue b/web/src/features/home/HomeSubscriptionAccounts.vue index 719ff2d5..d8205292 100644 --- a/web/src/features/home/HomeSubscriptionAccounts.vue +++ b/web/src/features/home/HomeSubscriptionAccounts.vue @@ -53,6 +53,9 @@ function ignoreReadonlyProxyMutation(): Promise { .home-subscription-accounts { display: grid; gap: var(--space-3); + margin-top: 36px; + border-top: 1px solid var(--color-border-subtle); + padding-top: 20px; } .home-subscription-accounts__grid {