any-ascii: lazy load for code-splitting

This commit is contained in:
Hunter Miller 2022-03-24 19:22:47 -05:00
parent 6a5b0e3a83
commit a93c3975d7
3 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,6 @@ import f from 'lodash/fp';
import { Association, Patp } from '@urbit/api';
import { enableMapSet } from 'immer';
/* eslint-disable max-lines */
import anyAscii from 'any-ascii';
import bigInt, { BigInteger } from 'big-integer';
import { IconRef, Workspace } from '~/types';
@ -410,7 +409,8 @@ export function getContactDetails(contact: any) {
return { nickname, color, member, avatar };
}
export function stringToSymbol(str: string) {
export async function stringToSymbol(str: string) {
const anyAscii = (await import('any-ascii')).default;
const ascii = anyAscii(str);
let result = '';
for (let i = 0; i < ascii.length; i++) {

View File

@ -70,7 +70,7 @@ export function NewChannel(props: NewChannelProps): ReactElement {
const onSubmit = async (values: FormSchema, actions) => {
const name = channelName(values);
const resId: string =
stringToSymbol(values.name) +
await stringToSymbol(values.name) +
(workspace?.type !== 'messages'
? `-${Math.floor(Math.random() * 10000)}`
: '');

View File

@ -45,7 +45,7 @@ export function NewGroup(): ReactElement {
async (values: FormSchema, actions: FormikHelpers<FormSchema>) => {
try {
const { title, description, isPrivate } = values;
const name = stringToSymbol(title.trim());
const name = await stringToSymbol(title.trim());
const policy: Enc<GroupPolicy> = isPrivate
? {
invite: {