Skip to content

Commit b996143

Browse files
committed
cleanup
1 parent bcd7299 commit b996143

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

apps/desktop/src/routes/target-select-overlay.tsx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ import {
4343
const MIN_WIDTH = 200;
4444
const MIN_HEIGHT = 100;
4545

46-
const EMPTY_BOUNDS = {
46+
const EMPTY_BOUNDS = () => ({
4747
position: { x: 0, y: 0 },
4848
size: { width: 0, height: 0 },
49-
};
49+
});
5050

5151
const DEFAULT_BOUNDS = {
5252
position: { x: 100, y: 100 },
@@ -114,7 +114,7 @@ function Inner() {
114114
}));
115115

116116
const [bounds, setBounds] = createStore(
117-
structuredClone(isHoveredDisplay ? DEFAULT_BOUNDS : EMPTY_BOUNDS),
117+
structuredClone(isHoveredDisplay ? DEFAULT_BOUNDS : EMPTY_BOUNDS()),
118118
);
119119

120120
const { postMessage, onMessage } = makeBroadcastChannel<{ type: "reset" }>(
@@ -123,7 +123,7 @@ function Inner() {
123123
createEventListener(window, "mousedown", () =>
124124
postMessage({ type: "reset" }),
125125
);
126-
onMessage(() => setBounds(EMPTY_BOUNDS));
126+
onMessage(() => setBounds(EMPTY_BOUNDS()));
127127

128128
// We do this so any Cap window, (or external in the case of a bug) that are focused can trigger the close shortcut
129129
const unsubOnEscapePress = events.onEscapePress.listen(() => {
@@ -336,10 +336,10 @@ function Inner() {
336336
e.stopPropagation();
337337
createOnMouseDown((startBounds, delta) => {
338338
const width = startBounds.size.width - delta.x;
339-
const limitedWidth = Math.max(width, 150);
339+
const limitedWidth = Math.max(width, MIN_WIDTH);
340340

341341
const height = startBounds.size.height - delta.y;
342-
const limitedHeight = Math.max(height, 150);
342+
const limitedHeight = Math.max(height, MIN_HEIGHT);
343343

344344
setBounds({
345345
position: {
@@ -372,10 +372,10 @@ function Inner() {
372372
e.stopPropagation();
373373
createOnMouseDown((startBounds, delta) => {
374374
const width = startBounds.size.width + delta.x;
375-
const limitedWidth = Math.max(width, 150);
375+
const limitedWidth = Math.max(width, MIN_WIDTH);
376376

377377
const height = startBounds.size.height - delta.y;
378-
const limitedHeight = Math.max(height, 150);
378+
const limitedHeight = Math.max(height, MIN_HEIGHT);
379379

380380
setBounds({
381381
position: {
@@ -405,10 +405,10 @@ function Inner() {
405405
e.stopPropagation();
406406
createOnMouseDown((startBounds, delta) => {
407407
const width = startBounds.size.width - delta.x;
408-
const limitedWidth = Math.max(width, 150);
408+
const limitedWidth = Math.max(width, MIN_WIDTH);
409409

410410
const height = startBounds.size.height + delta.y;
411-
const limitedHeight = Math.max(height, 150);
411+
const limitedHeight = Math.max(height, MIN_HEIGHT);
412412

413413
setBounds({
414414
position: {
@@ -438,10 +438,10 @@ function Inner() {
438438
e.stopPropagation();
439439
createOnMouseDown((startBounds, delta) => {
440440
const width = startBounds.size.width + delta.x;
441-
const limitedWidth = Math.max(width, 150);
441+
const limitedWidth = Math.max(width, MIN_WIDTH);
442442

443443
const height = startBounds.size.height + delta.y;
444-
const limitedHeight = Math.max(height, 150);
444+
const limitedHeight = Math.max(height, MIN_HEIGHT);
445445

446446
setBounds({
447447
position: {
@@ -468,7 +468,7 @@ function Inner() {
468468
e.stopPropagation();
469469
createOnMouseDown((startBounds, delta) => {
470470
const height = startBounds.size.height - delta.y;
471-
const limitedHeight = Math.max(height, 150);
471+
const limitedHeight = Math.max(height, MIN_HEIGHT);
472472

473473
setBounds({
474474
position: {
@@ -504,7 +504,7 @@ function Inner() {
504504
},
505505
size: {
506506
width: Math.max(
507-
150,
507+
MIN_WIDTH,
508508
startBounds.size.width + delta.x,
509509
),
510510
height: startBounds.size.height,
@@ -532,7 +532,7 @@ function Inner() {
532532
size: {
533533
width: startBounds.size.width,
534534
height: Math.max(
535-
150,
535+
MIN_HEIGHT,
536536
startBounds.size.height + delta.y,
537537
),
538538
},
@@ -552,7 +552,7 @@ function Inner() {
552552
e.stopPropagation();
553553
createOnMouseDown((startBounds, delta) => {
554554
const width = startBounds.size.width - delta.x;
555-
const limitedWidth = Math.max(150, width);
555+
const limitedWidth = Math.max(MIN_WIDTH, width);
556556

557557
setBounds({
558558
position: {
@@ -655,10 +655,7 @@ function Inner() {
655655
setHasArea(true);
656656
} else {
657657
// Reset to no area if too small
658-
setBounds({
659-
position: { x: 0, y: 0 },
660-
size: { width: 0, height: 0 },
661-
});
658+
setBounds(EMPTY_BOUNDS());
662659
}
663660
dispose();
664661
},

0 commit comments

Comments
 (0)