Skip to content

Commit be625f5

Browse files
therockerlineedospadoni
authored andcommitted
fix: replace call with clipboard copy; update contact details display
1 parent 11f525d commit be625f5

File tree

5 files changed

+40
-41
lines changed

5 files changed

+40
-41
lines changed

src/main/lib/ipcEvents.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ export function registerIpcEvents() {
216216
shell.openExternal(join(path))
217217
})
218218

219+
ipcMain.on(IPC_EVENTS.COPY_TO_CLIPBOARD, async (_, text) => {
220+
clipboard.writeText(text)
221+
})
222+
219223
ipcMain.on(IPC_EVENTS.PHONE_ISLAND_RESIZE, (_, size) => {
220224
PhoneIslandController.instance.resize(size)
221225
})

src/preload/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface IElectronAPI {
4040
exitNethLink(): void
4141
hidePhoneIsland(): void
4242
showPhoneIsland(size: Size): void
43+
copyToClipboard(text: string): void
4344

4445
}
4546

@@ -98,6 +99,7 @@ const api: IElectronAPI = {
9899
exitNethLink: setEmitter(IPC_EVENTS.CLOSE_NETH_LINK),
99100
hidePhoneIsland: setEmitter(IPC_EVENTS.HIDE_PHONE_ISLAND),
100101
showPhoneIsland: setEmitter(IPC_EVENTS.SHOW_PHONE_ISLAND),
102+
copyToClipboard: setEmitter(IPC_EVENTS.COPY_TO_CLIPBOARD),
101103

102104
//LISTENERS - receive data async
103105
onUpdateAppNotification: addListener(IPC_EVENTS.UPDATE_APP_NOTIFICATION),

src/renderer/src/components/Modules/NethVoice/SearchResults/SearchNumber.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function SearchNumber({ user, className, onClick }: SearchNumberProps) {
2727

2828

2929
const otherNumbers = [
30+
user.cellphone,
3031
user.workphone,
3132
user.homephone,
3233
].filter(p => p)
@@ -97,7 +98,7 @@ export function SearchNumber({ user, className, onClick }: SearchNumberProps) {
9798
contact={user}
9899
number={phoneNumber}
99100
displayedNumber={highlightedNumber}
100-
otherNumber={otherNumbers.length > 0 ? t('Common.PlusOther', { count: otherNumbers.length }) as string : ''}
101+
otherNumber={otherNumbers.length > 1 ? t('Common.PlusOther', { count: otherNumbers.length - 1 }) as string : ''}
101102
isHighlight={true}
102103
username={username}
103104
isFavourite={false}

src/renderer/src/components/Modules/NethVoice/SearchResults/SearchNumberDetail.tsx

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import { ClassNames } from '@renderer/utils'
1717
import { ModuleTitle } from '@renderer/components/ModuleTitle'
1818
import { ReactNode } from 'react'
1919
import { IconProp } from '@fortawesome/fontawesome-svg-core'
20-
import { CustomThemedTooltip } from '@renderer/components/Nethesis/CurstomThemedTooltip'
20+
import { Tooltip } from 'react-tooltip'
21+
2122
interface SearchNumberBoxProps {
2223
contactDetail?: {
2324
contact: SearchData,
@@ -54,25 +55,14 @@ export function SearchNumberDetail({ contactDetail, onBack }: SearchNumberBoxPro
5455
<div className='pl-6 pt-6 w-full h-full'>
5556
<Scrollable>
5657
<div className='flex flex-col gap-6 w-full pr-1'>
57-
<ContactVisibility isPublic={true} />
58-
<ContactDetail icon={PhoneIcon} label={t('Phonebook.Primary phone')}>
59-
<LinkedValue type='phone'>{primaryNumber || ''}</LinkedValue>
60-
</ContactDetail>
61-
<ContactDetail icon={PhoneIcon} label={t('Phonebook.Home phone')}>
62-
<LinkedValue type='phone'>{contact.homephone}</LinkedValue>
63-
</ContactDetail>
64-
<ContactDetail icon={MobilePhoneIcon} label={t('Phonebook.Mobile phone')}>
65-
<LinkedValue type='phone'>{contact.cellphone}</LinkedValue>
66-
</ContactDetail>
67-
<ContactDetail icon={PhoneIcon} label={t('Phonebook.Work phone')}>
68-
<LinkedValue type='phone'>{contact.workphone}</LinkedValue>
69-
</ContactDetail>
70-
<ContactDetail icon={MailIcon} label={t('Phonebook.Email')}>
71-
<LinkedValue type='mail'>{contact.homeemail}</LinkedValue>
72-
</ContactDetail>
73-
<ContactDetail icon={WorkIcon} label={t('Phonebook.Company')}>
74-
{contact.company}
75-
</ContactDetail>
58+
<ContactVisibility isPublic={!(contact?.type === 'private' && contact?.source === 'cti')} />
59+
{/* <ContactDetail icon={PhoneIcon} label={t('Phonebook.Primary phone')} copy>{primaryNumber || ''}</ContactDetail> */}
60+
<ContactDetail icon={PhoneIcon} label={t('Phonebook.Home phone')} copy>{contact.homephone}</ContactDetail>
61+
<ContactDetail icon={MobilePhoneIcon} label={t('Phonebook.Mobile phone')} copy>{contact.cellphone}</ContactDetail>
62+
<ContactDetail icon={PhoneIcon} label={t('Phonebook.Work phone')} copy>{contact.workphone}</ContactDetail>
63+
<ContactDetail icon={MailIcon} label={t('Phonebook.Email')} copy>{contact.homeemail}</ContactDetail>
64+
<ContactDetail icon={MailIcon} label={t('Phonebook.Work')} copy>{contact.workemail}</ContactDetail>
65+
<ContactDetail icon={WorkIcon} label={t('Phonebook.Company')}>{contact.company}</ContactDetail>
7666
</div>
7767
</Scrollable>
7868
</div>
@@ -104,7 +94,7 @@ const ContactVisibility = ({ isPublic }: { isPublic: boolean }) => {
10494
</div>
10595
}
10696

107-
const ContactDetail = ({ children, label, icon }: { label: string | DefaultTFuncReturn, icon: IconProp, children: ReactNode }) => {
97+
const ContactDetail = ({ children, label, icon, copy }: { label: string | DefaultTFuncReturn, icon: IconProp, children: string, copy?: boolean }) => {
10898
return <div className='flex flex-row w-full justify-start'>
10999
<div className='flex flex-row gap-2 items-center min-w-[170px] '>
110100
<FontAwesomeIcon
@@ -114,43 +104,44 @@ const ContactDetail = ({ children, label, icon }: { label: string | DefaultTFunc
114104
{label}
115105
</div>
116106
<div className='relative truncate max-w-[calc(100%-170px)]'
117-
{
118-
...(typeof children === 'string' ? {
119-
'data-tooltip-id': `tooltip-${label}`,
120-
'data-tooltip-content': children
121-
} : {})
122-
}
107+
data-tooltip-id={`tooltip-${label}`}
108+
data-tooltip-content={children}
109+
data-tooltip-place={'bottom'}
110+
123111
>
124-
{children}
125-
{typeof children === 'string' && <CustomThemedTooltip id={`tooltip-${label}`} />
126-
}
112+
{copy ? <CopyValue >{children}</CopyValue> : (children || '-')}
113+
<Tooltip
114+
id={`tooltip-${label}`}
115+
place="bottom"
116+
className="z-10"
117+
opacity={1}
118+
noArrow={false}
119+
/>
120+
127121
</div>
128122
</div>
129123
}
130124

131-
const LinkedValue = ({ children, type, className }: { className?: string, children: string, type: 'phone' | 'mail' }) => {
132-
if (!children) return <></>
125+
const CopyValue = ({ children, className }: { className?: string, children: string }) => {
126+
if (!children) return <>-</>
133127

134128
const onClick = () => {
135-
const url = (type === 'phone' ? 'callto://' : 'mailto://') + `${children.replace(/ /g, '')}`
136-
window.api.openExternalPage(url);
129+
window.api.copyToClipboard(children)
137130
}
138131

139132
return <div
140-
className={ClassNames(className, 'truncate cursor-pointer w-full flex flex-row items-center text-textBlueLight dark:text-textBlueDark font-normal gap-2 dark:focus:outline-none dark:focus:ring-2 focus:outline-none focus:ring-2 dark:ring-offset-1 ring-offset-1 dark:ring-offset-slate-900 ring-offset-slate-50 focus:ring-primaryRing dark:focus:ring-primaryRingDark rounded-md hover:underline')}
133+
className={ClassNames(className, 'relative cursor-pointer w-full flex flex-row items-center text-textBlueLight dark:text-textBlueDark font-normal gap-2 dark:focus:outline-none dark:focus:ring-2 focus:outline-none focus:ring-2 dark:ring-offset-1 ring-offset-1 dark:ring-offset-slate-900 ring-offset-slate-50 focus:ring-primaryRing dark:focus:ring-primaryRingDark rounded-md hover:underline')}
141134
onClick={onClick}
142135
>
143136
<span className='truncate'
144-
data-tooltip-id={`tooltip-${children}`}
145-
data-tooltip-content={children}
146137
>
147138
{children}
148139
</span>
149140
<FontAwesomeIcon
150141
className="text-base"
151142
icon={CopyIcon}
152143
/>
153-
<CustomThemedTooltip id={`tooltip-${children}`} />
144+
154145
</div>
155146

156-
}
147+
}

src/shared/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ export enum IPC_EVENTS {
9090
FULLSCREEN_EXIT = "FULLSCREEN_EXIT",
9191
SCREEN_SHARE_INIT = "SCREEN_SHARE_INIT",
9292
SCREEN_SHARE_SOURCES = "SCREEN_SHARE_SOURCES",
93-
CHANGE_SHORTCUT = 'CHANGE_SHORTCUT'
93+
CHANGE_SHORTCUT = 'CHANGE_SHORTCUT',
94+
COPY_TO_CLIPBOARD = "COPY_TO_CLIPBOARD"
9495
}
9596

9697
//PHONE ISLAND EVENTS

0 commit comments

Comments
 (0)