MCPcopy Index your code
hub / github.com/Dispatcharr/Dispatcharr / queryChannels

Method queryChannels

frontend/src/api.js:347–386  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

345 }
346
347 static async queryChannels(params) {
348 try {
349 API.lastQueryParams = params;
350
351 const response = await request(
352 `${host}/api/channels/channels/?${params.toString()}`
353 );
354
355 useChannelsTableStore.getState().queryChannels(response, params);
356
357 return response;
358 } catch (e) {
359 // Handle invalid page error by resetting to page 1 and retrying
360 if (e.body?.detail === 'Invalid page.') {
361 const currentPagination = useChannelsTableStore.getState().pagination;
362
363 // Only retry if we're not already on page 1
364 if (currentPagination.pageIndex > 0) {
365 // Reset to page 1
366 useChannelsTableStore.getState().setPagination({
367 ...currentPagination,
368 pageIndex: 0,
369 });
370
371 // Update params to page 1 and retry
372 const newParams = new URLSearchParams(params);
373 newParams.set('page', '1');
374
375 const response = await request(
376 `${host}/api/channels/channels/?${newParams.toString()}`
377 );
378
379 useChannelsTableStore.getState().queryChannels(response, newParams);
380 return response;
381 }
382 }
383
384 errorNotification('Failed to fetch channels', e);
385 }
386 }
387
388 /**
389 * Retrieve channels matching the provided query params, paging until complete.

Callers 3

requeryChannelsMethod · 0.80
ChannelsTableFunction · 0.80

Calls 3

requestFunction · 0.85
errorNotificationFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected