diff --git a/src/app/menu/menu.controller.ts b/src/app/menu/menu.controller.ts index adc6655..85838a0 100644 --- a/src/app/menu/menu.controller.ts +++ b/src/app/menu/menu.controller.ts @@ -16,14 +16,14 @@ export class MenuCtrl { senses: Object[]; constructor( - private $scope: IVMScope, + private $scope: IVMScope, private $log: angular.ILogService, private BackendService: BackendService, private WebPageService: WebPageService, private TagStorageService: TagStorageService, private SettingsService: SettingsService, private FileService: FileService) { - + $scope.vm = this; this.$scope.$on('wordWasSelected', (event, selectedWord) => { @@ -93,6 +93,7 @@ export class MenuCtrl { } onWordSelectedEvent = (newWord: string) => { + this.$log.debug('On word selected event()') if (countWords(newWord) > 2) { this.selectedWord = "Wops! Plugin can't handle more than two words." this.senses = [] @@ -100,7 +101,7 @@ export class MenuCtrl { else if (newWord.length === 0) { this.clearMenuVariables(); } - else { + else if (this.selectedWord != newWord) { this.selectedWord = newWord; this.senses = [] this.BackendService.callServer(newWord) @@ -126,21 +127,21 @@ export class MenuCtrl { } isLoadingSenses() { - // if senses var has initialized, we check length to see if they've been loaded. + // if senses var has initialized, we check length to see if they've been loaded. return this.senses && this.senses.length == 0 && this.selectedWord } /** - * In order to hide the menu before angular has loaded I - * explicitly set display: none; on the div. - * - * Thus to override that after user has logged in - * we use the ng-style attribute in combination with + * In order to hide the menu before angular has loaded I + * explicitly set display: none; on the div. + * + * Thus to override that after user has logged in + * we use the ng-style attribute in combination with * this function below. */ isUserLoggedIn() { if (!this.SettingsService.isUserLoggedIn()) return null; - else return {display: 'block'}; + else return {display: 'block'}; } doLogin() { diff --git a/src/app/services/backend.service.ts b/src/app/services/backend.service.ts index 9188fd9..e18a226 100644 --- a/src/app/services/backend.service.ts +++ b/src/app/services/backend.service.ts @@ -4,7 +4,7 @@ import {SettingsService} from '../services/index'; import {ISenseTag} from '../index.interfaces'; /** - * Service that is responsible for talking to the + * Service that is responsible for talking to the * backend server. */ export class BackendService { @@ -30,7 +30,9 @@ export class BackendService { //alright let's make this query! this.previousCall = word; return this.SettingsService.loadSettings() - .then(loadedSettings => this.$http.get(`${loadedSettings.tagitSenseQueryUrl}/${word}`)) + .then(loadedSettings => { + return this.$http.get(`${loadedSettings.tagitSenseQueryUrl}/${word}`) + }) } sendTaggedDataToServer(senseTag: ISenseTag) { @@ -38,9 +40,9 @@ export class BackendService { return this.SettingsService.loadSettings() .then(loadedSettings => { //let's add in the user's email to the tag. - senseTag.userEmail = loadedSettings.emailToTagWith + senseTag.userEmail = loadedSettings.emailToTagWith this.$http.post(loadedSettings.tagitSenseDestinationUrl, senseTag) }) } -} \ No newline at end of file +} diff --git a/src/app/services/tagStorage.service.ts b/src/app/services/tagStorage.service.ts index 5357a09..6c53135 100644 --- a/src/app/services/tagStorage.service.ts +++ b/src/app/services/tagStorage.service.ts @@ -9,7 +9,7 @@ export class TagStorageService { $localStorage: { tagStorage: ISenseTag[] }; constructor( - private $http: ng.IHttpService, + private $http: ng.IHttpService, private $log: ng.ILogService, $localStorage: any) { this.$localStorage = $localStorage; @@ -52,7 +52,7 @@ export class TagStorageService { loadTagsForCurrentPage(): ISenseTag[] { this.$log.debug('loadTagsForCurrentPage'); - return this.$localStorage.tagStorage + return angular.copy(this.$localStorage.tagStorage) .filter((tag: ISenseTag) => tag.urlOfPageThatWasTagged === window.location.href ); @@ -66,4 +66,4 @@ export class TagStorageService { return this.$localStorage.tagStorage } -} \ No newline at end of file +}