|
|
@@ -34,26 +34,37 @@ export class LsxPostRenderInterceptor extends BasicInterceptor {
|
|
|
*/
|
|
|
process(contextName, ...args) {
|
|
|
let contexts = JSON.parse(sessionStorage.getItem('lsx-loading-contexts')) || {};
|
|
|
+
|
|
|
+ let keysToBeRemoved = [];
|
|
|
+
|
|
|
// forEach keys of contexts
|
|
|
- Object.keys(contexts).forEach((renderId) => {
|
|
|
- const elem = document.getElementById(renderId);
|
|
|
+ Object.keys(contexts).forEach((key) => {
|
|
|
+ const elem = document.getElementById(key);
|
|
|
|
|
|
if (elem) {
|
|
|
- const context = new LsxLoadingContext(contexts[renderId]);
|
|
|
-
|
|
|
+ const contextObj = contexts[key]
|
|
|
+ // remove from context regardless of rendering success or failure
|
|
|
+ delete contexts[key];
|
|
|
// render
|
|
|
- ReactDOM.render(
|
|
|
- <Lsx crowi={this.crowi}
|
|
|
- currentPagePath={context.currentPagePath}
|
|
|
- tagExpression={context.tagExpression}
|
|
|
- fromPagePath={context.fromPagePath}
|
|
|
- lsxArgs={context.lsxArgs} />,
|
|
|
- elem
|
|
|
- );
|
|
|
+ this.renderReactDOM(contextObj, elem);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // store contexts to sessionStorage
|
|
|
+ sessionStorage.setItem('lsx-loading-contexts', JSON.stringify(contexts));
|
|
|
+
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
|
|
|
+ renderReactDOM(contextObj, elem) {
|
|
|
+ const context = new LsxLoadingContext(contextObj);
|
|
|
+ ReactDOM.render(
|
|
|
+ <Lsx crowi={this.crowi}
|
|
|
+ currentPagePath={context.currentPagePath}
|
|
|
+ tagExpression={context.tagExpression}
|
|
|
+ fromPagePath={context.fromPagePath}
|
|
|
+ lsxArgs={context.lsxArgs} />,
|
|
|
+ elem
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|