Browse Source

Fixes #5353 - Apollo client returns an error about exceeding max complexity of the query

Co-authored-by: Dominik Klein <dk@zammad.com>
Martin Gruner 5 months ago
parent
commit
a363b68cc1

+ 16 - 0
app/frontend/apps/mobile/pages/ticket/__tests__/ticket-detail-view.spec.ts

@@ -1013,6 +1013,21 @@ it('correctly redirects from ticket hash-based routes', async () => {
 it('correctly redirects from ticket hash-based routes with other ids', async () => {
   const { waitUntilTicketLoaded } = mockTicketDetailViewGql({
     ticketView: 'agent',
+    articles: [
+      defaultArticles(),
+      {
+        articles: {
+          edges: [],
+          pageInfo: {
+            endCursor: null,
+            startCursor: null,
+            hasPreviousPage: false,
+            __typename: 'PageInfo',
+          },
+          totalCount: 5,
+        },
+      },
+    ],
   })
 
   await visitView('/#ticket/zoom/1/20')
@@ -1022,6 +1037,7 @@ it('correctly redirects from ticket hash-based routes with other ids', async ()
   const route = router.currentRoute.value
 
   expect(route.name).toBe('TicketDetailArticlesView')
+
   expect(route.params).toEqual({ internalId: '1' })
 })
 

+ 5 - 0
app/frontend/apps/mobile/pages/ticket/views/TicketDetailArticlesView.vue

@@ -226,9 +226,14 @@ const initialScroll = async () => {
 const stopScrollWatch = watch(
   () => articles.value.length,
   async () => {
+    // Do nothing for initial article computed value, because this is initialy an empty error, when
+    // nothing is used from the cache.
+    if (articles.value.length === 0) return
+
     if (hasScroll() && !isAtTheBottom()) {
       scrollDownState.value = true
     }
+
     const scrolled = await initialScroll()
     if (scrolled) stopScrollWatch()
   },