commit
e6edec581c
|
@ -186,7 +186,7 @@ export class AddonNotesListComponent implements OnInit, OnDestroy {
|
||||||
this.notesLoaded = false;
|
this.notesLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refreshNotes(true);
|
this.refreshNotes(false);
|
||||||
} else if (data && data.type && data.type != this.type) {
|
} else if (data && data.type && data.type != this.type) {
|
||||||
this.type = data.type;
|
this.type = data.type;
|
||||||
this.typeChanged();
|
this.typeChanged();
|
||||||
|
@ -209,7 +209,7 @@ export class AddonNotesListComponent implements OnInit, OnDestroy {
|
||||||
this.notesProvider.deleteNote(note, this.courseId).then(() => {
|
this.notesProvider.deleteNote(note, this.courseId).then(() => {
|
||||||
this.showDelete = false;
|
this.showDelete = false;
|
||||||
|
|
||||||
this.refreshNotes(true);
|
this.refreshNotes(false);
|
||||||
|
|
||||||
this.domUtils.showToast('addon.notes.eventnotedeleted', true, 3000);
|
this.domUtils.showToast('addon.notes.eventnotedeleted', true, 3000);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
@Input() poster?: string;
|
@Input() poster?: string;
|
||||||
@Output() onLoad = new EventEmitter(); // Emitted when content is loaded. Only for images.
|
@Output() onLoad = new EventEmitter(); // Emitted when content is loaded. Only for images.
|
||||||
|
|
||||||
|
loaded = false;
|
||||||
protected element: HTMLElement;
|
protected element: HTMLElement;
|
||||||
protected logger;
|
protected logger;
|
||||||
protected initialized = false;
|
protected initialized = false;
|
||||||
|
@ -192,6 +193,10 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
this.addSource(url);
|
this.addSource(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tagName === 'IMG') {
|
||||||
|
this.waitForLoad();
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.reject(null);
|
return Promise.reject(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,13 +232,8 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
this.addSource(finalUrl);
|
this.addSource(finalUrl);
|
||||||
} else {
|
} else {
|
||||||
if (tagName === 'IMG') {
|
if (tagName === 'IMG') {
|
||||||
const listener = (): void => {
|
this.loaded = false;
|
||||||
this.element.removeEventListener('load', listener);
|
this.waitForLoad();
|
||||||
this.element.removeEventListener('error', listener);
|
|
||||||
this.onLoad.emit();
|
|
||||||
};
|
|
||||||
this.element.addEventListener('load', listener);
|
|
||||||
this.element.addEventListener('error', listener);
|
|
||||||
}
|
}
|
||||||
this.element.setAttribute(targetAttr, finalUrl);
|
this.element.setAttribute(targetAttr, finalUrl);
|
||||||
this.element.setAttribute('data-original-' + targetAttr, url);
|
this.element.setAttribute('data-original-' + targetAttr, url);
|
||||||
|
@ -299,4 +299,19 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
this.element.setAttribute('style', inlineStyles);
|
this.element.setAttribute('style', inlineStyles);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for the image to be loaded or error, and emit an event when it happens.
|
||||||
|
*/
|
||||||
|
protected waitForLoad(): void {
|
||||||
|
const listener = (): void => {
|
||||||
|
this.element.removeEventListener('load', listener);
|
||||||
|
this.element.removeEventListener('error', listener);
|
||||||
|
this.onLoad.emit();
|
||||||
|
this.loaded = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.element.addEventListener('load', listener);
|
||||||
|
this.element.addEventListener('error', listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,6 +464,11 @@ export class CoreFormatTextDirective implements OnChanges {
|
||||||
let promise: Promise<any> = null;
|
let promise: Promise<any> = null;
|
||||||
if (externalImages.length) {
|
if (externalImages.length) {
|
||||||
promise = Promise.all(externalImages.map((externalImage) => {
|
promise = Promise.all(externalImages.map((externalImage) => {
|
||||||
|
if (externalImage.loaded) {
|
||||||
|
// Image has already been loaded, no need to wait.
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve): void => {
|
return new Promise((resolve): void => {
|
||||||
const subscription = externalImage.onLoad.subscribe(() => {
|
const subscription = externalImage.onLoad.subscribe(() => {
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
|
|
Loading…
Reference in New Issue