Skip to content

Commit 5897ac7

Browse files
tonyco97edospadoni
andauthored
chore(dep): update phone-island (#62)
Co-authored-by: Edoardo Spadoni <[email protected]>
1 parent ce9101b commit 5897ac7

File tree

4 files changed

+95
-126
lines changed

4 files changed

+95
-126
lines changed

.github/workflows/build-dev.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ jobs:
4141
- name: Enable code signing only for current repo
4242
if: github.event.pull_request.head.repo.full_name == github.repository
4343
run: echo "CSC_FOR_PULL_REQUEST=true" >> $GITHUB_ENV
44+
45+
- name: Set dev version
46+
run: |
47+
echo "Creating patch-version.js"
48+
cat << 'EOF' > patch-version.js
49+
const fs = require('fs');
50+
const pkg = require('./package.json');
51+
const sha = process.env.COMMIT_SHA.slice(0, 7);
52+
const pr = process.env.PR_NUMBER;
53+
const baseVersion = pkg.version.replace(/-dev.*$/, '');
54+
pkg.version = `${baseVersion}-dev.pr${pr}.${sha}`;
55+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
56+
console.log("Updated version:", pkg.version);
57+
EOF
58+
node patch-version.js
59+
shell: bash
60+
env:
61+
GITHUB_SHA: ${{ github.sha }}
62+
PR_NUMBER: ${{ github.event.pull_request.number }}
63+
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
4464

4565
- name: Build/release Electron app
4666
uses: samuelmeuli/action-electron-builder@v1

package-lock.json

Lines changed: 41 additions & 111 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands",
5050
"@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light",
5151
"@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid",
52-
"@nethesis/phone-island": "^0.13.6",
52+
"@nethesis/phone-island": "^0.14.0",
5353
"@tailwindcss/forms": "^0.5.7",
5454
"@types/lodash": "^4.14.202",
5555
"@types/node": "^18.19.9",

src/renderer/src/components/ElectronDraggableWindow.tsx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const ElectronDraggableWindow = ({ children }) => {
1010
const mouseDownEvent = useRef<MouseEvent | null>(null)
1111
const mouseUpEvent = useRef<MouseEvent | null>(null)
1212
const target = useRef<EventTarget | null>(null)
13+
const lastMouseDownTime = useRef<number>(0)
1314

1415
const handleMouseClick = (e: MouseEvent) => {
1516
if (e['pointerId'] !== -1) {
@@ -28,6 +29,12 @@ export const ElectronDraggableWindow = ({ children }) => {
2829
};
2930

3031
const handleMouseDown = (e: MouseEvent) => {
32+
const now = Date.now();
33+
if (now - lastMouseDownTime.current < 100) {
34+
return;
35+
}
36+
lastMouseDownTime.current = now;
37+
3138
if (!isDrag.current && !mouseDownEvent.current) {
3239
target.current = e.target
3340
passthroughEvent.current = false
@@ -45,16 +52,28 @@ export const ElectronDraggableWindow = ({ children }) => {
4552
mouseUpEvent.current = e
4653
};
4754

55+
const handleMouseLeave = () => {
56+
if (isDrag.current) {
57+
window.electron.send(IPC_EVENTS.STOP_DRAG);
58+
isDrag.current = false;
59+
mouseDownEvent.current = null;
60+
}
61+
};
62+
63+
const handleWindowBlur = () => {
64+
if (isDrag.current) {
65+
isDrag.current = false;
66+
mouseDownEvent.current = null;
67+
window.electron.send(IPC_EVENTS.STOP_DRAG);
68+
}
69+
};
70+
4871
useEffect(() => {
49-
document.addEventListener('click', handleMouseClick, {
50-
capture: true,
51-
});
52-
document.addEventListener('mousedown', handleMouseDown, {
53-
capture: true,
54-
});
55-
document.addEventListener('mouseup', handleMouseUp, {
56-
capture: true,
57-
});
72+
document.addEventListener('click', handleMouseClick, { capture: true });
73+
document.addEventListener('mousedown', handleMouseDown, { capture: true });
74+
document.addEventListener('mouseup', handleMouseUp, { capture: true });
75+
window.addEventListener('mouseleave', handleMouseLeave);
76+
window.addEventListener('blur', handleWindowBlur);
5877

5978
window.electron.receive(IPC_EVENTS.ENABLE_CLICK, () => {
6079
if (target.current && !passthroughEvent.current) {
@@ -64,18 +83,19 @@ export const ElectronDraggableWindow = ({ children }) => {
6483
cancelable: true,
6584
view: window,
6685
});
67-
//we create an untrusted event, with this property we ensure that this event was created by us
6886
newEvent['nethlink'] = true
6987
target.current.dispatchEvent(newEvent);
7088
}
71-
})
89+
});
7290

7391
return () => {
7492
document.removeEventListener('click', handleMouseClick);
7593
document.removeEventListener('mousedown', handleMouseDown);
7694
document.removeEventListener('mouseup', handleMouseUp);
95+
window.removeEventListener('mouseleave', handleMouseLeave);
96+
window.removeEventListener('blur', handleWindowBlur);
7797
};
78-
}, [handleMouseUp]);
98+
}, []);
7999

80100
return (
81101
<div
@@ -84,5 +104,4 @@ export const ElectronDraggableWindow = ({ children }) => {
84104
{children}
85105
</div>
86106
);
87-
};
88-
107+
};

0 commit comments

Comments
 (0)