2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00

Notification cleanup (#8945)

- Prevent spamming of duplicate notifications
This commit is contained in:
Oliver 2025-01-26 07:18:38 +11:00 committed by GitHub
parent 94a0e11702
commit ab7e6385c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View File

@ -18,7 +18,7 @@ import {
} from '@tabler/icons-react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { showNotification } from '@mantine/notifications';
import { hideNotification, showNotification } from '@mantine/notifications';
import { api } from '../../App';
import { BarcodeInput } from '../../components/barcodes/BarcodeInput';
import type { BarcodeScanItem } from '../../components/barcodes/BarcodeScanItem';
@ -55,7 +55,10 @@ export default function Scan() {
// Prevent duplicates
if (history.find((i) => i.model == item.model && i.pk == item.pk)) {
hideNotification('duplicate-barcode');
showNotification({
id: 'duplicate-barcode',
title: t`Duplicate`,
message: t`Item already scanned`,
color: 'orange'

View File

@ -1,7 +1,7 @@
import { create } from 'zustand';
import { t } from '@lingui/macro';
import { showNotification } from '@mantine/notifications';
import { hideNotification, showNotification } from '@mantine/notifications';
import { api } from '../App';
import { ApiEndpoints } from '../enums/ApiEndpoints';
import { generateUrl } from '../functions/urls';
@ -38,7 +38,11 @@ export const useIconState = create<IconState>()((set, get) => ({
const packs = await api.get(apiUrl(ApiEndpoints.icons)).catch((_error) => {
console.error('ERR: Could not fetch icon packages');
hideNotification('icon-fetch-error');
showNotification({
id: 'icon-fetch-error',
title: t`Error`,
message: t`Error loading icon package from server`,
color: 'red'
@ -66,7 +70,9 @@ export const useIconState = create<IconState>()((set, get) => ({
console.error(
"ERR: Icon package is missing 'prefix' or 'fonts' field"
);
hideNotification('icon-fetch-error');
showNotification({
id: 'icon-fetch-error',
title: t`Error`,
message: t`Error loading icon package from server`,
color: 'red'

View File

@ -12,7 +12,7 @@ import type React from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { showNotification } from '@mantine/notifications';
import { hideNotification, showNotification } from '@mantine/notifications';
import { Boundary } from '../components/Boundary';
import type { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
import { useApi } from '../contexts/ApiContext';
@ -207,7 +207,9 @@ export function InvenTreeTable<T extends Record<string, any>>({
return null;
})
.catch(() => {
hideNotification('table-options-error');
showNotification({
id: 'table-options-error',
title: t`API Error`,
message: t`Failed to load table options`,
color: 'red'