Extracted notification util

This commit is contained in:
Nick Sandstrom 2025-12-24 22:41:51 -08:00
parent 61247a452a
commit ca96adf781
3 changed files with 12 additions and 7 deletions

View file

@ -1,9 +1,9 @@
import React from 'react';
import { Modal, Stack, Text, Flex, Group, Button } from '@mantine/core';
import { notifications } from '@mantine/notifications';
import useChannelsStore from '../../store/channels.jsx';
import { deleteSeriesAndRule } from '../../utils/cards/RecordingCardUtils.js';
import { evaluateSeriesRulesByTvgId, fetchRules } from '../../pages/guideUtils.js';
import { showNotification } from '../../utils/notificationUtils.js';
export default function SeriesRecordingModal({
opened,
@ -18,7 +18,7 @@ export default function SeriesRecordingModal({
} catch (error) {
console.warn('Failed to refresh recordings after evaluation', error);
}
notifications.show({
showNotification({
title: 'Evaluated',
message: 'Checked for episodes',
});

View file

@ -9,7 +9,6 @@ import React, {
import useChannelsStore from '../store/channels';
import useLogosStore from '../store/logos';
import useVideoStore from '../store/useVideoStore'; // NEW import
import { notifications } from '@mantine/notifications';
import useSettingsStore from '../store/settings';
import {
ActionIcon,
@ -80,6 +79,7 @@ import GuideRow from '../components/GuideRow.jsx';
import HourTimeline from '../components/HourTimeline';
import ProgramRecordingModal from '../components/forms/ProgramRecordingModal';
import SeriesRecordingModal from '../components/forms/SeriesRecordingModal';
import { showNotification } from '../utils/notificationUtils.js';
export default function TVChannelGuide({ startDate, endDate }) {
const channels = useChannelsStore((s) => s.channels);
@ -130,7 +130,7 @@ export default function TVChannelGuide({ startDate, endDate }) {
useEffect(() => {
if (Object.keys(channels).length === 0) {
console.warn('No channels provided or empty channels array');
notifications.show({ title: 'No channels available', color: 'red.5' });
showNotification({ title: 'No channels available', color: 'red.5' });
return;
}
@ -522,7 +522,7 @@ export default function TVChannelGuide({ startDate, endDate }) {
async (program) => {
const channel = findChannelByTvgId(program.tvg_id);
if (!channel) {
notifications.show({
showNotification({
title: 'Unable to schedule recording',
message: 'No channel found for this program.',
color: 'red.6',
@ -531,7 +531,7 @@ export default function TVChannelGuide({ startDate, endDate }) {
}
await createRecording(channel, program);
notifications.show({ title: 'Recording scheduled' });
showNotification({ title: 'Recording scheduled' });
},
[findChannelByTvgId]
);
@ -547,7 +547,7 @@ export default function TVChannelGuide({ startDate, endDate }) {
error
);
}
notifications.show({
showNotification({
title: mode === 'new' ? 'Record new episodes' : 'Record all episodes',
});
}, []);

View file

@ -0,0 +1,5 @@
import { notifications } from '@mantine/notifications';
export function showNotification(notificationObject) {
notifications.show(notificationObject);
}