Skip to content
Merged
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
5 changes: 1 addition & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,7 @@ export class AppComponent implements OnInit, AfterViewInit {
&& !(await this.commonUtilService.isIpLocationAvailable())) {
this.deviceRegisterService.getDeviceProfile().toPromise().then(async (response) => {
if (response.userDeclaredLocation) {
const locationMap = new Map();
locationMap['state'] = response.userDeclaredLocation.state;
locationMap['district'] = response.userDeclaredLocation.district;
await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(locationMap)).toPromise();
await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(response.userDeclaredLocation)).toPromise();
} else if (response.ipLocation) {
const ipLocationMap = new Map();
if (response.ipLocation.state) {
Expand Down
15 changes: 7 additions & 8 deletions src/app/district-mapping/district-mapping.page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component, OnInit, Inject, ChangeDetectorRef, NgZone, ViewChild} from '@angular/core';
import {
LocationSearchCriteria, ProfileService,
SharedPreferences, Profile, DeviceRegisterRequest, DeviceRegisterService, DeviceInfo
SharedPreferences, Profile, DeviceRegisterRequest, DeviceRegisterService, DeviceInfo, LocationSearchResult
} from 'sunbird-sdk';
import { Location as loc, PreferenceKey, RouterLinks, LocationConfig } from '../../app/app.constant';
import { AppHeaderService, CommonUtilService, AppGlobalService, FormAndFrameworkUtilService } from '@app/services';
Expand Down Expand Up @@ -104,8 +104,8 @@ export class DistrictMappingPage {
}

name;
stateList = [];
districtList = [];
stateList: LocationSearchResult[] = [];
districtList: LocationSearchResult[] = [];
stateCode;
districtCode;
backButtonFunc: Subscription;
Expand Down Expand Up @@ -435,15 +435,14 @@ export class DistrictMappingPage {
const req: DeviceRegisterRequest = {
userDeclaredLocation: {
state: this.stateName,
stateId: this.stateList.find((s) => s.name === this.stateName).id,
district: this.districtName,
districtId: this.districtList.find((d) => d.name === this.districtName).id,
declaredOffline: !this.commonUtilService.networkInfo.isNetworkAvailable
}
};
this.deviceRegisterService.registerDevice(req).toPromise();

const locationMap = new Map();
locationMap['state'] = this.stateName ? this.stateName : this.availableLocationState;
locationMap['district'] = this.districtName ? this.districtName : this.availableLocationDistrict;
await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(locationMap)).toPromise();
this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(req.userDeclaredLocation)).toPromise();
await loader.dismiss();
}

Expand Down