Skip to content

Commit

Permalink
#1201 | Use crypto.randomUUID to generate random v4 uuids
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Nov 28, 2023
1 parent fa5254d commit 9aac1b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
20 changes: 20 additions & 0 deletions packages/openchs-android/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/openchs-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"react-native-keep-awake": "^4.0.0",
"react-native-keychain": "^8.1.1",
"react-native-mime-types": "2.3.0",
"react-native-random-uuid": "^0.1.4",
"react-native-randombytes": "^3.6.1",
"react-native-restart": "0.0.24",
"react-native-safe-area-context": "4.3.1",
Expand Down
7 changes: 2 additions & 5 deletions packages/openchs-android/src/utility/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Concept, Duration, Observation} from 'avni-models';
import _ from 'lodash';
import moment from "moment";
import EnvironmentConfig from "../framework/EnvironmentConfig";
import 'react-native-random-uuid'

let currentLogLevel;

Expand Down Expand Up @@ -178,12 +179,8 @@ class General {
return dest;
}

//http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
static randomUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
return crypto.randomUUID();
}

static objectsShallowEquals(a: Object, b: Object): Boolean {
Expand Down

0 comments on commit 9aac1b8

Please sign in to comment.