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,317 changes: 356 additions & 961 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"build:linux": "npm run build && electron-builder --linux"
},
"devDependencies": {
"@date-fns/utc": "^2.0.0",
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
"@electron-toolkit/eslint-config-ts": "^3.1.0",
"@electron-toolkit/preload": "^3.0.0",
Expand All @@ -46,8 +45,6 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^2.2.8",
"@hookform/resolvers": "^3.3.4",
"@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": "^1.0.15",
"@tailwindcss/forms": "^0.5.7",
Expand All @@ -56,12 +53,10 @@
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.2.1",
"auto-launch": "^5.0.6",
"autoprefixer": "^10.4.17",
"axios": "^1.6.7",
"classnames": "^2.5.1",
"clsx": "^2.1.0",
"crypto-browserify": "^3.12.0",
"crypto-js": "^4.2.0",
"date-fns": "^2.30.0",
"date-fns-tz": "^1.3.8",
Expand All @@ -74,13 +69,10 @@
"eslint-plugin-react-hooks": "^5.2.0",
"framer-motion": "^11.11.8",
"i18next": "^22.4.9",
"i18next-browser-languagedetector": "^7.0.1",
"i18next-electron-fs-backend": "^3.0.1",
"i18next-fs-backend": "^2.3.2",
"i18next-http-backend": "^2.1.1",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"motion": "^11.13.1",
"path-browserify": "^1.0.1",
"postcss": "^8.4.35",
"prettier": "^3.2.4",
Expand All @@ -90,13 +82,11 @@
"react-hook-form": "^7.50.1",
"react-i18next": "^12.1.5",
"react-router-dom": "^6.21.3",
"rollup": "^4.12.1",
"react-tooltip": "^5.28.0",
"tailwind-merge": "^2.2.1",
"tailwind-scrollbar": "^3.1.0",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-plugin-copy": "^0.1.6",
"zod": "^3.22.4",
"zustand": "^4.5.0"
},
Expand Down
23 changes: 0 additions & 23 deletions src/main/classes/controllers/AccountController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
Account,
AuthAppData,
AvailableDevices,
ConfigFile,
PhoneIslandPosition,
isSsoMethod,
} from '@shared/types'
Expand All @@ -15,21 +13,6 @@ import { NetworkController } from './NetworkController'
import { getAccountUID } from '@shared/utils/utils'
import { requires2FA, isJWTExpired } from '@shared/utils/jwt'

const defaultConfig: ConfigFile = {
lastUser: undefined,
accounts: {},
}

type EventCallback = (...args: any[]) => void | Promise<void>
type EventListenerCallback = {
event: keyof typeof AccountEvents
callback: EventCallback
}
export enum AccountEvents {
LOGIN = 'LOGIN',
LOGOUT = 'LOGOUT',
}

