From ed53aee57f011b93b0005048f3b5ab2a9947edf5 Mon Sep 17 00:00:00 2001
From: therockerline <therockerline@gmail.com>
Date: Tue, 28 May 2024 12:05:23 +0200
Subject: [PATCH 1/2] fix quit logic

---
 src/main/classes/controllers/AccountController.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/classes/controllers/AccountController.ts b/src/main/classes/controllers/AccountController.ts
index 2c195363..4b2de968 100644
--- a/src/main/classes/controllers/AccountController.ts
+++ b/src/main/classes/controllers/AccountController.ts
@@ -90,8 +90,8 @@ export class AccountController {
     log('On logout account', account?.username, { isSoft })
     const API = NethVoiceAPI.api()
     try {
-      if (!isSoft)
-        await PhoneIslandController.instance.logout(account!)
+      //if (!isSoft)
+      await PhoneIslandController.instance.logout(account!)
       await API.Authentication.logout()
       log(`${account!.username} logout succesfully`)
     } catch (e) {

From c9ff47a07cd245feb2f873bd0a608450f0f2e68c Mon Sep 17 00:00:00 2001
From: therockerline <therockerline@gmail.com>
Date: Tue, 28 May 2024 12:39:42 +0200
Subject: [PATCH 2/2] fix call button logic and removed the ghost usere from
 search

---
 src/renderer/src/components/SearchNumberBox.tsx | 13 ++++++++-----
 src/renderer/src/pages/NethLinkPage.tsx         |  4 ++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/renderer/src/components/SearchNumberBox.tsx b/src/renderer/src/components/SearchNumberBox.tsx
index 69934a33..f0b7bd8d 100644
--- a/src/renderer/src/components/SearchNumberBox.tsx
+++ b/src/renderer/src/components/SearchNumberBox.tsx
@@ -122,8 +122,9 @@ export function SearchNumberBox({
         return as < bs ? -1 : as > bs ? 1 : 0
       }
     })
-    const mappedOperators: SearchData[] = filteredOperators.map((o) => {
-      const id = o?.endpoints?.['extension']?.[0]?.['id']
+    const getId = (o) => parseInt(o?.endpoints?.['extension']?.[0]?.['id']) || -1
+    const mappedOperators: SearchData[] = filteredOperators.filter((o) => getId(o) !== -1).map((o) => {
+      const id = getId(o)
       return {
         ...o,
         cellphone: o?.endpoints?.['cellphone']?.[0]?.['id'],
@@ -136,7 +137,7 @@ export function SearchNumberBox({
         homepostalcode: '',
         homeprovince: '',
         homestreet: '',
-        id: id ? parseInt(id) : -1,
+        id: id,
         notes: '',
         owner_id: '',
         source: '',
@@ -199,13 +200,15 @@ export function SearchNumberBox({
     setCanAddToPhonebook(() => _canAddInPhonebook)
   }
 
+  const isCallButtonEnabled = isCallsEnabled && getIsPhoneNumber(searchText) && searchText.length > 1
+
   return (
     <div className="flex flex-col dark:text-titleDark text-titleLight dark:bg-bgDark bg-bgLight">
       <div
-        className={`flex gap-5 pt-[10px] pr-8 pb-[10px] pl-7 min-h-9 items-start  ${isCallsEnabled && getIsPhoneNumber(searchText) ? 'cursor-pointer dark:hover:bg-hoverDark hover:bg-hoverLight' : 'dark:bg-hoverDark bg-hoverLight opacity-50 cursor-not-allowed'}`}
+        className={`flex gap-5 pt-[10px] pr-8 pb-[10px] pl-7 min-h-9 items-start  ${isCallButtonEnabled ? 'cursor-pointer dark:hover:bg-hoverDark hover:bg-hoverLight' : 'dark:bg-hoverDark bg-hoverLight opacity-50 cursor-not-allowed'}`}
 
         onClick={() => {
-          if (isCallsEnabled && getIsPhoneNumber(searchText))
+          if (isCallButtonEnabled)
             callUser(searchText)
         }}
       >
diff --git a/src/renderer/src/pages/NethLinkPage.tsx b/src/renderer/src/pages/NethLinkPage.tsx
index 89eec05a..b0c43da5 100644
--- a/src/renderer/src/pages/NethLinkPage.tsx
+++ b/src/renderer/src/pages/NethLinkPage.tsx
@@ -65,9 +65,9 @@ export function NethLinkPage({ themeMode }: NethLinkPageProps) {
     //log('USERAGENT', navigator.userAgent.includes('Linux'))
   }, true)
   useEffect(() => {
-    const isPhoneNumber = getIsPhoneNumber(search)
+    //const isPhoneNumber = getIsPhoneNumber(search)
     //la ricerca é abilitata squando maggiore di due caratteri per i numeri e maggiore di 3 caratteri per il resto
-    if (search.length > (isPhoneNumber ? 2 : 3)) {
+    if (search.length >= 3) {
       debouncer(
         'search',
         () => {
