diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 449c0593..c7f0ffc9 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -81,7 +81,7 @@ export class PollService implements Resolve { if (custom_url) { const poll: Poll | undefined = await this.apiService.getPollByCustomUrl(custom_url); - console.log({ loadPollBycustom_urlResponse: poll }); + console.log('loadPollBycustom_urlResponse', poll); if (poll) { this.updateCurrentPoll(poll); this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`); @@ -109,7 +109,11 @@ export class PollService implements Resolve { public updateCurrentPoll(poll: Poll): void { console.log('update poll with: ', poll); - this.storageService.setChoicesForVoteStack(poll.choices); + if (!this.storageService.vote_stack.id || this.storageService.vote_stack.poll_custom_url !== poll.custom_url) { + console.log('set base choices', poll.choices); + // set the choices only the first time the poll loads + this.storageService.setChoicesForVoteStack(poll.choices); + } this.toastService.display('sondage bien mis à jour', 'success'); diff --git a/src/app/core/services/storage.service.ts b/src/app/core/services/storage.service.ts index 3d683146..b7ce3863 100644 --- a/src/app/core/services/storage.service.ts +++ b/src/app/core/services/storage.service.ts @@ -119,12 +119,8 @@ export class StorageService { mapVotes(resp) { console.log('data', resp.data); console.log('this.vote_stack', this.vote_stack); - this.vote_stack.votes = []; this.vote_stack.owner = resp.data.owner; this.vote_stack.id = resp.data.id; - for (const vote of resp.data.votes) { - this.vote_stack.votes.push(vote); - } console.log('this.vote_stack', this.vote_stack); } } diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index 55bb09bf..887709a3 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -86,6 +86,17 @@ Detailed +
+ + +
diff --git a/src/app/features/consultation/consultation.component.ts b/src/app/features/consultation/consultation.component.ts index e65d8293..793987f2 100644 --- a/src/app/features/consultation/consultation.component.ts +++ b/src/app/features/consultation/consultation.component.ts @@ -85,21 +85,23 @@ export class ConsultationComponent implements OnInit, OnDestroy { /** * update existing vote stack - * @param vote_stack + * @param Stack */ updateVoteStack(): void { const vote_stack = this.storageService.vote_stack; vote_stack.poll_custom_url = this.poll.custom_url; - console.log('updateVoteStack vote_stack', vote_stack); - // const handlingError = this.api.handleError; + console.log('updateVoteStack vote_stack.votes', vote_stack.votes.length, vote_stack.votes); + const handlingError = this.api.ousideHandleError; - this.api.sendUpdateVoteStack(vote_stack).then((resp) => { - console.log('sendUpdateVoteStack resp', resp); - this.storeVoteStackAndReloadPoll(resp); - this.toastService.display('vote bien mis à jour', 'success'); - }); - // .catch(handlingError); + this.api + .sendUpdateVoteStack(vote_stack) + .then((resp) => { + console.log('sendUpdateVoteStack updated resp', resp); + // this.storeVoteStackAndReloadPoll(resp); + this.toastService.display('vote bien mis à jour', 'success'); + }) + .catch(handlingError); } /** diff --git a/src/environments/endpoints.ts b/src/environments/endpoints.ts index 11c62811..95051473 100644 --- a/src/environments/endpoints.ts +++ b/src/environments/endpoints.ts @@ -1,13 +1,13 @@ export const backendApiUrlsInDev = { local: 'http://tktest.lan/api/v1', - // remote: 'http://tktest.lan/api/v1', + remote: 'http://tktest.lan/api/v1', // local: 'http://localhost:8000/api/v1', - remote: 'http://localhost:8000/api/v1', + // remote: 'http://localhost:8000/api/v1', // remote: 'https://framadate-api.cipherbliss.com/api/v1', }; export const apiV1 = { - baseHref: 'http://localhost:8000/api/v1', - // baseHref: 'http://tktest.lan/api/v1', + // baseHref: 'http://localhost:8000/api/v1', + baseHref: 'http://tktest.lan/api/v1', // baseHref: 'https://framadate-api.cipherbliss.com/api/v1', api_new_poll: '/poll/', api_get_poll: '/poll/{id}',