Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,14 +32,28 @@ 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])
}

const isFavourite = (contact: ContactType) => {
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) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down