:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(conversations): stop the unread counter loading the tickets scene logic (#126955)
Paul D'Ambra92319f7f3aaf
diff --git a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.ts b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.tsindex 527c28146f38..a82c698fedfe 100644--- a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.ts+++ b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.ts@@ -12,6 +12,7 @@ import { initKeaTests } from '~/test/init'import { AccessControlLevel } from '~/types'import { MAX_ASSIGNEE_FILTER_ENTRIES, assigneeSelectLogic } from '../../components/Assignee'+import { supportTicketCounterLogic } from '../../supportTicketCounterLogic'import { normalizeAssigneeFilter, type SavedTicketView, type Ticket, type TicketViewFilters } from '../../types'import { supportTicketsSceneLogic } from './supportTicketsSceneLogic'@@ -135,6 +136,46 @@ describe('supportTicketsSceneLogic', () => {})})+ describe('unread count changes', () => {+ let logic: ReturnType<typeof supportTicketsSceneLogic.build>+ let counter: ReturnType<typeof supportTicketCounterLogic.build>+ let ticketRequests = 0++ beforeEach(async () => {+ ticketRequests = 0+ useMocks({+ get: {+ '/api/projects/:team_id/conversations/tickets/': () => {+ ticketRequests+++ return [200, { results: [], count: 0 }]+ },+ },+ })+ initKeaTests()+ counter = supportTicketCounterLogic()+ counter.mount()+ logic = supportTicketsSceneLogic()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ })++ afterEach(() => {+ logic.unmount()+ counter.unmount()+ })++ it.each([+ ['reloads the list when the count changes', 2, 1],+ ['keeps the list when the count stays the same', 0, 0],+ ])('%s', async (_, newCount, extraRequests) => {+ const before = ticketRequests+ await expectLogic(logic, () => {+ counter.actions.loadUnreadCountSuccess(newCount)+ }).toFinishAllListeners()+ expect(ticketRequests - before).toBe(extraRequests)+ })+ })+describe('assignee filter param', () => {let logic: ReturnType<typeof supportTicketsSceneLogic.build>let lastAssigneeParam: string | null = nulldiff --git a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.tsindex 6498c6ddae05..8a8a5340d824 100644--- a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts+++ b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts@@ -13,6 +13,7 @@ import {selectors,} from 'kea'import { actionToUrl, router, urlToAction } from 'kea-router'+import { subscriptions } from 'kea-subscriptions'import { lemonToast } from '@posthog/lemon-ui'@@ -28,6 +29,7 @@ import { AccessControlLevel, AccessControlResourceType, Breadcrumb, TeamType } fimport { assigneeSelectLogic } from '../../components/Assignee'import { conversationsTicketsBulkUpdateStatusCreate, conversationsViewsRetrieve } from '../../generated/api'import type { AiTriageResultEnumApi } from '../../generated/api.schemas'+import { supportTicketCounterLogic } from '../../supportTicketCounterLogic'import { normalizeAssigneeFilter } from '../../types'import type {AITriageFilterValue,@@ -199,6 +201,7 @@ export interface SupportTicketsSceneLogicProps {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface supportTicketsSceneLogicValues {+ unreadCount: number // supportTicketCounterLogicactiveView: SavedTicketView | nullaiEnabled: booleanaiTriageResultFilter: AITriageFilterValue[]@@ -394,6 +397,7 @@ export const supportTicketsSceneLogic = kea<supportTicketsSceneLogicType>([props({} as SupportTicketsSceneLogicProps),key((props: SupportTicketsSceneLogicProps) => props?.key || 'SupportTicketsScene'),connect(() => ({+ values: [supportTicketCounterLogic, ['unreadCount']],actions: [assigneeSelectLogic, ['ensureAssigneeTypesLoaded']],})),actions({@@ -1025,6 +1029,14 @@ export const supportTicketsSceneLogic = kea<supportTicketsSceneLogicType>([}},})),+ subscriptions(({ actions, props }) => ({+ unreadCount: (unreadCount: number, oldUnreadCount: number | undefined) => {+ const embedded = !!props.distinctIds?.length+ if (!embedded && oldUnreadCount !== undefined && unreadCount !== oldUnreadCount) {+ actions.loadTickets()+ }+ },+ })),afterMount(({ actions, values, props }) => {// The assignee column and the filter pills turn a user id into a name with the// organization member list, and nothing else on this page loads it.diff --git a/products/conversations/frontend/supportTicketCounterLogic.ts b/products/conversations/frontend/supportTicketCounterLogic.tsindex 14868f149839..220147008cd3 100644--- a/products/conversations/frontend/supportTicketCounterLogic.ts+++ b/products/conversations/frontend/supportTicketCounterLogic.ts@@ -7,7 +7,6 @@ import { teamLogic } from 'scenes/teamLogic'import type { TeamPublicType, TeamType } from '../../../frontend/src/types'import { browserNotificationLogic } from './browserNotificationLogic'-import { supportTicketsSceneLogic } from './scenes/tickets/supportTicketsSceneLogic'const POLL_INTERVAL = 5 * 1000 // 5 seconds - backend is cached so frequent polling is cheap@@ -203,14 +202,10 @@ export const supportTicketCounterLogic = kea<supportTicketCounterLogicType>([actions.loadUnreadCount()}},- // Notify tickets scene when unread count changesunreadCount: (unreadCount, oldUnreadCount) => {if (oldUnreadCount === undefined) {return}- if (unreadCount !== oldUnreadCount) {- supportTicketsSceneLogic.findMounted()?.actions.loadTickets()- }if (unreadCount > oldUnreadCount && values.canShowNotifications) {actions.showNotification(unreadCount)}