Skip to content

Commit bca9070

Browse files
authored
Handle floating promises (#3492)
1 parent 40e8268 commit bca9070

File tree

63 files changed

+231
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+231
-223
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
120120
// Check authentication when coming back online
121121
// This is also run on first load when the websocket connects for the first time
122122
if (status && !this.isAppLoading) {
123-
this.authService.checkOnlineAuth();
123+
void this.authService.checkOnlineAuth();
124124
}
125125
});
126126

@@ -279,7 +279,7 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
279279
if (this._selectedProjectDoc == null || !this._selectedProjectDoc.isLoaded) {
280280
return;
281281
}
282-
this.userService.setCurrentProjectId(this.currentUserDoc!, this._selectedProjectDoc.id);
282+
void this.userService.setCurrentProjectId(this.currentUserDoc!, this._selectedProjectDoc.id);
283283
this.projectUserConfigDoc = await this.projectService.getUserConfig(
284284
this._selectedProjectDoc.id,
285285
this.currentUserDoc!.id
@@ -291,7 +291,7 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
291291
// handle remotely deleted project
292292
const userDoc = this.currentUserDoc;
293293
if (userDoc != null && this.userService.currentProjectId(userDoc) != null) {
294-
this.showProjectDeletedDialog();
294+
void this.showProjectDeletedDialog();
295295
}
296296
});
297297

@@ -311,8 +311,8 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
311311
// See if the user was removed from the project
312312
if (!(this.currentUserDoc.id in this._selectedProjectDoc.data.userRoles)) {
313313
// The user has been removed from the project
314-
this.showProjectDeletedDialog();
315-
this.projectService.localDelete(this._selectedProjectDoc.id);
314+
void this.showProjectDeletedDialog();
315+
void this.projectService.localDelete(this._selectedProjectDoc.id);
316316
}
317317

318318
if (this.projectUserConfigDoc != null) {
@@ -348,7 +348,7 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
348348

349349
setLocale(locale: string): void {
350350
this.i18n.setLocale(locale);
351-
this.authService.updateInterfaceLanguage(locale);
351+
void this.authService.updateInterfaceLanguage(locale);
352352
}
353353

354354
changePassword(): void {
@@ -357,20 +357,20 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
357357
} else if (!this.isAppOnline) {
358358
this.noticeService.show(this.i18n.translateStatic('app.action_not_available_offline'));
359359
} else {
360-
this.authService
360+
void this.authService
361361
.changePassword(this.currentUser.email)
362362
.then(() => {
363363
this.noticeService.show(this.i18n.translateStatic('app.password_reset_email_sent'));
364364
})
365365
.catch(() => {
366-
this.dialogService.message('app.cannot_change_password');
366+
void this.dialogService.message('app.cannot_change_password');
367367
});
368368
}
369369
}
370370

371371
editName(): void {
372372
if (this.isAppOnline) {
373-
this.userService.editDisplayName(false);
373+
void this.userService.editDisplayName(false);
374374
} else {
375375
this.noticeService.show(this.i18n.translateStatic('app.action_not_available_offline'));
376376
}
@@ -393,11 +393,11 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
393393
}
394394

395395
installOnDevice(): void {
396-
this.pwaService.install();
396+
void this.pwaService.install();
397397
}
398398

399399
logOut(): void {
400-
this.authService.logOut();
400+
void this.authService.logOut();
401401
}
402402

403403
collapseDrawer(): void {

src/SIL.XForge.Scripture/ClientApp/src/app/checking/chapter-audio-dialog/chapter-audio-dialog.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class ChapterAudioDialogComponent implements AfterViewInit, OnDestroy {
238238
this.processUploadedFiles(e.dataTransfer.files);
239239
});
240240

