diff --git a/package-lock.json b/package-lock.json index 6c8afb31..595f83cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.17.4", + "@nethesis/phone-island": "^0.17.7", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", @@ -5573,9 +5573,9 @@ } }, "node_modules/@nethesis/phone-island": { - "version": "0.17.4", - "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.17.4.tgz", - "integrity": "sha512-3QRVzxyXEcPQIljI2vnO3VrYE+J5sM9Tz9iInna9ciKfLUGnBJWaj8K1towNhrfLbf/OAGlSwZeQE/Z1OGVGLA==", + "version": "0.17.7", + "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.17.7.tgz", + "integrity": "sha512-rPGR2YM972uw3wPffUrPsuBa1GTPShbLqQPsesGtB5VmGpcmJeqlilXxkgq9QFA78ob7w6jVR5v9ywdXKrTcog==", "dev": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index e5ecc1db..b16167c1 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.17.4", + "@nethesis/phone-island": "^0.17.7", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", diff --git a/src/renderer/src/components/Modules/NethVoice/Speeddials/hook/useFavouriteModule.ts b/src/renderer/src/components/Modules/NethVoice/Speeddials/hook/useFavouriteModule.ts index 9cdf89ef..3c94c4e5 100644 --- a/src/renderer/src/components/Modules/NethVoice/Speeddials/hook/useFavouriteModule.ts +++ b/src/renderer/src/components/Modules/NethVoice/Speeddials/hook/useFavouriteModule.ts @@ -13,7 +13,7 @@ export const useFavouriteModule = () => { const { NethVoiceAPI } = useLoggedNethVoiceAPI() useEffect(() => { rawSpeedDials && filterFavourites(rawSpeedDials, speeddialsModule?.favouriteOrder || FilterTypes.AZ) - }, [rawSpeedDials, speeddialsModule?.favouriteOrder]) + }, [rawSpeedDials, speeddialsModule?.favouriteOrder, operators]) const getSorter = (order: FilterTypes) => { let sorter: ((a: ContactType, b: ContactType) => number) | undefined = undefined @@ -32,7 +32,10 @@ export const useFavouriteModule = () => { } const filterFavourites = (rawSpeeddials: ContactType[], order: FilterTypes) => { - const favourites = rawSpeeddials.filter(isFavourite).sort(getSorter(order)) + const favourites = rawSpeeddials + .filter(isFavourite) + .filter(isActiveOperator) + .sort(getSorter(order)) setFavourites(() => [...favourites]) } @@ -40,6 +43,17 @@ export const useFavouriteModule = () => { return contact.notes?.includes(SpeeddialTypes.FAVOURITES) } + const isActiveOperator = (contact: ContactType) => { + // If no operators data or no contact name, don't show the favorite + if (!operators?.groups || !contact.name) { + return false + } + // Check if the contact's username exists in any operator group + return Object.values(operators.groups).some(group => + group.users.includes(contact.name!) + ) + } + const isSearchAlsoAFavourite = (contact: SearchData) => { const foundedContact = favourites?.find((s) => s.speeddial_num === (contact.speeddial_num || contact.extension)) if (foundedContact) { diff --git a/src/shared/types.ts b/src/shared/types.ts index 7526e222..b5976873 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -5,7 +5,7 @@ export type AvailableDevices = 'nethlink' | 'physical' | 'webrtc' export enum PAGES { SPLASHSCREEN = "splashscreenpage", - LOGIN = "NethLink-Login", + LOGIN = "Login", PHONEISLAND = "phoneislandpage", NETHLINK = "NethLink", DEVTOOLS = "devtoolspage"