File tree Expand file tree Collapse file tree 7 files changed +10
-21
lines changed Expand file tree Collapse file tree 7 files changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ import {
3636 ThreadProvider ,
3737} from '../../contexts/threadContext/ThreadContext' ;
3838import { useTranslationContext } from '../../contexts/translationContext/TranslationContext' ;
39- import { emojiData as emojiDataDefault , randomId } from '../../utils/utils' ;
39+ import { emojiData as emojiDataDefault } from '../../utils/utils' ;
4040
4141import type { LoadingErrorProps } from '../Indicators/LoadingErrorIndicator' ;
4242import type { LoadingProps } from '../Indicators/LoadingIndicator' ;
@@ -52,6 +52,7 @@ import type {
5252 DefaultUserType ,
5353 UnknownType ,
5454} from '../../types/types' ;
55+ import { generateRandomId } from '../../utils/generateRandomId' ;
5556
5657export type ChannelProps <
5758 At extends UnknownType = DefaultAttachmentType ,
@@ -454,7 +455,7 @@ export const Channel = <
454455 attachments,
455456 created_at : new Date ( ) ,
456457 html : text ,
457- id : `${ client . userID } -${ randomId ( ) } ` ,
458+ id : `${ client . userID } -${ generateRandomId ( ) } ` ,
458459 mentioned_users :
459460 mentioned_users ?. map ( ( userId ) => ( {
460461 id : userId ,
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ export const usePaginatedChannels = <
6161 const [ loadingNextPage , setLoadingNextPage ] = useState ( false ) ;
6262 const [ offset , setOffset ] = useState ( 0 ) ;
6363 const [ refreshing , setRefreshing ] = useState ( false ) ;
64- const lastRefresh = useRef ( new Date ( ) . getTime ( ) ) ;
64+ const lastRefresh = useRef ( Date . now ( ) ) ;
6565
6666 const queryChannels = async (
6767 queryType = '' ,
@@ -128,7 +128,7 @@ export const usePaginatedChannels = <
128128 return ;
129129 }
130130
131- lastRefresh . current = new Date ( ) . getTime ( ) ;
131+ lastRefresh . current = Date . now ( ) ;
132132 return queryChannels ( 'refresh' ) ;
133133 } ;
134134
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ import {
4141 ImageUpload ,
4242 useMessageDetailsForState ,
4343} from './hooks/useMessageDetailsForState' ;
44- import { generateRandomId } from './utils/generateRandomId' ;
44+ import { generateRandomId } from '../.. /utils/generateRandomId' ;
4545
4646import {
4747 AutoCompleteInput ,
Original file line number Diff line number Diff line change 11import { useEffect , useState } from 'react' ;
22
3- import { generateRandomId } from '../utils/generateRandomId' ;
3+ import { generateRandomId } from '../../../ utils/generateRandomId' ;
44
55import {
66 isEditingBoolean ,
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ import type {
6060} from '../../types/types' ;
6161
6262import { NetworkDownIndicator as DefaultNetworkDownIndicator } from './NetworkDownIndicator' ;
63- import { randomId } from 'src/utils /utils' ;
63+ import { generateRandomId } from '../.. /utils/generateRandomId ' ;
6464
6565const ListContainer = ( styled ( FlatList ) `
6666 flex: 1;
@@ -87,13 +87,13 @@ const keyExtractor = <
8787 ? typeof item . created_at === 'string'
8888 ? item . created_at
8989 : item . created_at . toISOString ( )
90- : randomId ( ) )
90+ : generateRandomId ( ) )
9191 ) ;
9292 }
9393 if ( item . date && typeof item . date !== 'string' ) {
9494 return item . date . toISOString ( ) ;
9595 }
96- return randomId ( ) ;
96+ return generateRandomId ( ) ;
9797} ;
9898
9999export type MessageListProps <
File renamed without changes.
Original file line number Diff line number Diff line change @@ -376,15 +376,3 @@ export const MESSAGE_ACTIONS = {
376376
377377export const makeImageCompatibleUrl = ( url : string ) =>
378378 ( url . indexOf ( '//' ) === 0 ? `https:${ url } ` : url ) . trim ( ) ;
379-
380- /** adopted from https://github.com/ai/nanoid/blob/master/non-secure/index.js */
381- const alphabet =
382- 'ModuleSymbhasOwnPr0123456789ABCDEFGHNRVfgctiUvzKqYTJkLxpZXIjQW' ;
383- export const randomId = ( ) => {
384- let id = '' ;
385- for ( let i = 0 ; i < 21 ; i ++ ) {
386- // eslint-disable-next-line no-bitwise
387- id += alphabet [ ( Math . random ( ) * 64 ) | 0 ] ;
388- }
389- return id ;
390- } ;
You can’t perform that action at this time.
0 commit comments