Use grapheme-splitter instead of lodash for saving emoji from being ripped apart (#10976)
* Use grapheme-splitter instead of lodash for saving emoji from being ripped apart * Move to a more appropriate place * Add tests and improve types
This commit is contained in:
parent
277a3c0146
commit
f4a265b2c7
7 changed files with 55 additions and 22 deletions
|
@ -18,11 +18,11 @@ import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
|||
import { User } from "matrix-js-sdk/src/models/user";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { ResizeMethod } from "matrix-js-sdk/src/@types/partials";
|
||||
import { split } from "lodash";
|
||||
|
||||
import DMRoomMap from "./utils/DMRoomMap";
|
||||
import { mediaFromMxc } from "./customisations/Media";
|
||||
import { isLocalRoom } from "./utils/localRoom/isLocalRoom";
|
||||
import { getFirstGrapheme } from "./utils/strings";
|
||||
|
||||
// Not to be used for BaseAvatar urls as that has similar default avatar fallback already
|
||||
export function avatarUrlForMember(
|
||||
|
@ -133,8 +133,7 @@ export function getInitialLetter(name: string): string | undefined {
|
|||
name = name.substring(1);
|
||||
}
|
||||
|
||||
// rely on the grapheme cluster splitter in lodash so that we don't break apart compound emojis
|
||||
return split(name, "", 1)[0].toUpperCase();
|
||||
return getFirstGrapheme(name).toUpperCase();
|
||||
}
|
||||
|
||||
export function avatarUrlForRoom(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue