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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ out
*.log*
.yarn/install-state.gz
yarn.lock
package-lock.json
certification
*.env
test/
9 changes: 5 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.8.45",
"@nethesis/phone-island": "^0.10.2",
"@tailwindcss/forms": "^0.5.7",
"@types/lodash": "^4.14.202",
"@types/node": "^18.19.9",
Expand Down
10 changes: 8 additions & 2 deletions src/main/classes/controllers/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export class NetworkController {

async post(path: string, data: object | undefined, config: { headers: { Authorization?: string | undefined; 'Content-Type': string; }; } | undefined = { headers: { 'Content-Type': 'application/json' } }): Promise<any> {
try {
const response = await axios.post(path, data, config)
const response = await axios.post(path, data, {
timeout: 5000,
...config
})

return response.data
} catch (e: any) {
Expand All @@ -19,7 +22,10 @@ export class NetworkController {
}
async get(path: string, config: { headers: { Authorization?: string | undefined; 'Content-Type': string } } | undefined = { headers: { 'Content-Type': 'application/json' } }): Promise<any> {
try {
const response = await axios.get(path, config)
const response = await axios.get(path, {
timeout: 5000,
...config
})
return response.data
} catch (e: any) {
const err: AxiosError = e
Expand Down
2 changes: 1 addition & 1 deletion src/main/classes/windows/NethLinkWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class NethLinkWindow extends BaseWindow {
super.buildWindow()
this._window?.on('hide', this.toggleVisibility)
this._window?.on('moved', () => {
this.saveBounds()
debouncer('onMoveNethLinkWindow', () => this.saveBounds(), 1000)
})
this._window?.on('show', this.toggleVisibility)
this._window?.on('closed', this.toggleVisibility)
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/ipcEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function registerIpcEvents() {
if (!draggingWindows?.hasOwnProperty(window.title)) {
const interval: number = setInterval(() => {
updateWindowPosition(window)
}, 1000 / 60) as unknown as number; // => 60 frames per seconds
}, 1000 / 300) as unknown as number; // => 300 frames per seconds
draggingWindows = {
...draggingWindows,
[window.title]: {
Expand Down
47 changes: 18 additions & 29 deletions src/renderer/index.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<!-- <meta http-equiv="Content-Security-Policy"
content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval';" /> -->
<!-- IMPORT THE WIDGET CSS -->
<link
rel="stylesheet"
type="text/css"
href="https://cdn.jsdelivr.net/gh/nethesis/phone-island/dist-widget/index.widget.css"
/>
<!-- IMPORT THE POPPINS FONTS -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet"
/>
<!-- IMPORT THE WIDGET CSS -->
<meta
http-equiv="Content-Security-Policy"
content="default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;"
/>
<!-- 'unsafe-eval' -->
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
<head>
<meta charset="UTF-8" />
<!-- IMPORT THE POPPINS FONTS -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet" />
<meta http-equiv="Content-Security-Policy"
content="default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;" />
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>

</html>
11 changes: 5 additions & 6 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useRegisterStoreHook, useSharedState } from "@renderer/store";
import { PageContext, usePageCtx } from './contexts/pageContext'
import { GIT_RELEASES_URL, IPC_EVENTS } from '@shared/constants'
import { useNetwork } from '@shared/useNetwork'

import './index.css'

const RequestStateComponent = () => {
const pageData = usePageCtx()
Expand Down Expand Up @@ -66,7 +66,7 @@ const RequestStateComponent = () => {
}, [account?.username, pageData?.page])

const loader = async () => {
Log.info('check i18n initialization')
Log.debug('check i18n initialization')
let time = 0
//I wait for the language to load or 200 milliseconds
while (time < 20 && !i18next.isInitialized) {
Expand Down Expand Up @@ -119,10 +119,9 @@ const Layout = ({ theme, page }: { theme?: AvailableThemes, page?: PAGES }) => {

const importStyle = async () => {
// Importing CSS dynamically when the page is not 'PHONEISLAND'
if (page !== PAGES.PHONEISLAND) {
await import('./tailwind.css')
if (page === PAGES.PHONEISLAND) {
await import('@nethesis/phone-island/dist/index.css')
}
await import('./index.css')
setIsCSSLoaded(true);
}

Expand All @@ -142,7 +141,7 @@ const Layout = ({ theme, page }: { theme?: AvailableThemes, page?: PAGES }) => {
export default function App() {

useInitialize(() => {
Log.info('initialize i18n')
Log.debug('initialize i18n')
loadI18n()
})
return (
Expand Down
12 changes: 5 additions & 7 deletions src/renderer/src/components/ElectronDraggableWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ export const ElectronDraggableWindow = ({ children }) => {
};

const handleMouseUp = (e: MouseEvent) => {
if (!mouseUpEvent.current) {
mouseDownEvent.current = null
window.electron.send(IPC_EVENTS.STOP_DRAG);
isDrag.current = false
mouseUpEvent.current = e
}
mouseDownEvent.current = null
window.electron.send(IPC_EVENTS.STOP_DRAG);
isDrag.current = false
mouseUpEvent.current = e
};

useEffect(() => {
Expand Down Expand Up @@ -81,7 +79,7 @@ export const ElectronDraggableWindow = ({ children }) => {

return (
<div
className={classNames('absolute select-none top-0 left-0 h-screen w-screen z-[10000]', isDev() ? 'bg-red-700/75' : '')}
className={classNames('select-none h-[inherit] w-[inherit] z-[10000]', isDev() ? 'bg-red-700/75' : '')}
>
{children}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { PhoneIsland } from "@nethesis/phone-island"
import { eventDispatch } from "@renderer/hooks/eventDispatch"
import { useLoggedNethVoiceAPI } from "@renderer/hooks/useLoggedNethVoiceAPI"
import { useSharedState } from "@renderer/store"
import { IPC_EVENTS, PHONE_ISLAND_EVENTS } from "@shared/constants"
import { IPC_EVENTS } from "@shared/constants"
import { Log } from "@shared/utils/logger"
import { useEffect, useMemo } from "react"

export const PhoneIslandContainer = ({ dataConfig, deviceInformationObject, isDataConfigCreated, i18nLoadPath }) => {
export const PhoneIslandContainer = ({ dataConfig, deviceInformationObject, isDataConfigCreated }) => {
const [account] = useSharedState('account')
const { NethVoiceAPI } = useLoggedNethVoiceAPI()

useEffect(() => {
updateAccountInfo()
Expand All @@ -17,18 +14,14 @@ export const PhoneIslandContainer = ({ dataConfig, deviceInformationObject, isDa
const updateAccountInfo = async () => {
if (deviceInformationObject) {
Log.info('FORCE DEFAULT DEVICE TO NETHLINK')
//TODO: controlla
if(account?.data?.default_device?.type === 'webrtc') {
if (account?.data?.default_device?.type === 'webrtc') {
window.electron.send(IPC_EVENTS.CHANGE_DEFAULT_DEVICE, deviceInformationObject)
}
// await NethVoiceAPI.User.default_device(deviceInformationObject)
// eventDispatch(PHONE_ISLAND_EVENTS['phone-island-default-device-change'], { deviceInformationObject })

}
}

const PhoneIslandComponent = useMemo(() => {
return dataConfig && isDataConfigCreated && <PhoneIsland dataConfig={dataConfig} i18nLoadPath={i18nLoadPath} uaType='mobile' />
return dataConfig && isDataConfigCreated && <PhoneIsland dataConfig={dataConfig} uaType='mobile' />
}, [account?.username, dataConfig, isDataConfigCreated])

return PhoneIslandComponent
Expand Down
Loading