241-
this.projectService.queryAudioText(this.data.projectId, this.destroyRef).then(query => {
241+
void this.projectService.queryAudioText(this.data.projectId, this.destroyRef).then(query => {
242242
this.textAudioQuery = query;
243243
this.populateExistingData();
244244
});
@@ -322,7 +322,7 @@ export class ChapterAudioDialogComponent implements AfterViewInit, OnDestroy {
322322
// if the upload fails, we need to show an error and not close the dialog
323323
this._loadingAudio = false;
324324
if (audioUrl == null) {
325-
this.dialogService.message('chapter_audio_dialog.upload_failed');
325+
void this.dialogService.message('chapter_audio_dialog.upload_failed');
326326
return;
327327
}
328328

@@ -511,7 +511,7 @@ export class ChapterAudioDialogComponent implements AfterViewInit, OnDestroy {
511511
return;
512512
}
513513
this.timing = this.timing_processed = doc.timings;
514-
this.fileService
514+
void this.fileService
515515
.findOrUpdateCache(FileType.Audio, TextAudioDoc.COLLECTION, textAudioId, doc.audioUrl)
516516
.then(data => {
517517
if (data == null) {
@@ -524,7 +524,7 @@ export class ChapterAudioDialogComponent implements AfterViewInit, OnDestroy {
524524
fileName: this.i18n.localizeBook(this.data.currentBook!) + ' ' + this.data.currentChapter,
525525
status: 'uploaded'
526526
};
527-
this.audioUpdate(audioAttachment);
527+
void this.audioUpdate(audioAttachment);
528528
});
529529
});
530530
}
@@ -553,7 +553,7 @@ export class ChapterAudioDialogComponent implements AfterViewInit, OnDestroy {
553553
}
554554
const isTimingFile: boolean = TIMING_FILE_EXTENSION_REGEX.test(file.name);
555555
if (isTimingFile) {
556-
this.prepareTimingFileUpload(file);
556+
void this.prepareTimingFileUpload(file);
557557
} else {
558558
// if file is larger than 100MB, show an error
559559
if (file.size > 100_000_000) {
@@ -568,7 +568,7 @@ export class ChapterAudioDialogComponent implements AfterViewInit, OnDestroy {
568568
status: 'uploaded'
569569
};
570570

571-
this.audioUpdate(audioAttachment);
571+
void this.audioUpdate(audioAttachment);
572572
}
573573
}
574574
}

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking-overview/checking-overview.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export class CheckingOverviewComponent extends DataLoadingComponent implements O
333333
}
334334

