only allow a single boost via hotkey - fixes #467 #468

As usual, have to write the same thing four times ☹

The parentheses around `q` tell the hotkey/keymap code to ignore
auto-repeat events (which works fine in Chrome but not in Firefox, I
reported the bug https://bugzilla.mozilla.org/show_bug.cgi?id=1900397
)

In addition, I've added a guard variable that is true while calling
the backend to boost/renote, and false otherwise. This way, even in
Firefox we don't spam-boost. Unboosting is still *only with the
mouse*, I have not added that functionality.
This commit is contained in:
dakkar 2024-06-07 11:40:44 +01:00
parent b2088e60b7
commit cb43994841
4 changed files with 20 additions and 12 deletions

View File

@ -328,10 +328,12 @@ function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string
return false;
}
let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'q': () => renote(appearNote.value.visibility),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'up|k|shift+tab': focusBefore,
'down|j|tab': focusAfter,
'esc': blur,
@ -436,7 +438,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => { renoting = false });
}
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
@ -455,7 +457,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => renoting = false);
}
}
}

View File

@ -336,10 +336,12 @@ if ($i) {
});
}
let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'q': () => renote(appearNote.value.visibility),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'esc': blur,
'm|o': () => showMenu(true),
's': () => showContent.value !== showContent.value,
@ -457,7 +459,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => { renoting = false });
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -474,7 +476,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => { renoting = false });
}
}

View File

@ -329,10 +329,12 @@ function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string
return false;
}
let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'q': () => renote(appearNote.value.visibility),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'up|k|shift+tab': focusBefore,
'down|j|tab': focusAfter,
'esc': blur,
@ -437,7 +439,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => { renoting = false });
}
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
@ -456,7 +458,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => { renoting = false });
}
}
}

View File

@ -345,10 +345,12 @@ if ($i) {
});
}
let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'q': () => renote(appearNote.value.visibility),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'esc': blur,
'm|o': () => showMenu(true),
's': () => showContent.value !== showContent.value,
@ -466,7 +468,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => { renoting = false });
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -483,7 +485,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
}).then(() => { renoting = false });
}
}