Skip to content

Commit d9be4d1

Browse files
committed
completely fix floating stop
1 parent 89fe830 commit d9be4d1

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

floating.html

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</div>
2727
<div id="floating-hover" onmouseover="hover()" onmouseleave="unhover()" ontouchstart="semihover()">
2828
<div class="small" id="floating-stopper" style="margin-top: 8px;">
29-
<a id="stopper" href="javascript:stopper()" class="text-muted" draggable="false">
29+
<a id="stopper" href="#" role="button" class="text-muted" draggable="false">
3030
<i class="iconfont icon-pause"></i>
3131
</a>
3232
<div id="stopper-spacing"><br /><br /></div>
@@ -58,6 +58,17 @@
5858
$('#skipper').attr('title', i18n.__('skipper'));
5959
$('#recover').attr('title', i18n.__('recover'));
6060
$('#exit').attr('title', i18n.__('exit'));
61+
(function () {
62+
var el = document.getElementById('stopper');
63+
function handleStopper(e) {
64+
e.preventDefault();
65+
e.stopPropagation();
66+
stopper(e);
67+
return false;
68+
}
69+
el.addEventListener('mousedown', handleStopper, true);
70+
el.addEventListener('click', handleStopper, true);
71+
})();
6172
</script>
6273
</div>
6374
</div><!-- for things with 'work' mark, when it's resting, the color should be changed -->
@@ -91,19 +102,23 @@
91102
}
92103
}
93104

94-
function stopper() {
105+
const STOPPER_DEBOUNCE_MS = 320;
106+
function stopper(ev) {
107+
if (ev && ev.preventDefault) ev.preventDefault();
108+
var now = Date.now();
109+
if (lastActionAt && now - lastActionAt < STOPPER_DEBOUNCE_MS) return false;
110+
95111
let baseWorking = lastMessageWorking;
96112
if (baseWorking === null) baseWorking = isWorking;
97-
if (baseWorking === null) {
98-
return;
99-
}
113+
if (baseWorking === null) baseWorking = true;
100114

101115
desiredWorking = !baseWorking;
102116
isWorking = desiredWorking;
103-
lastActionAt = Date.now();
117+
lastActionAt = now;
104118
stopSyncPending = true;
105119
renderStopperIcon(isWorking);
106120
ipc.send("floating-conversation", { topic: "stop-set", desiredWorking: desiredWorking });
121+
return false;
107122
}
108123

109124
function skipper() {

0 commit comments

Comments
 (0)