Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent freq used order change during shift hold #7168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/modules/emote_menu/components/EmoteMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ function setKeyPressCallback(newKeyPressCallback) {
keyPressCallback = newKeyPressCallback;
}

const cachedEmoteClicks = new Map();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pendingEmoteHistory


function cacheOrProcessEmoteClicks(emote, shiftPressed) {
if (emote && !cachedEmoteClicks.has(emote.canonicalId)) {
cachedEmoteClicks.set(emote.canonicalId, emote);
}
if (!shiftPressed && cachedEmoteClicks.size > 0) {
cachedEmoteClicks.forEach((cachedEmote) => emoteMenuViewStore.trackHistory(cachedEmote));
cachedEmoteClicks.clear();
}
}

export default function EmoteMenu({toggleWhisper, appendToChat, onSetTip}) {
const [search, setSearch] = useState('');
const [selected, setSelected] = useState(null);
Expand All @@ -40,7 +52,7 @@ export default function EmoteMenu({toggleWhisper, appendToChat, onSetTip}) {
}

appendToChat(emote, !shiftPressed);
emoteMenuViewStore.trackHistory(emote);
cacheOrProcessEmoteClicks(emote, shiftPressed);

if (shiftPressed) {
markTipAsSeen(EmoteMenuTips.EMOTE_MENU_PREVENT_CLOSE);
Expand All @@ -56,6 +68,9 @@ export default function EmoteMenu({toggleWhisper, appendToChat, onSetTip}) {
function buttonPressCallback(event) {
setAltPressed(event.altKey);
setShiftPressed(event.shiftKey);
if (!event.shiftKey) {
cacheOrProcessEmoteClicks(null, false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the popout is closed via other means (clicking out of the popout or closing it via the X in the upper right), these track events are lost. this operation may need to be in the parent. since appendToChat is a parent function, perhaps the track could be moved there instead.

}
}

function callback(event) {
Expand Down