📶 fix: Mobile Stylings (#2639)

* chore: remove unused mobile nav

* fix: mobile nav fix for 'more' and 'archive' buttons div

* refactor(useTextarea): rewrite handleKeyUp for backwards compatibility

refactor(useTextarea): rewrite handleKeyUp for backwards compatibility

* experimental: add processing delay to azure streams for better performance/UX

* experiemental: adjust gpt-3 azureDelay

* fix: perplexity titles
This commit is contained in:
Danny Avila 2024-05-08 16:40:20 -04:00 committed by GitHub
parent b6d6343f54
commit 3c5fa40435
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 49 additions and 105 deletions

View file

@ -14,6 +14,11 @@ import store from '~/store';
type KeyEvent = KeyboardEvent<HTMLTextAreaElement>;
const keyMap = {
50: '2',
192: '@',
};
export default function useTextarea({
textAreaRef,
submitButtonRef,
@ -138,24 +143,30 @@ export default function useTextarea({
const handleKeyUp = useCallback(
(e: KeyEvent) => {
let isMention = false;
if (e.key === '@' || e.key === '2') {
const text = textAreaRef.current?.value;
isMention = !!(text && text[text.length - 1] === '@');
let normalizedKey = e.key;
if (!normalizedKey || normalizedKey === 'Unidentified') {
normalizedKey = keyMap[e.keyCode] || normalizedKey;
}
if (isMention) {
const startPos = textAreaRef.current?.selectionStart;
const isAtStart = startPos === 1;
const isPrecededBySpace =
startPos && textAreaRef.current?.value.charAt(startPos - 2) === ' ';
if (isAtStart || isPrecededBySpace) {
setShowMentionPopover(true);
} else {
setShowMentionPopover(false);
}
if (normalizedKey !== '@' && normalizedKey !== '2') {
return;
}
const text = textAreaRef.current?.value;
if (!(text && text[text.length - 1] === '@')) {
return;
}
const startPos = textAreaRef.current?.selectionStart;
if (!startPos) {
return;
}
const isAtStart = startPos === 1;
const isPrecededBySpace = textAreaRef.current?.value.charAt(startPos - 2) === ' ';
setShowMentionPopover(isAtStart || isPrecededBySpace);
},
[textAreaRef, setShowMentionPopover],
);