Skip to content

Commit

Permalink
Merge pull request #612 from MonobikashDas/develop
Browse files Browse the repository at this point in the history
#524 : model download issue fixed
  • Loading branch information
MonobikashDas authored Mar 7, 2023
2 parents 8867f3c + 72835b5 commit 5cf9610
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
16 changes: 3 additions & 13 deletions machines/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { init } from 'mosip-inji-face-sdk';
import { ContextFrom, EventFrom, send, StateFrom } from 'xstate';
import { createModel } from 'xstate/lib/model';
import getAllConfigurations from '../shared/commonprops/commonProps';
import { downloadModel } from '../shared/commonprops/commonProps';
import { AppServices } from '../shared/GlobalContext';
import { StoreEvents, StoreResponseEvent } from './store';

Expand Down Expand Up @@ -130,18 +130,8 @@ export const authMachine = model.createMachine(
},

services: {
downloadFaceSdkModel: () => async () => {
var injiProp = null;
try {
var injiProp = await getAllConfigurations();
const resp: string =
injiProp != null ? injiProp.faceSdkModelUrl : null;
if (resp != null) {
init(resp, false);
}
} catch (error) {
console.log(error);
}
downloadFaceSdkModel: () => () => {
downloadModel();
},
},

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"expo-status-bar": "~1.2.0",
"expo-updates": "~0.11.6",
"i18next": "^21.6.16",
"mosip-inji-face-sdk": "^0.1.7",
"mosip-inji-face-sdk": "^0.1.11",
"node-forge": "^1.3.1",
"react": "17.0.1",
"react-i18next": "^11.16.6",
Expand Down
21 changes: 21 additions & 0 deletions shared/commonprops/commonProps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { request } from '../request';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { init } from 'mosip-inji-face-sdk';

const COMMON_PROPS_KEY: string =
'CommonPropsKey-' + '6964d04a-9268-11ed-a1eb-0242ac120002';
Expand All @@ -22,6 +23,26 @@ export default async function getAllConfigurations() {
}
}

export async function downloadModel() {
try {
var injiProp = await getAllConfigurations();
const maxRetryStr = injiProp.modelDownloadMaxRetry;
const maxRetry = parseInt(maxRetryStr);
const resp: string = injiProp != null ? injiProp.faceSdkModelUrl : null;
if (resp != null) {
for (let counter = 0; counter < maxRetry; counter++) {
var result = await init(resp, false);
console.log('model download result is = ' + result);
if (result) {
break;
}
}
}
} catch (error) {
console.log(error);
}
}

export interface DownloadProps {
maxDownloadLimit: number;
downloadInterval: number;
Expand Down

0 comments on commit 5cf9610

Please sign in to comment.