🐛 Several bugfixes (#7062)

* 🐛 Fix incorrect status validation on subscription internal api

* 🐛 Make the shortcuts overwritting optional
This commit is contained in:
Andrey Antukh 2025-08-04 13:54:29 +02:00 committed by GitHub
parent ded8e39e73
commit 85f6cf32ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 18 deletions

View file

@ -186,7 +186,7 @@
"canceled"
"incomplete"
"incomplete_expired"
"pass_due"
"past_due"
"paused"
"trialing"
"unpaid"]]

View file

@ -148,17 +148,17 @@
(defn- bind!
[shortcuts]
(let [msbind (fn [command callback type]
(->> shortcuts
(remove #(:disabled (second %)))
(run! (fn [[key {:keys [command fn type overwrite]}]]
(let [callback (wrap-cb key fn)
undefined (js* "(void 0)")
commands (if (vector? command)
(into-array command)
#js [command])]
(if type
(mousetrap/bind command callback type)
(mousetrap/bind command callback)))]
(->> shortcuts
(remove #(:disabled (second %)))
(run! (fn [[key {:keys [command fn type]}]]
(let [callback (wrap-cb key fn)]
(if (vector? command)
(run! #(msbind % callback type) command)
(msbind command callback type))))))))
(mousetrap/bind commands callback type overwrite)
(mousetrap/bind commands callback undefined overwrite)))))))
(defn- reset!
([]

View file

@ -24,5 +24,6 @@
{:delete-stop {:tooltip (ds/supr)
:command ["del" "backspace"]
:subsections [:edit]
:overwrite true
:fn #(st/emit! (dwc/remove-gradient-stop))}}))

View file

@ -821,7 +821,7 @@ function Mousetrap(targetElement) {
* @param {number=} level - what part of the sequence the command is
* @returns void
*/
function _bindSingle(combination, callback, action, sequenceName, level) {
function _bindSingle(combination, callback, action, sequenceName, level, overwrite) {
// store a direct mapped reference for use with Mousetrap.trigger
self._directMap[combination + ':' + action] = callback;
@ -845,8 +845,10 @@ function Mousetrap(targetElement) {
// a callback is added for this key
self._callbacks[info.key] = self._callbacks[info.key] || [];
// // remove an existing match if there is one
// _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
// remove an existing match if there is one
if (overwrite) {
_getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
}
// add this call back to the array
// if it is a sequence put it at the beginning
@ -872,9 +874,9 @@ function Mousetrap(targetElement) {
* @param {string|undefined} action
* @returns void
*/
self._bindMultiple = function(combinations, callback, action) {
self._bindMultiple = function(combinations, callback, action, overwrite) {
for (var i = 0; i < combinations.length; ++i) {
_bindSingle(combinations[i], callback, action);
_bindSingle(combinations[i], callback, action, undefined, undefined, overwrite);
}
};
@ -899,10 +901,10 @@ function Mousetrap(targetElement) {
* @param {string=} action - 'keypress', 'keydown', or 'keyup'
* @returns void
*/
Mousetrap.prototype.bind = function(keys, callback, action) {
Mousetrap.prototype.bind = function(keys, callback, action, overwrite) {
var self = this;
keys = keys instanceof Array ? keys : [keys];
self._bindMultiple.call(self, keys, callback, action);
self._bindMultiple.call(self, keys, callback, action, overwrite);
return self;
};