Merge pull request #4973 from GabrielInTheWorld/fixSpinner

Improves the spinner
This commit is contained in:
Emanuel Schütze 2019-09-03 13:33:44 +02:00 committed by GitHub
commit a193cc1e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 37 deletions

View File

@ -199,7 +199,7 @@ export class AppComponent {
*/
private checkConnectionProgress(): void {
if ((this.user || this.operator.isAnonymous) && this.isStable) {
this.overlayService.setSpinner(false, null, true);
this.overlayService.setSpinner(false, null, false, true);
}
}
}

View File

@ -28,12 +28,7 @@ export class OverlayService {
/**
* Boolean, whether appearing of the spinner should be prevented next time.
*/
private preventAppearingSpinner: boolean;
/**
* Boolean to indicate, if the spinner has already appeared.
*/
private spinnerHasAppeared = false;
private preventAppearingSpinner = false;
/**
*
@ -48,12 +43,9 @@ export class OverlayService {
* @param text optional. If the spinner should show a message.
* @param preventAppearing optional. Wether to prevent showing the spinner the next time.
*/
public setSpinner(isVisible: boolean, text?: string, preventAppearing?: boolean): void {
if (!(this.preventAppearingSpinner && !this.spinnerHasAppeared && isVisible)) {
public setSpinner(isVisible: boolean, text?: string, forceAppearing?: boolean, preventAppearing?: boolean): void {
if (!this.preventAppearingSpinner || forceAppearing) {
setTimeout(() => this.spinner.next({ isVisible, text }));
if (isVisible) {
this.spinnerHasAppeared = true;
}
}
this.preventAppearingSpinner = preventAppearing;
}
@ -93,7 +85,6 @@ export class OverlayService {
* and still stays at the website.
*/
public logout(): void {
this.spinnerHasAppeared = false;
this.preventAppearingSpinner = false;
}
}

View File

@ -81,7 +81,7 @@ export class MotionMultiselectService {
`\n${i} ` +
this.translate.instant('of') +
` ${motions.length}`;
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
await this.repo.delete(motion);
}
this.overlayService.setSpinner(false);
@ -119,7 +119,7 @@ export class MotionMultiselectService {
const selectedChoice = await this.choiceService.open(title, choices);
if (selectedChoice) {
const message = `${motions.length} ` + this.translate.instant(this.messageForSpinner);
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
await this.repo.setMultiState(motions, selectedChoice.items as number);
}
} else {
@ -152,7 +152,7 @@ export class MotionMultiselectService {
recommendation: selectedChoice.action ? 0 : (selectedChoice.items as number)
}));
const message = `${motions.length} ` + this.translate.instant(this.messageForSpinner);
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
await this.httpService.post('/rest/motions/motion/manage_multiple_recommendation/', {
motions: requestData
});
@ -181,13 +181,8 @@ export class MotionMultiselectService {
);
if (selectedChoice) {
const message = this.translate.instant(this.messageForSpinner);
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
await this.repo.setMultiCategory(motions, selectedChoice.items as number);
// .catch(error => {
// this.overlayService.setSpinner(false);
// throw error;
// });
// this.overlayService.setSpinner(false);
}
}
@ -213,7 +208,6 @@ export class MotionMultiselectService {
submitters: submitterIds
};
});
// await this.httpService.post('/rest/motions/motion/manage_multiple_submitters/', { motions: requestData });
} else if (selectedChoice.action === choices[1]) {
requestData = motions.map(motion => {
const submitterIdsToRemove = selectedChoice.items as number[];
@ -226,9 +220,8 @@ export class MotionMultiselectService {
}
const message = `${motions.length} ` + this.translate.instant(this.messageForSpinner);
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
await this.httpService.post('/rest/motions/motion/manage_multiple_submitters/', { motions: requestData });
// this.overlayService.setSpinner(false);
}
}
@ -256,7 +249,6 @@ export class MotionMultiselectService {
tags: tagIds
};
});
// await this.httpService.post('/rest/motions/motion/manage_multiple_tags/', { motions: requestData });
} else if (selectedChoice.action === choices[1]) {
requestData = motions.map(motion => {
const tagIdsToRemove = selectedChoice.items as number[];
@ -266,7 +258,6 @@ export class MotionMultiselectService {
tags: tagIds
};
});
// await this.httpService.post('/rest/motions/motion/manage_multiple_tags/', { motions: requestData });
} else if (selectedChoice.action === choices[2]) {
requestData = motions.map(motion => {
return {
@ -277,9 +268,8 @@ export class MotionMultiselectService {
}
const message = `${motions.length} ` + this.translate.instant(this.messageForSpinner);
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
await this.httpService.post('/rest/motions/motion/manage_multiple_tags/', { motions: requestData });
// this.overlayService.setSpinner(false);
}
}
@ -300,14 +290,9 @@ export class MotionMultiselectService {
);
if (selectedChoice) {
const message = this.translate.instant(this.messageForSpinner);
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
const blockId = selectedChoice.action ? null : (selectedChoice.items as number);
await this.repo.setMultiMotionBlock(motions, blockId);
// .catch(error => {
// this.overlayService.setSpinner(false);
// throw error;
// });
// this.overlayService.setSpinner(false);
}
}
@ -370,9 +355,8 @@ export class MotionMultiselectService {
if (selectedChoice && motions.length) {
const message = this.translate.instant(`I have ${motions.length} favorite motions. Please wait ...`);
const star = (selectedChoice.items as number) === choices[0].id;
this.overlayService.setSpinner(true, message);
this.overlayService.setSpinner(true, message, true);
await this.personalNoteService.bulkSetStar(motions, star);
// this.overlayService.setSpinner(false);
}
}
}