Skip to content

Move uuidv4 to helper to avoid circular dependency with React Compiler #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/Downloader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NativeEventEmitter, Platform } from 'react-native';
import type { NativeEventSubscription } from 'react-native';
import { Compressor } from '../Main';
const CompressEventEmitter = new NativeEventEmitter(Compressor);
import { uuidv4 } from './index';
import { uuidv4 } from './helpers';
export const download = async (
fileUrl: string,
downloadProgress?: (progress: number) => void,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NativeEventEmitter, Platform } from 'react-native';
import type { NativeEventSubscription } from 'react-native';
import { Compressor } from '../Main';
const CompressEventEmitter = new NativeEventEmitter(Compressor);
import { uuidv4 } from './index';
import { uuidv4 } from './helpers';
export enum UploadType {
BINARY_CONTENT = 0,
MULTIPART = 1,
Expand Down
15 changes: 15 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const uuidv4 = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r =
(parseFloat(
'0.' +
Math.random().toString().replace('0.', '') +
new Date().getTime()
) *
16) |
0,
// eslint-disable-next-line eqeqeq
v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
};
16 changes: 1 addition & 15 deletions src/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,20 +194,6 @@ export const getFileSize = async (filePath: string): Promise<string> => {
return Compressor.getFileSize(filePath);
};

export const uuidv4 = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r =
(parseFloat(
'0.' +
Math.random().toString().replace('0.', '') +
new Date().getTime()
) *
16) |
0,
// eslint-disable-next-line eqeqeq
v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
};
export * from './Downloader';
export * from './Uploader';
export * from './helpers';