Skip to content

Commit b66ccb4

Browse files
menu & tray: added favorites menu and fix tray icon click (#36)
* feat: update add/remove favourites * fix: removed the override of the sip_port when host contain "nethesis" * fix: left-click on the taskbar icon now toggles nethlink on WindosOS only * fix: the first start of the application started with the connection set to false, changed to true; the speeddial delete modal now has a correct backdrop Co-authored-by: edospadoni <[email protected]>
1 parent b31abda commit b66ccb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+837
-374
lines changed

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@electron-toolkit/utils": "^3.0.0",
4343
"@fortawesome/fontawesome-svg-core": "^6.5.1",
4444
"@fortawesome/free-solid-svg-icons": "^6.5.1",
45+
"@fortawesome/free-regular-svg-icons": "^6.5.1",
4546
"@fortawesome/react-fontawesome": "^0.2.0",
4647
"@headlessui/react": "^1.7.18",
4748
"@hookform/resolvers": "^3.3.4",

public/locales/en/translations.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,16 @@
586586
"Speed dial creation message": "You've just created a new speed dial: {{extensionWaiting}}",
587587
"Speed dial created": "Speed dial created",
588588
"Speed dial edit message": "You've just edited a speed dial: {{extensionWaiting}}",
589-
"Speed dial edited": "Speed dial edited"
589+
"Speed dial edited": "Speed dial edited",
590+
"Favourites": "Favourites",
591+
"No favourites": "No favourites found",
592+
"Order by": "Order by",
593+
"A-Z": "Alphabetic A-Z",
594+
"Z-A": "Alphabetic Z-A",
595+
"EXT": "Extension",
596+
"A-Z label": "A-Z",
597+
"Z-A label": "Z-A",
598+
"EXT label": "Extension"
590599
},
591600
"LastCalls": {
592601
"Last calls": "Last calls",

public/locales/it/translations.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,16 @@
587587
"Speed dial creation message": "Hai appena creato una nuova chiamata rapida: {{estensioneAttesa}}",
588588
"Speed dial created": "Chiamata rapida creata",
589589
"Speed dial edit message": "Hai appena modificato una chiamata rapida: {{estensioneAttesa}}",
590-
"Speed dial edited": "Chiamata rapida modificata"
590+
"Speed dial edited": "Chiamata rapida modificata",
591+
"Favourites": "Preferiti",
592+
"No favourites": "Nessun preferito trovato",
593+
"Order by": "Ordina per",
594+
"A-Z": "Alfabetico A-Z",
595+
"Z-A": "Alfabetico Z-A",
596+
"EXT": "Interno",
597+
"A-Z label": "A-Z",
598+
"Z-A label": "Z-A",
599+
"EXT label": "Interno"
591600
},
592601
"LastCalls": {
593602
"Last calls": "Ultime chiamate",

src/main/classes/controllers/TrayController.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export class TrayController {
2525
this.tray = new Tray(image)
2626
this.updateTray()
2727
this.tray.on('click', () => {
28-
this.tray.popUpContextMenu()
28+
if (process.platform === 'win32') {
29+
this.toggleWindow(true)
30+
} else {
31+
this.tray.popUpContextMenu()
32+
}
2933
})
3034
}
3135

@@ -47,6 +51,27 @@ export class TrayController {
4751
this.tray.setImage(image)
4852
}
4953

54+
toggleWindow(enableShowButton: boolean) {
55+
try {
56+
if (enableShowButton) {
57+
if (store.store['account']) {
58+
if (NethLinkController.instance && NethLinkController.instance.window?.isOpen())
59+
NethLinkController.instance.hide()
60+
else
61+
NethLinkController.instance.show()
62+
} else {
63+
if (LoginController.instance && LoginController.instance.window?.isOpen())
64+
LoginController.instance.hide()
65+
else
66+
LoginController.instance.show()
67+
}
68+
69+
}
70+
} catch (e) {
71+
log(e)
72+
}
73+
}
74+
5075
updateTray({
5176
enableShowButton,
5277
isShowButtonVisible
@@ -69,20 +94,7 @@ export class TrayController {
6994
enabled: enableShowButton ?? false,
7095
visible: _isShowButtonVisible,
7196
click: (menuItem, window, event) => {
72-
if (enableShowButton) {
73-
if (store.store['account']) {
74-
if (NethLinkController.instance && NethLinkController.instance.window?.isOpen())
75-
NethLinkController.instance.hide()
76-
else
77-
NethLinkController.instance.show()
78-
} else {
79-
if (LoginController.instance && LoginController.instance.window?.isOpen())
80-
LoginController.instance.hide()
81-
else
82-
LoginController.instance.show()
83-
}
84-
85-
}
97+
this.toggleWindow(enableShowButton ?? false)
8698
}
8799
},
88100
{

src/main/lib/ipcEvents.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,10 @@ export function registerIpcEvents() {
5050

5151
let draggingWindows: OnDraggingWindow = {}
5252

53-
//TODO: move each event to the controller it belongs to
5453
onSyncEmitter(IPC_EVENTS.GET_LOCALE, async () => {
5554
return app.getSystemLocale()
5655
})
5756

58-
// ipcMain.on(IPC_EVENTS.DEV_TOOL_TOGGLE_CONNECTION, (e) => {
59-
// const windows = BrowserWindow.getAllWindows();
60-
// windows.forEach(win => {
61-
// log(win.webContents?.session)
62-
// win.webContents?.session.enableNetworkEmulation({
63-
// offline: false
64-
// });
65-
// });
66-
// })
67-
6857
ipcMain.on(IPC_EVENTS.UPDATE_SHARED_STATE, (event, newState, page, selector) => {
6958
const windows = BrowserWindow.getAllWindows();
7059
store.updateStore(newState, `${page}[${selector}]`)

src/main/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ async function resetApp() {
454454
lastUserCryptPsw: undefined
455455
},
456456
theme: 'system',
457-
connection: false,
457+
connection: true,
458458
}, 'resetApp')
459459
await delay(100)
460460
store.saveToDisk()

src/renderer/public/locales/en/translations.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,16 @@
586586
"Speed dial creation message": "You've just created a new speed dial: {{extensionWaiting}}",
587587
"Speed dial created": "Speed dial created",
588588
"Speed dial edit message": "You've just edited a speed dial: {{extensionWaiting}}",
589-
"Speed dial edited": "Speed dial edited"
589+
"Speed dial edited": "Speed dial edited",
590+
"Favourites": "Favourites",
591+
"No favourites": "No favourites found",
592+
"Order by": "Order by",
593+
"A-Z": "Alphabetic A-Z",
594+
"Z-A": "Alphabetic Z-A",
595+
"EXT": "Extension",
596+
"A-Z label": "A-Z",
597+
"Z-A label": "Z-A",
598+
"EXT label": "Extension"
590599
},
591600
"LastCalls": {
592601
"Last calls": "Last calls",

src/renderer/public/locales/it/translations.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,16 @@
587587
"Speed dial creation message": "Hai appena creato una nuova chiamata rapida: {{estensioneAttesa}}",
588588
"Speed dial created": "Chiamata rapida creata",
589589
"Speed dial edit message": "Hai appena modificato una chiamata rapida: {{estensioneAttesa}}",
590-
"Speed dial edited": "Chiamata rapida modificata"
590+
"Speed dial edited": "Chiamata rapida modificata",
591+
"Favourites": "Preferiti",
592+
"No favourites": "Nessun preferito trovato",
593+
"Order by": "Ordina per",
594+
"A-Z": "Alfabetico A-Z",
595+
"Z-A": "Alfabetico Z-A",
596+
"EXT": "Interno",
597+
"A-Z label": "A-Z",
598+
"Z-A label": "Z-A",
599+
"EXT label": "Interno"
591600
},
592601
"LastCalls": {
593602
"Last calls": "Ultime chiamate",
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { NumberCaller } from "./NumberCaller"
2+
import { ContactType, OperatorData } from "@shared/types"
3+
import { isDev } from "@shared/utils/utils"
4+
import { FavouriteStar } from "./FavouritesStar"
5+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
6+
import { useAccount } from "@renderer/hooks/useAccount"
7+
import { useStoreState } from "@renderer/store"
8+
import { usePhoneIslandEventHandler } from "@renderer/hooks/usePhoneIslandEventHandler"
9+
import { Avatar } from "./Nethesis"
10+
import {
11+
faPhone as CallIcon,
12+
} from '@fortawesome/free-solid-svg-icons'
13+
import { t } from "i18next"
14+
import { ReactNode } from "react"
15+
import classNames from "classnames"
16+
export const ContactNameAndActions = ({ contact, number, isHighlight, displayedNumber, avatarDim, username, isFavourite, isSearchData }: {
17+
contact: ContactType,
18+
number: string,
19+
isHighlight: boolean,
20+
displayedNumber: string | ReactNode[],
21+
avatarDim: "small" | "base" | "extra_small" | "large" | "extra_large",
22+
username: string | undefined,
23+
isFavourite: boolean
24+
isSearchData: boolean
25+
}) => {
26+
const { isCallsEnabled } = useAccount()
27+
const [operators] = useStoreState<OperatorData>('operators')
28+
const { callNumber } = usePhoneIslandEventHandler()
29+
const avatarSrc = username && operators?.avatars?.[username]
30+
31+
const isOperator = username && !!(operators?.operators?.[username])
32+
33+
return (
34+
<div className={classNames(avatarDim === 'small' ? 'gap-3' : 'gap-6', "flex flex-row items-center w-full max-w-full")}>
35+
<Avatar
36+
size={avatarDim}
37+
src={avatarSrc}
38+
status={isOperator ? operators?.operators?.[username]?.mainPresence : undefined}
39+
bordered={true}
40+
placeholderType={operators?.extensions[contact.speeddial_num || ''] ? 'operator' : 'person'}
41+
/>
42+
<div className='relative w-full h-[44px] '>
43+
<div className="absolute top-0 left-0 flex flex-col gap-1 w-full ">
44+
<div className="flex flex-row gap-2 w-full overflow-hidden">
45+
<div className='dark:text-titleDark text-titleLight font-medium text-[14px] leading-5 truncate break-all whitespace-nowrap '>
46+
{isFavourite ? (contact.company || `${t('Common.Unknown')}`) : (contact.name || contact.company || `${t('Common.Unknown')}`)}
47+
{false && isDev() && <span className='absolute top-[-4px] left-[-26px] text-[8px]'>[{contact.id}]</span>}
48+
</div>
49+
{isOperator && <FavouriteStar contact={contact} isSearchData={isSearchData} />}
50+
</div>
51+
<div className="flex flex-row gap-2 items-center">
52+
{!isHighlight &&
53+
<FontAwesomeIcon
54+
className="dark:text-gray-400 text-gray-600 text-base"
55+
icon={CallIcon}
56+
onClick={() => callNumber(contact.speeddial_num!)}
57+
/>
58+
}
59+
<NumberCaller
60+
number={number}
61+
disabled={!isCallsEnabled}
62+
className="dark:text-textBlueDark text-textBlueLight font-normal hover:underline"
63+
isNumberHiglighted={isHighlight}
64+
>
65+
{displayedNumber}
66+
</NumberCaller>
67+
</div>
68+
</div>
69+
</div>
70+
</div>
71+
)
72+
}

0 commit comments

Comments
 (0)