Skip to content

Commit

Permalink
Copying from UI now uses electron's native clipboard management rathe…
Browse files Browse the repository at this point in the history
…r than a js solution.
  • Loading branch information
dgreene-r7 committed Apr 10, 2023
1 parent 4632ab9 commit 1f40db0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ contextBridge.exposeInMainWorld('electronAPI', {
refresh: () => ipcRenderer.invoke('refresh:get'),
getDarkMode: () => ipcRenderer.invoke('dark-mode:get'),
darkModeUpdated: (callback) => ipcRenderer.on('dark-mode:updated', callback),
copy: (args) => ipcRenderer.invoke('copy', args),
});
10 changes: 5 additions & 5 deletions src/containers/components/InputGroupWithCopyButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function InputGroupWithCopyButton(props) {
} = props;
const [tooltipState, setTooltipState] = useState(false);

const handleTooltipTargetClick = () => {
setTooltipState(!tooltipState);
navigator.clipboard.writeText(value);
const handleTooltipTargetClick = async () => {
setTooltipState(true);
await window.electronAPI.copy(value);

setTimeout(function () { // eslint-disable-line prefer-arrow-callback, func-names
setTooltipState(!tooltipState);
}, 1000);
setTooltipState(false);
}, 3000);
};

const id = `icon-${idFromProps}`;
Expand Down

0 comments on commit 1f40db0

Please sign in to comment.