Skip to content

Commit 93f5464

Browse files
Added parking section (#34)
* feat: add parking feature * feat: add pulse notification on parked calls Co-authored-by: Edoardo Spadoni <[email protected]>
1 parent dcc5ebb commit 93f5464

30 files changed

+658
-137
lines changed

package-lock.json

Lines changed: 41 additions & 15 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
@@ -67,6 +67,7 @@
6767
"electron-vite": "^2.0.0",
6868
"eslint": "^8.56.0",
6969
"eslint-plugin-react": "^7.33.2",
70+
"framer-motion": "^11.11.8",
7071
"i18next": "^22.4.9",
7172
"i18next-browser-languagedetector": "^7.0.1",
7273
"i18next-electron-fs-backend": "^3.0.1",

public/locales/en/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@
797797
"Pick up": "Pick up",
798798
"Parking": "Parking",
799799
"Hold": "Hold",
800+
"No parked call": "No parked calls found",
800801
"Click and hold to take current parking in call": "Click and hold to take current parking in call"
801802
},
802803
"Devices": {

public/locales/it/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@
798798
"Pick up": "Riprendi",
799799
"Parking": "Parcheggio",
800800
"Hold": "Tieni premuto",
801+
"No parked call": "Nessuna chiamata parcheggiata trovata",
801802
"Click and hold to take current parking in call": "Clicca e tieni premuto per riprendere la chiamata parcheggiata"
802803
},
803804
"Devices": {

src/main/main.ts

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -209,49 +209,58 @@ function attachOnReadyProcess() {
209209

210210
async function startApp(attempt = 0) {
211211
const data = store.getFromDisk()
212-
store.updateStore(data, 'startApp')
213-
log('START APP, retry:', attempt)
214-
if (!store.store.connection) {
215-
log('NO CONNECTION', attempt, store.store)
216-
if (attempt >= 3)
217-
SplashScreenController.instance.window.emit(IPC_EVENTS.SHOW_NO_CONNECTION)
218-
retryAppStart = setTimeout(() => {
219-
startApp(++attempt)
220-
}, 1000)
221-
} else {
222-
if (retryAppStart) {
223-
clearTimeout(retryAppStart)
224-
}
225-
const auth: AuthAppData | undefined = store.store['auth']
226-
await getPermissions()
227-
if (auth?.isFirstStart !== undefined && !auth?.isFirstStart) {
228-
const isLastUserLogged = await AccountController.instance.autoLogin()
229-
if (isLastUserLogged) {
230-
ipcMain.emit(IPC_EVENTS.LOGIN, undefined, { showNethlink: true })
212+
if (checkData(data)) {
213+
store.updateStore(data, 'startApp')
214+
log('START APP, retry:', attempt)
215+
if (!store.store.connection) {
216+
log('NO CONNECTION', attempt, store.store)
217+
if (attempt >= 3)
218+
SplashScreenController.instance.window.emit(IPC_EVENTS.SHOW_NO_CONNECTION)
219+
retryAppStart = setTimeout(() => {
220+
startApp(++attempt)
221+
}, 1000)
222+
} else {
223+
if (retryAppStart) {
224+
clearTimeout(retryAppStart)
225+
}
226+
const auth: AuthAppData | undefined = store.store['auth']
227+
await getPermissions()
228+
if (auth?.isFirstStart !== undefined && !auth?.isFirstStart) {
229+
const isLastUserLogged = await AccountController.instance.autoLogin()
230+
if (isLastUserLogged) {
231+
ipcMain.emit(IPC_EVENTS.LOGIN, undefined, { showNethlink: true })
232+
} else {
233+
store.updateStore({
234+
auth: {
235+
...store.store['auth']!,
236+
lastUser: undefined,
237+
lastUserCryptPsw: undefined
238+
},
239+
account: undefined,
240+
theme: 'system',
241+
connection: store.store['connection'] || false,
242+
}, 'showLogin')
243+
showLogin()
244+
}
231245
} else {
232-
store.updateStore({
233-
auth: {
234-
...store.store['auth']!,
235-
lastUser: undefined,
236-
lastUserCryptPsw: undefined
237-
},
238-
account: undefined,
239-
theme: 'system',
240-
connection: store.store['connection'] || false,
241-
}, 'showLogin')
246+
await resetApp()
242247
showLogin()
243248
}
244-
} else {
245-
await resetApp()
246-
showLogin()
249+
SplashScreenController.instance.window.quit(true)
250+
//once the loading is complete I enable the ability to click on the icon in the tray
251+
TrayController.instance.updateTray({
252+
enableShowButton: true
253+
})
247254
}
255+
} else {
256+
await resetApp()
257+
showLogin()
248258
SplashScreenController.instance.window.quit(true)
249259
//once the loading is complete I enable the ability to click on the icon in the tray
250260
TrayController.instance.updateTray({
251261
enableShowButton: true
252262
})
253263
}
254-
255264
}
256265

257266
app.on('window-all-closed', () => {
@@ -417,7 +426,7 @@ function attachThemeChangeListener() {
417426
store.set('theme', updatedSystemTheme)
418427
}
419428
//update theme state on the store
420-
TrayController.instance.changeIconByTheme(updatedSystemTheme)
429+
TrayController.instance?.changeIconByTheme(updatedSystemTheme)
421430
})
422431
}
423432
/**
@@ -485,5 +494,14 @@ async function checkForUpdate() {
485494
}
486495
}
487496

497+
function checkData(data: any): boolean {
498+
log({ data })
499+
return data.hasOwnProperty('account') &&
500+
data.hasOwnProperty('auth') &&
501+
data.hasOwnProperty('theme') &&
502+
data.hasOwnProperty('connection')
503+
}
504+
488505
//BEGIN APP
489506
startup()
507+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@
797797
"Pick up": "Pick up",
798798
"Parking": "Parking",
799799
"Hold": "Hold",
800+
"No parked call": "No parked calls found",
800801
"Click and hold to take current parking in call": "Click and hold to take current parking in call"
801802
},
802803
"Devices": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@
798798
"Pick up": "Riprendi",
799799
"Parking": "Parcheggio",
800800
"Hold": "Tieni premuto",
801+
"No parked call": "Nessuna chiamata parcheggiata trovata",
801802
"Click and hold to take current parking in call": "Clicca e tieni premuto per riprendere la chiamata parcheggiata"
802803
},
803804
"Devices": {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { IconProp } from "@fortawesome/fontawesome-svg-core"
2+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
3+
4+
5+
export interface EmptyListProps {
6+
icon: IconProp,
7+
text: string
8+
}
9+
export const EmptyList = ({ icon, text }: EmptyListProps) => {
10+
11+
return (
12+
<div className="flex flex-col justify-between items-center gap-5 py-[28px] bg-hoverLight dark:bg-hoverDark min-h-[132px] mt-4 rounded-lg ml-5 mr-3">
13+
<div className="text-emptyIconLight dark:text-emptyIconDark">
14+
<FontAwesomeIcon icon={icon} className="text-[28px] " />
15+
</div>
16+
<span className="text-center text-emptyTextLight dark:text-emptyTextDark text-sm">{text}</span>
17+
</div>
18+
)
19+
}

src/renderer/src/components/Modules/NethVoice/LastCalls/LastCall.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,36 @@ export function LastCall({
8484
const handleCreateContact = () => {
8585
handleSelectedCallContact(
8686
(call.direction === 'in' ? call.src : call.dst) || '',
87-
call.direction === 'out'
88-
? call?.dst_cnam || call?.dst_ccompany
89-
: call.direction === 'in'
90-
? call?.cnam || call?.ccompany
87+
call.direction === 'in'
88+
? call?.cnam || call?.ccompany
89+
: call.direction === 'out'
90+
? call?.dst_cnam || call?.dst_ccompany
9191
: undefined
9292
)
9393
showContactForm()
9494
}
9595

96+
const getCallName = (call: LastCallData) => {
97+
return `${call.direction === 'in'
98+
? (call.cnam || call.ccompany || t('Common.Unknown'))
99+
: call.direction === 'out'
100+
? (call.dst_cnam || call.dst_ccompany || t('Common.Unknown'))
101+
: t('Common.Unknown')
102+
}`
103+
}
104+
96105
return (
97106
<div className="group">
98107
<div
99108
className={`flex flex-grow gap-3 min-h-[72px] p-2 ${className}`}
100109
onMouseEnter={() => {
101-
if (call.username === t('Common.Unknown')) {
110+
if (
111+
call.direction === 'in'
112+
? !(call.src || call.ccompany)
113+
: call.direction === 'out'
114+
? !(call.dst_cnam || call.dst_ccompany)
115+
: false
116+
) {
102117
setShowCreateButton(() => true)
103118
}
104119
}}
@@ -130,9 +145,9 @@ export function LastCall({
130145
</div>
131146
<div className="flex flex-col gap-1 dark:text-titleDark text-titleLight">
132147
<p className={`tooltip-username-${call?.username} font-medium text-[14px] leading-5`}>
133-
{truncate(call.username, 13)}
148+
{truncate(getCallName(call), 13)}
134149
</p>
135-
<Tooltip anchorSelect={`.tooltip-username-${call?.username}`}>{call.username}</Tooltip>
150+
<Tooltip anchorSelect={`.tooltip-username-${call?.username}`}>{getCallName(call)}</Tooltip>
136151
<div className="flex flex-row gap-2 items-center">
137152
<div className={`h-4 w-4 call_${call.uniqueid?.replace('.', '_')}`}>
138153
{call.disposition === 'NO ANSWER' ? (

0 commit comments

Comments
 (0)