MOBILE-4270 notes: Fix error displayed when restoring note

main
Dani Palou 2023-05-09 09:00:54 +02:00
parent a0b4c8259d
commit a128ae8929
1 changed files with 10 additions and 10 deletions

View File

@ -98,12 +98,12 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
* Fetch notes. * Fetch notes.
* *
* @param sync When to resync notes. * @param sync When to resync notes.
* @param showErrors When to display errors or not. * @param showSyncErrors When to display sync errors or not.
* @returns Promise with the notes. * @returns Promise with the notes.
*/ */
protected async fetchNotes(sync = false, showErrors = false): Promise<void> { protected async fetchNotes(sync = false, showSyncErrors = false): Promise<void> {
if (sync) { if (sync) {
await this.syncNotes(showErrors); await this.syncNotes(showSyncErrors);
} }
try { try {
@ -150,15 +150,15 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
/** /**
* Refresh notes on PTR. * Refresh notes on PTR.
* *
* @param showErrors Whether to display errors or not. * @param showSyncErrors Whether to display sync errors or not.
* @param refresher Refresher instance. * @param refresher Refresher instance.
*/ */
refreshNotes(showErrors: boolean, refresher?: IonRefresher): void { refreshNotes(showSyncErrors: boolean, refresher?: IonRefresher): void {
this.refreshIcon = CoreConstants.ICON_LOADING; this.refreshIcon = CoreConstants.ICON_LOADING;
this.syncIcon = CoreConstants.ICON_LOADING; this.syncIcon = CoreConstants.ICON_LOADING;
AddonNotes.invalidateNotes(this.courseId, this.userId).finally(() => { AddonNotes.invalidateNotes(this.courseId, this.userId).finally(() => {
this.fetchNotes(true, showErrors).finally(() => { this.fetchNotes(true, showSyncErrors).finally(() => {
if (refresher) { if (refresher) {
refresher?.complete(); refresher?.complete();
} }
@ -253,7 +253,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
e.stopPropagation(); e.stopPropagation();
await AddonNotesOffline.undoDeleteNote(note.id); await AddonNotesOffline.undoDeleteNote(note.id);
this.refreshNotes(true); this.refreshNotes(false);
} }
/** /**
@ -266,16 +266,16 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
/** /**
* Tries to synchronize course notes. * Tries to synchronize course notes.
* *
* @param showErrors Whether to display errors or not. * @param showSyncErrors Whether to display sync errors or not.
* @returns Promise resolved when done. * @returns Promise resolved when done.
*/ */
protected async syncNotes(showErrors: boolean): Promise<void> { protected async syncNotes(showSyncErrors: boolean): Promise<void> {
try { try {
const result = await AddonNotesSync.syncNotes(this.courseId); const result = await AddonNotesSync.syncNotes(this.courseId);
this.showSyncWarnings(result.warnings); this.showSyncWarnings(result.warnings);
} catch (error) { } catch (error) {
if (showErrors) { if (showSyncErrors) {
CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true);
} }
} }