Skip to content

Commit

Permalink
#1201 | Use 'uuid' package to generate random UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Nov 28, 2023
1 parent 6fed11a commit 5dd5778
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 21 deletions.
74 changes: 60 additions & 14 deletions packages/openchs-android/package-lock.json

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

6 changes: 4 additions & 2 deletions packages/openchs-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"lodash": "4.17.21",
"moment": "2.29.4",
"native-base": "3.4.9",
"openchs-models": "1.30.88",
"openchs-models": "1.30.91",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-native": "0.72.3",
Expand All @@ -73,6 +73,7 @@
"react-native-file-viewer": "2.1.5",
"react-native-fs": "2.20.0",
"react-native-geolocation-service": "5.3.0",
"react-native-get-random-values": "^1.10.0",
"react-native-i18n": "^0.1.1",
"react-native-image-picker": "5.3.1",
"react-native-image-zoom-viewer": "3.0.1",
Expand All @@ -96,7 +97,8 @@
"rn-fetch-blob": "0.13.0-beta-1",
"rules-config": "github:openchs/rules-config#fe552da405368bfd138e2f38e605c1d307e3ebe4",
"stacktrace-js": "2.0.2",
"transducers-js": "0.4.174"
"transducers-js": "0.4.174",
"uuid": "^9.0.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
8 changes: 3 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,8 @@ import {Concept, Duration, Observation} from 'avni-models';
import _ from 'lodash';
import moment from "moment";
import EnvironmentConfig from "../framework/EnvironmentConfig";
import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid';

let currentLogLevel;

Expand Down Expand Up @@ -178,12 +180,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 uuidv4();
}

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

0 comments on commit 5dd5778

Please sign in to comment.