335335
setQuestionArchiveStatus(questionDoc: QuestionDoc, archiveStatus: boolean): void {
336-
questionDoc.submitJson0Op(op => {
336+
void questionDoc.submitJson0Op(op => {
337337
op.set(q => q.isArchived, archiveStatus);
338338
if (archiveStatus) {
339339
op.set(q => q.dateArchived!, new Date().toJSON());

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-answers/checking-answers.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ export class CheckingAnswersComponent implements OnInit {
173173
if (questionDoc == null) {
174174
return;
175175
}
176-
this.updateQuestionDocAudioUrls();
176+
void this.updateQuestionDocAudioUrls();
177177
if (this.questionChangeSubscription != null) {
178178
this.questionChangeSubscription!.unsubscribe();
179179
}
180180
this.questionChangeSubscription = questionDoc.remoteChanges$
181181
.pipe(quietTakeUntilDestroyed(this.destroyRef))
182182
.subscribe(ops => {
183-
this.updateQuestionDocAudioUrls();
183+
void this.updateQuestionDocAudioUrls();
184184
// If the user hasn't added an answer yet and is able to, then
185185
// don't hold back any incoming answers from appearing right away
186186
// as soon as the user adds their answer.
@@ -358,7 +358,7 @@ export class CheckingAnswersComponent implements OnInit {
358358
};
359359
const dialogResponseDoc: QuestionDoc | undefined = await this.questionDialogService.questionDialog(data);
360360
if (dialogResponseDoc?.data != null) {
361-
this.updateQuestionDocAudioUrls();
361+
void this.updateQuestionDocAudioUrls();
362362
this.action.emit({ action: 'edit', questionDoc: dialogResponseDoc });
363363
}
364364
}
@@ -387,7 +387,7 @@ export class CheckingAnswersComponent implements OnInit {
387387
result.audio.fileName
388388
);
389389
if (urlResult != null) {
390-
this.questionDoc.submitJson0Op(op => op.set(q => q.audioUrl, urlResult));
390+
void this.questionDoc.submitJson0Op(op => op.set(q => q.audioUrl, urlResult));
391391
}
392392
}
393393
}
@@ -539,9 +539,9 @@ export class CheckingAnswersComponent implements OnInit {
539539
if (this.questionDoc?.data == null) {
540540
return;
541541
}
542-
this.cacheFileSource(this.questionDoc, this.questionDoc.data.dataId, this.questionDoc.data.audioUrl);
542+
void this.cacheFileSource(this.questionDoc, this.questionDoc.data.dataId, this.questionDoc.data.audioUrl);
543543
for (const answer of this.questionDoc.getAnswers()) {
544-
this.cacheFileSource(this.questionDoc, answer.dataId, answer.audioUrl);
544+
void this.cacheFileSource(this.questionDoc, answer.dataId, answer.audioUrl);
545545
}
546546
}
547547

@@ -581,7 +581,7 @@ export class CheckingAnswersComponent implements OnInit {
581581
this.hideAnswerForm();
582582
this.submittingAnswer = false;
583583
this.justEditedAnswer = true;
584-
this.updateQuestionDocAudioUrls();
584+
void this.updateQuestionDocAudioUrls();
585585
}
586586
});
587587
}
@@ -590,7 +590,7 @@ export class CheckingAnswersComponent implements OnInit {
590590
if (this.projectId == null) {
591591
return;
592592
}
593-
this.projectService.isProjectAdmin(this.projectId, this.userService.currentUserId).then(isProjectAdmin => {
593+
void this.projectService.isProjectAdmin(this.projectId, this.userService.currentUserId).then(isProjectAdmin => {
594594
this.isProjectAdmin = isProjectAdmin;
595595
});
596596
}

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-answers/checking-comments/checking-comments.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class CheckingCommentsComponent extends SubscriptionDisposable implements
169169
}
170170
}
171171
if (commentIdsToMarkRead.length) {
172-
this.projectUserConfigDoc.submitJson0Op(op => {
172+
void this.projectUserConfigDoc.submitJson0Op(op => {
173173
for (const commentId of commentIdsToMarkRead) {
174174
op.add(puc => puc.commentRefsRead, commentId);
175175
}

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-questions/checking-questions.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class CheckingQuestionsComponent implements OnInit, OnChanges {
8686
});
8787
this.setProjectAdmin();
8888

89-
this.questionsService
89+
void this.questionsService
9090
.queryFirstUnansweredQuestion(projectProfileDoc.id, this.userService.currentUserId, this.destroyRef)
9191
.then(query => {
9292
this._firstUnansweredQuestion = query;
@@ -321,7 +321,7 @@ export class CheckingQuestionsComponent implements OnInit, OnChanges {
321321
return;
322322
}
323323

324-
this._projectUserConfigDoc
324+
void this._projectUserConfigDoc
325325
.submitJson0Op(op => {
326326
if (questionDoc != null && questionDoc.data != null && !this.hasUserReadQuestion(questionDoc)) {
327327
op.add(puc => puc.questionRefsRead, questionDoc.data.dataId);
@@ -394,7 +394,7 @@ export class CheckingQuestionsComponent implements OnInit, OnChanges {
394394
this.activeQuestionDoc = questionDoc;
395395

396396
if (verseRef != null) {
397-
this.storeMostRecentQuestion().then(() => {
397+
void this.storeMostRecentQuestion().then(() => {
398398
// Only emit if not a filter to avoid duplicate emission, as an emit from filter is called elsewhere
399399
if (!actionSource?.isQuestionListChange) {
400400
this.changed.emit({ questionDoc, actionSource, clearFilter });
@@ -441,7 +441,7 @@ export class CheckingQuestionsComponent implements OnInit, OnChanges {
441441
if (this.projectId == null) {
442442
return;
443443
}
444-
this.projectService.isProjectAdmin(this.projectId, this.userService.currentUserId).then(isProjectAdmin => {
444+
void this.projectService.isProjectAdmin(this.projectId, this.userService.currentUserId).then(isProjectAdmin => {
445445
this.isProjectAdmin = isProjectAdmin;
446446
});
447447
}

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-scripture-audio-player/checking-scripture-audio-player.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export class CheckingScriptureAudioPlayerComponent implements AfterViewInit {
201201
if (this.audioPlayer == null) return;
202202
this._audioIsAvailable = false;
203203
// wait until the next microtask cycle to get the audio player with the updated source
204-
Promise.resolve(this.audioPlayer).then(audioPlayer => {
204+
void Promise.resolve(this.audioPlayer).then(audioPlayer => {
205205
this.audioSubscription?.unsubscribe();
206206
this.audioSubscription = audioPlayer.isAudioAvailable$
207207
.pipe(

0 commit comments

Comments
 (0)