Experiment to rebuild Diffuse using web applets.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

experiment: reuse iframes automatically if possible

+4 -3
+4 -3
src/scripts/applets/common.ts
··· 40 40 src = QS.stringifyUrl({ url: src, query }); 41 41 } 42 42 43 - const existingFrame: HTMLIFrameElement | null = window.document.querySelector(`[src="${src}"]`); 43 + const context = self.top || self.parent; 44 + const existingFrame: HTMLIFrameElement | null = context.document.querySelector(`[src="${src}"]`); 44 45 45 46 let frame; 46 47 ··· 54 55 if (opts.container) { 55 56 opts.container.appendChild(frame); 56 57 } else { 57 - window.document.body.appendChild(frame); 58 + context.document.body.appendChild(frame); 58 59 } 59 60 } 60 61 ··· 62 63 throw new Error("iframe does not have a contentWindow"); 63 64 } 64 65 65 - const applet = await applets.connect<D>(frame.contentWindow).catch((err) => { 66 + const applet = await applets.connect<D>(frame.contentWindow, { context }).catch((err) => { 66 67 console.error("Error connecting to " + src, err); 67 68 throw err; 68 69 });