export class AccountController {
_app: Electron.App | undefined
static instance: AccountController
Expand Down Expand Up @@ -61,12 +44,6 @@ export class AccountController {
return safeStorage.isEncryptionAvailable()
}

listAvailableAccounts(): Account[] {
const authAppData = store.store.auth
if (authAppData) return Object.values(authAppData.availableAccounts)
return []
}

async logout() {
// Call API logout before clearing local data
const account = store.store.account
Expand Down
33 changes: 0 additions & 33 deletions src/main/classes/controllers/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,6 @@ export class NetworkController {
NetworkController.instance = this
}

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, {
timeout: 5000,
...config,
})

return response.data
} catch (e: any) {
const err: AxiosError = e
Log.error(
'during fetch POST',
err.name,
err.code,
err.message,
path,
config,
data,
)
throw e
}
}
async get(
path: string,
config:
Expand Down
161 changes: 1 addition & 160 deletions src/main/classes/controllers/PhoneIslandController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { PhoneIslandWindow } from '../windows'
import { IPC_EVENTS } from '@shared/constants'
import { Log } from '@shared/utils/logger'
import { AccountController } from './AccountController'
import { debouncer } from '@shared/utils/utils'
import { once } from '@/lib/ipcEvents'
import { screen } from 'electron'
import { Extension, PhoneIslandPosition, Size } from '@shared/types'

export class PhoneIslandController {
static instance: PhoneIslandController
window: PhoneIslandWindow
private isWarmingUp: boolean = false
private lastVisibleBounds: Electron.Rectangle | undefined

private isValidVisibleBounds(
Expand Down Expand Up @@ -280,8 +278,7 @@ export class PhoneIslandController {
`PhoneIsland resize to 0x0 -> hidden from (${hiddenFrom.x}, ${hiddenFrom.y})`,
)
} else {
// Don't show window during warm-up
if (!window.isVisible() && !this.isWarmingUp) {
if (!window.isVisible()) {
if (process.platform === 'win32') {
const restoredBounds = this.resolveWindowsBounds(size)
window.setBounds(restoredBounds, false)
Expand All @@ -302,91 +299,6 @@ export class PhoneIslandController {
}
}

showPhoneIsland(size: Size) {
try {
const window = this.window.getWindow()
if (window) {
Log.info(
`PhoneIsland showPhoneIsland called with size ${size.w}x${size.h}`,
)
this.resize(size)
if (process.platform === 'win32') {
const restoredBounds = this.resolveWindowsBounds(size)
window.setBounds(restoredBounds, false)
this.rememberVisibleBounds(restoredBounds)
if (!window.isVisible() && !this.isWarmingUp) {
window.show()
window.setAlwaysOnTop(true, 'screen-saver')
}
} else if (process.platform !== 'linux') {
const phoneIslandPosition =
AccountController.instance.getAccountPhoneIslandPosition()
Log.info(
`PhoneIsland saved position: ${phoneIslandPosition ? `(${phoneIslandPosition.x}, ${phoneIslandPosition.y})` : 'none'}`,
)
if (phoneIslandPosition) {
const displays = screen.getAllDisplays()
const isPhoneIslandOnDisplay = displays.reduce(
(result, display) => {
const area = display.workArea
return (
result ||
(phoneIslandPosition.x >= area.x &&
phoneIslandPosition.y >= area.y &&
phoneIslandPosition.x + size.w < area.x + area.width &&
phoneIslandPosition.y + size.h < area.y + area.height)
)
},
false,
)
if (isPhoneIslandOnDisplay) {
window?.setBounds(
{ x: phoneIslandPosition.x, y: phoneIslandPosition.y },
false,
)
Log.info(
`PhoneIsland positioned at saved location (${phoneIslandPosition.x}, ${phoneIslandPosition.y})`,
)
} else {
window?.center()
Log.info(
`PhoneIsland saved position is off-screen, centered instead. Displays: ${JSON.stringify(displays.map((d) => d.workArea))}`,
)
}
} else {
window?.center()
Log.info('PhoneIsland no saved position, centered')
}
} else {
window?.center()
}
const finalBounds = window.getBounds()
Log.info(
`PhoneIsland final bounds after showPhoneIsland: (${finalBounds.x}, ${finalBounds.y}) ${finalBounds.width}x${finalBounds.height}`,
)
}
} catch (e) {
Log.warning('error during showing PhoneIslandWindow:', e)
}
}

hidePhoneIsland() {
try {
const window = this.window.getWindow()
const phoneIslandBounds = window?.getBounds()
const persistableBounds = this.getPersistableBounds(phoneIslandBounds)
if (persistableBounds) {
Log.info(
`PhoneIsland hiding, saving position (${persistableBounds.x}, ${persistableBounds.y}) size ${persistableBounds.width}x${persistableBounds.height}`,
)
this.savePhoneIslandPosition(persistableBounds)
}
debouncer('hide', () => window?.hide(), 250)
} catch (e) {
Log.warning('error during hiding PhoneIslandWindow:', e)
}
}

logout() {
return new Promise<void>((resolve, reject) => {
try {
Expand Down Expand Up @@ -427,10 +339,7 @@ export class PhoneIslandController {

updateDefaultDevice(ext: Extension, force: boolean) {
try {
// const { NethVoiceAPI } = useNethVoiceAPI(store.store.account)
// NethVoiceAPI.User.me().then((me) => {
this.window.emit(IPC_EVENTS.CHANGE_DEFAULT_DEVICE, ext, force)
// })
} catch (e) {
Log.warning(
'error during emitting updateDefaultDevice event to the PhoneIslandWindow:',
Expand All @@ -439,74 +348,6 @@ export class PhoneIslandController {
}
}

muteAudio() {
try {
const window = this.window.getWindow()
if (window && window.webContents) {
window.webContents.setAudioMuted(true)
Log.info('PhoneIsland audio muted')
}
} catch (e) {
Log.warning('error during muting PhoneIsland audio:', e)
}
}

unmuteAudio() {
try {
const window = this.window.getWindow()
if (window && window.webContents) {
window.webContents.setAudioMuted(false)
Log.info('PhoneIsland audio unmuted')
}
} catch (e) {
Log.warning('error during unmuting PhoneIsland audio:', e)
}
}

forceHide() {
try {
const window = this.window.getWindow()
if (window) {
this.isWarmingUp = true
const persistableBounds = this.getPersistableBounds(window.getBounds())
if (persistableBounds) {
this.savePhoneIslandPosition(persistableBounds)
}
window.hide()
Log.info('PhoneIsland window hidden')
}
} catch (e) {
Log.warning('error during force hiding PhoneIsland:', e)
}
}

forceShow() {
try {
const window = this.window.getWindow()
if (window) {
this.isWarmingUp = false
// Only show if there's actually content (size > 0)
const bounds = window.getBounds()
if (bounds.width > 0 && bounds.height > 0) {
if (process.platform === 'win32') {
const restoredBounds = this.resolveWindowsBounds({
w: bounds.width,
h: bounds.height,
})
window.setBounds(restoredBounds, false)
this.rememberVisibleBounds(restoredBounds)
}
window.show()
window.setAlwaysOnTop(true, 'screen-saver')
this.rememberVisibleBounds(window.getBounds())
Log.info('PhoneIsland window shown')
}
}
} catch (e) {
Log.warning('error during force showing PhoneIsland:', e)
}
}

async safeQuit() {
await this.logout()
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/lib/commandBarShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export function getDefaultCommandBarModifier(): CommandBarDoubleTapModifier {
return process.platform === 'darwin' ? 'Cmd' : 'Ctrl'
}

export function isCommandBarDoubleTapShortcutStarted(): boolean {
return uiohookStarted
}

export function stopCommandBarDoubleTapShortcut() {
if (!uiohookStarted) return

Expand Down
Loading
Loading