Make backendService correctly load settings

This commit is contained in:
Nils Norman Haukås 2016-08-14 12:12:51 +02:00
parent 66a16ea0f9
commit 97bd55b97e
2 changed files with 11 additions and 6 deletions

View file

@ -14,7 +14,7 @@ export class BackendService {
constructor(
private $http: ng.IHttpService,
private $q: ng.IQService,
private $log: ng.ILogService,
private $log: ng.ILogService,
private SettingsService: SettingsService) {
}
@ -29,12 +29,14 @@ export class BackendService {
//alright let's make this query!
this.previousCall = word;
return this.$http.get(`${this.SettingsService.senseQueryUrl}/${word}`)
return this.SettingsService.loadSettings()
.then(loadedSettings => this.$http.get(`${loadedSettings.tagitSenseQueryUrl}/${word}`))
}
sendTaggedDataToServer(senseTag: ISenseTag) {
this.$log.debug('sendTaggedDataToServer() was called');
return this.$http.post(this.SettingsService.senseDestinationUrl, senseTag)
return this.SettingsService.loadSettings()
.then(loadedSettings => this.$http.post(loadedSettings.tagitSenseDestinationUrl, senseTag))
}
}

View file

@ -61,12 +61,15 @@ export class SettingsService {
//use default value if no setting specified.
.then((loadedSettings: saveableSettings) => {
/**
* tagitSenseQueryUrl is not configurable yet so we just use
* the default instead
*/
loadedSettings.tagitSenseQueryUrl = this._defaultSenseQueryUrl
if (!loadedSettings.tagitSenseDestinationUrl) {
loadedSettings.tagitSenseDestinationUrl = this._defaultSenseDestinationUrl
}
if (!loadedSettings.tagitSenseQueryUrl) {
loadedSettings.tagitSenseQueryUrl = this._defaultSenseQueryUrl
}
if (!loadedSettings.emailToTagWith) {
loadedSettings.emailToTagWith = ''
}