MCPcopy Index your code
hub / github.com/MALSync/MALSync / notificationCheck

Function notificationCheck

src/background/releaseProgressUtils.ts:303–349  ·  view source on GitHub ↗
(el, cProgress, nProgress, type)

Source from the content-addressed store, hash-verified

301}
302
303export async function notificationCheck(el, cProgress, nProgress, type) {
304 try {
305 if (
306 (type === 'anime' && !api.settings.get('progressNotificationsAnime')) ||
307 (type === 'manga' && !api.settings.get('progressNotificationsManga'))
308 ) {
309 return;
310 }
311 if (el && nProgress && nProgress) {
312 if (
313 cProgress.lastEp &&
314 typeof cProgress.lastEp.total !== 'undefined' &&
315 nProgress.lastEp &&
316 nProgress.lastEp.total &&
317 cProgress.lang === nProgress.lang &&
318 cProgress.type === nProgress.type
319 ) {
320 if (cProgress.lastEp.total < nProgress.lastEp.total) {
321 // Check if new ep is one higher than the watched one
322 if (el.watchedEp + 1 === nProgress.lastEp.total) {
323 let noti;
324 if (el.single) {
325 noti = {
326 title: el.title,
327 text: api.storage.lang(`syncPage_malObj_nextEp_${type}`, [nProgress.lastEp.total]),
328 sticky: api.settings.get('notificationsSticky'),
329 image: await el.single.getImage(),
330 url: el.single.getStreamingUrl() ? el.single.getStreamingUrl() : el.single.getUrl(),
331 };
332 } else {
333 noti = {
334 title: el.title,
335 text: api.storage.lang(`syncPage_malObj_nextEp_${type}`, [nProgress.lastEp.total]),
336 sticky: api.settings.get('notificationsSticky'),
337 image: el.image,
338 url: el.options && el.options.u ? el.options.u : el.url,
339 };
340 }
341 api.request.notification(noti);
342 }
343 }
344 }
345 }
346 } catch (e) {
347 con.error('Could not check notification Progress', e);
348 }
349}

Callers 2

multipleFunction · 0.90
singleFunction · 0.85

Calls 7

langMethod · 0.80
notificationMethod · 0.80
errorMethod · 0.80
getMethod · 0.65
getImageMethod · 0.45
getStreamingUrlMethod · 0.45
getUrlMethod · 0.45

Tested by

no test coverage detected