fix: picker emoji-mart errors after update

pull/2840/head
Audric Ackermann 2 years ago
parent d43d6abbae
commit feaba36fa4

@ -118,7 +118,7 @@ module.exports = {
},
{
files: ['ts/node/**/*.ts', 'ts/test/**/*.ts'],
rules: { 'no-console': 'off' },
rules: { 'no-console': 'off', 'import/no-extraneous-dependencies': 'off' },
},
],
};

@ -71,8 +71,8 @@
"worker:libsession": "rimraf 'ts/webworker/workers/node/libsession/*.node' && webpack --config=./libsession.worker.config.js"
},
"dependencies": {
"@emoji-mart/data": "^1.0.6",
"@emoji-mart/react": "^1.0.1",
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@reduxjs/toolkit": "1.8.5",
"@signalapp/better-sqlite3": "^8.4.3",
"@types/react-mentions": "^4.1.8",
@ -93,7 +93,7 @@
"dompurify": "^2.0.7",
"electron-localshortcut": "^3.2.1",
"electron-updater": "^4.2.2",
"emoji-mart": "^5.2.2",
"emoji-mart": "^5.5.2",
"filesize": "3.6.1",
"firstline": "1.2.1",
"fs-extra": "9.0.0",
@ -154,7 +154,6 @@
"@types/config": "0.0.34",
"@types/dompurify": "^2.0.0",
"@types/electron-localshortcut": "^3.1.0",
"@types/emoji-mart": "3.0.9",
"@types/filesize": "3.6.0",
"@types/firstline": "^2.0.2",
"@types/fs-extra": "5.0.5",

@ -1,10 +1,10 @@
import React, { forwardRef } from 'react';
import classNames from 'classnames';
import styled from 'styled-components';
import Picker from '@emoji-mart/react';
import { useSelector } from 'react-redux';
import Picker from '@emoji-mart/react';
import { getTheme, isDarkTheme } from '../../state/selectors/theme';
import { FixedBaseEmoji, FixedPickerProps } from '../../types/Reaction';
import {
COLORS,
ColorsType,
@ -16,6 +16,7 @@ import {
import { hexColorToRGB } from '../../util/hexColorToRGB';
import { getPrimaryColor } from '../../state/selectors/primaryColor';
import { i18nEmojiData } from '../../util/emoji';
import { FixedBaseEmoji } from '../../types/Reaction';
export const StyledEmojiPanel = styled.div<{
isModal: boolean;
@ -90,7 +91,7 @@ type Props = {
onKeyDown?: (event: any) => void;
};
const pickerProps: FixedPickerProps = {
const pickerProps = {
title: '',
showPreview: true,
autoFocus: true,

@ -102,7 +102,7 @@ export const OverlayCommunity = () => {
<SessionButton text={buttonText} disabled={!groupUrl} onClick={onTryJoinRoom} />
<SessionSpinner loading={loading} />
<SessionJoinableRooms onJoinClick={() => void onTryJoinRoom()} alreadyJoining={loading} />
<SessionJoinableRooms onJoinClick={url => void onTryJoinRoom(url)} alreadyJoining={loading} />
</div>
);
};

@ -637,13 +637,13 @@ function getPubkeysInPublicConversation(conversationId: string) {
conversation.capabilities?.includes('blind')
);
const whereClause = hasBlindOn ? 'AND source LIKE "15%"' : '';
const whereClause = hasBlindOn ? "AND source LIKE '15%'" : ''; // the LIKE content has to be ' and not "
const rows = assertGlobalInstance()
.prepare(
`SELECT DISTINCT source FROM ${MESSAGES_TABLE} WHERE
conversationId = $conversationId ${whereClause}
ORDER BY received_at DESC LIMIT ${MAX_PUBKEYS_MEMBERS};`
conversationId = $conversationId ${whereClause}
ORDER BY received_at DESC LIMIT ${MAX_PUBKEYS_MEMBERS};`
)
.all({
conversationId,

@ -2,12 +2,7 @@ import { AbortSignal } from 'abort-controller';
import { getEmojiDataFromNative } from 'emoji-mart';
import { Data } from '../../../../data/data';
import { ConversationModel } from '../../../../models/conversation';
import {
Action,
FixedBaseEmoji,
OpenGroupReactionResponse,
Reaction,
} from '../../../../types/Reaction';
import { Action, OpenGroupReactionResponse, Reaction } from '../../../../types/Reaction';
import { Reactions } from '../../../../util/reactions';
import { OnionSending } from '../../../onions/onionSend';
import { ToastUtils, UserUtils } from '../../../utils';
@ -74,7 +69,8 @@ export const sendSogsReactionOnionV4 = async (
// The SOGS endpoint supports any text input so we need to make sure we are sending a valid unicode emoji
// for an invalid input we use https://emojipedia.org/frame-with-an-x/ as a replacement since it cannot rendered as an emoji but is valid unicode
// NOTE emoji-mart v5.2.2 types for getEmojiDataFromNative are broken
const emoji = (getEmojiDataFromNative(reaction.emoji) as FixedBaseEmoji) ? reaction.emoji : '🖾';
// eslint-disable-next-line @typescript-eslint/await-thenable
const emoji = (await getEmojiDataFromNative(reaction.emoji)) ? reaction.emoji : '🖾';
const endpoint = `/room/${room}/reaction/${reaction.id}/${emoji}`;
const method = reaction.action === Action.REACT ? 'PUT' : 'DELETE';
const serverPubkey = allValidRoomInfos[0].serverPublicKey;

@ -71,7 +71,7 @@ describe('BlockedNumberController', () => {
const blockedNumbers = BlockedNumberController.getBlockedNumbers();
expect(blockedNumbers.length).to.be.eq(0);
expect(Object.keys(memoryDB.blocked)).to.be.be.eq(0);
expect(Object.keys(memoryDB.blocked).length).to.be.be.eq(0);
});
it('should only unblock if a device was blocked', async () => {

@ -1,4 +1,4 @@
import { EmojiSet, PartialI18n } from 'emoji-mart';
import { Emoji, EmojiMartData } from '@emoji-mart/data';
export const reactionLimit: number = 6;
@ -30,14 +30,7 @@ export class RecentReactions {
}
}
type BaseEmojiSkin = { unified: string; native: string };
export interface FixedBaseEmoji {
id: string;
name: string;
keywords: Array<string>;
skins: Array<BaseEmojiSkin>;
version: number;
export interface FixedBaseEmoji extends Emoji {
search?: string;
// props from emoji panel click event
native?: string;
@ -46,64 +39,10 @@ export interface FixedBaseEmoji {
unified?: string;
}
export interface NativeEmojiData {
categories: Array<{ id: string; emojis: Array<string> }>;
emojis: Record<string, FixedBaseEmoji>;
aliases: Record<string, string>;
sheet: { cols: number; rows: number };
export interface NativeEmojiData extends EmojiMartData {
ariaLabels?: Record<string, string>;
}
// Types for EmojiMart 5 are currently broken these are a temporary fixes
export interface FixedPickerProps {
autoFocus?: boolean | undefined;
title?: string | undefined;
theme?: 'auto' | 'light' | 'dark' | undefined;
perLine?: number | undefined;
stickySearch?: boolean | undefined;
searchPosition?: 'sticky' | 'static' | 'none' | undefined;
emojiButtonSize?: number | undefined;
emojiButtonRadius?: number | undefined;
emojiButtonColors?: string | undefined;
maxFrequentRows?: number | undefined;
icons?: 'auto' | 'outline' | 'solid';
set?: EmojiSet | undefined;
emoji?: string | undefined;
navPosition?: 'bottom' | 'top' | 'none' | undefined;
showPreview?: boolean | undefined;
previewEmoji?: boolean | undefined;
noResultsEmoji?: string | undefined;
previewPosition?: 'bottom' | 'top' | 'none' | undefined;
skinTonePosition?: 'preview' | 'search' | 'none';
i18n?: PartialI18n | undefined;
onEmojiSelect?: (emoji: FixedBaseEmoji) => void;
onClickOutside?: () => void;
onKeyDown?: (event: any) => void;
onAddCustomEmoji?: () => void;
getImageURL?: () => void;
getSpritesheetURL?: () => void;
// Below here I'm currently unsure of usage
// style?: React.CSSProperties | undefined;
// color?: string | undefined;
// skin?: EmojiSkin | undefined;
// defaultSkin?: EmojiSkin | undefined;
// backgroundImageFn?: BackgroundImageFn | undefined;
// sheetSize?: EmojiSheetSize | undefined;
// emojisToShowFilter?(emoji: EmojiData): boolean;
// showSkinTones?: boolean | undefined;
// emojiTooltip?: boolean | undefined;
// include?: CategoryName[] | undefined;
// exclude?: CategoryName[] | undefined;
// recent?: string[] | undefined;
// /** NOTE: custom emoji are copied into a singleton object on every new mount */
// custom?: CustomEmoji[] | undefined;
// skinEmoji?: string | undefined;
// notFound?(): React.Component;
// notFoundEmoji?: string | undefined;
// enableFrequentEmojiSort?: boolean | undefined;
// useButton?: boolean | undefined;
}
export enum Action {
REACT = 0,
REMOVE = 1,

@ -2,7 +2,7 @@
/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
/* eslint-disable import/no-mutable-exports */
import { PartialI18n, init } from 'emoji-mart';
import { init, I18n } from 'emoji-mart';
import { FixedBaseEmoji, NativeEmojiData } from '../types/Reaction';
import { loadEmojiPanelI18n } from './i18n';
@ -47,7 +47,7 @@ export function getEmojiSizeClass(str: string): SizeClassType {
}
export let nativeEmojiData: NativeEmojiData | null = null;
export let i18nEmojiData: PartialI18n | null = null;
export let i18nEmojiData: typeof I18n | null = null;
export async function initialiseEmojiData(data: any): Promise<void> {
const ariaLabels: Record<string, string> = {};
@ -85,7 +85,7 @@ export async function initialiseEmojiData(data: any): Promise<void> {
i18nEmojiData = await loadEmojiPanelI18n();
// Data needs to be initialised once per page load for the emoji components
// See https://github.com/missive/emoji-mart#%EF%B8%8F%EF%B8%8F-headless-search
init({ data, i18n: i18nEmojiData });
await init({ data, i18n: i18nEmojiData });
}
// Synchronous version of Emoji Mart's SearchIndex.search()

@ -508,15 +508,15 @@
minimatch "^3.0.4"
plist "^3.0.4"
"@emoji-mart/data@^1.0.6":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@emoji-mart/data/-/data-1.0.6.tgz#68f71be5e023653a3f9f73f4beadfd50848e2131"
integrity sha512-8wu3ec/kLCB0Y3K+pOKyY6Ob+xtQu3XhZvntdrpOTUQZ/PO6FW5PpFw7RE1kQ/up1fsVSJBl5mZ8Gs4SPwTYeg==
"@emoji-mart/data@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@emoji-mart/data/-/data-1.1.2.tgz#777c976f8f143df47cbb23a7077c9ca9fe5fc513"
integrity sha512-1HP8BxD2azjqWJvxIaWAMyTySeZY0Osr83ukYjltPVkNXeJvTz7yDrPLBtnrD5uqJ3tg4CcLuuBW09wahqL/fg==
"@emoji-mart/react@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@emoji-mart/react/-/react-1.0.1.tgz#46b6a2e92faf16fa9b7f9471f137fa2e3d1e8ac3"
integrity sha512-ALhLD96BOL5w+a4NI5NpmfqfF1aVjjj2qJE0dLst/OhjBfVmpteWNgn/h8LZy9ulU6AnbeS+13KnPFzDjCvRRw==
"@emoji-mart/react@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@emoji-mart/react/-/react-1.1.1.tgz#ddad52f93a25baf31c5383c3e7e4c6e05554312a"
integrity sha512-NMlFNeWgv1//uPsvLxvGQoIerPuVdXwK/EUek8OOkJ6wVOWPUizRBJU0hDqWZCOROVpfBgCemaC3m6jDOXi03g==
"@emotion/is-prop-valid@^0.8.8":
version "0.8.8"
@ -1010,13 +1010,6 @@
dependencies:
electron "*"
"@types/emoji-mart@3.0.9":
version "3.0.9"
resolved "https://registry.yarnpkg.com/@types/emoji-mart/-/emoji-mart-3.0.9.tgz#2f7ef5d9ec194f28029c46c81a5fc1e5b0efa73c"
integrity sha512-qdBo/2Y8MXaJ/2spKjDZocuq79GpnOhkwMHnK2GnVFa8WYFgfA+ei6sil3aeWQPCreOKIx9ogPpR5+7MaOqYAA==
dependencies:
"@types/react" "*"
"@types/eslint-scope@^3.7.3":
version "3.7.4"
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16"
@ -3403,10 +3396,10 @@ electron@*, electron@25.3.0:
"@types/node" "^18.11.18"
extract-zip "^2.0.1"
emoji-mart@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/emoji-mart/-/emoji-mart-5.2.2.tgz#1c093ffc19554dd6edfcfeec9aca43ff38bcc16e"
integrity sha512-BvcrX+Ps9MxSVEjnvxupclU3MBD6WVC4WZOY26csfC6oFdaWpFhdrzeVNVBmCLPOmzY1SE0aAsqZJRNVbZ1yhQ==
emoji-mart@^5.5.2:
version "5.5.2"
resolved "https://registry.yarnpkg.com/emoji-mart/-/emoji-mart-5.5.2.tgz#3ddbaf053139cf4aa217650078bc1c50ca8381af"
integrity sha512-Sqc/nso4cjxhOwWJsp9xkVm8OF5c+mJLZJFoFfzRuKO+yWiN7K8c96xmtughYb0d/fZ8UC6cLIQ/p4BR6Pv3/A==
emoji-regex@^8.0.0:
version "8.0.0"

Loading…
Cancel
Save