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

Method requeryChannels

frontend/src/api.js:426–473  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

424 }
425
426 static async requeryChannels() {
427 try {
428 const [response, ids] = await Promise.all([
429 request(
430 `${host}/api/channels/channels/?${API.lastQueryParams.toString()}`
431 ),
432 API.getAllChannelIds(API.lastQueryParams),
433 ]);
434
435 useChannelsTableStore
436 .getState()
437 .queryChannels(response, API.lastQueryParams);
438 useChannelsTableStore.getState().setAllQueryIds(ids);
439
440 return response;
441 } catch (e) {
442 // Handle invalid page error by resetting to page 1 and retrying
443 if (e.body?.detail === 'Invalid page.') {
444 const currentPagination = useChannelsTableStore.getState().pagination;
445
446 // Only retry if we're not already on page 1
447 if (currentPagination.pageIndex > 0) {
448 // Reset to page 1
449 useChannelsTableStore.getState().setPagination({
450 ...currentPagination,
451 pageIndex: 0,
452 });
453
454 // Update params to page 1 and retry
455 const newParams = new URLSearchParams(API.lastQueryParams);
456 newParams.set('page', '1');
457 API.lastQueryParams = newParams;
458
459 const [response, ids] = await Promise.all([
460 request(`${host}/api/channels/channels/?${newParams.toString()}`),
461 API.getAllChannelIds(newParams),
462 ]);
463
464 useChannelsTableStore.getState().queryChannels(response, newParams);
465 useChannelsTableStore.getState().setAllQueryIds(ids);
466
467 return response;
468 }
469 }
470
471 errorNotification('Failed to fetch channels', e);
472 }
473 }
474
475 static async getAllChannelIds(params = new URLSearchParams()) {
476 try {

Callers 13

batchSetEPGMethod · 0.95
WebsocketProviderFunction · 0.80
reorderChannelStreamsMethod · 0.80
addStreamsToChannelMethod · 0.80
executeDeleteChannelFunction · 0.80
executeDeleteChannelsFunction · 0.80
handleDragEndFunction · 0.80
assignChannelsFunction · 0.80
EditableNumberCellInnerFunction · 0.80
requeryChannelsFunction · 0.80

Calls 5

requestFunction · 0.85
errorNotificationFunction · 0.85
getAllChannelIdsMethod · 0.80
queryChannelsMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected