|
@@ -18,9 +18,10 @@ export class IHistory {
|
|
|
protected _playload: playloadType;
|
|
|
private _currentRef: string;
|
|
|
private _currentUrl: string;
|
|
|
-
|
|
|
+ private _appId: string;
|
|
|
constructor(sdk: SDK, appId?: string) {
|
|
|
this._sdk = sdk;
|
|
|
+ this._appId = appId;
|
|
|
this.init();
|
|
|
this._playload.website = appId;
|
|
|
}
|
|
@@ -39,9 +40,17 @@ export class IHistory {
|
|
|
|
|
|
init(): void {
|
|
|
console.log('history init');
|
|
|
- global.document.addEventListener('readystatechange', this.handleReadystatechange.bind(this), true);
|
|
|
- global.history.pushState = hook(global.history, 'pushState', this.handlePushState.bind(this));
|
|
|
- global.history.replaceState = hook(global.history, 'replaceState', this.handlePushState.bind(this));
|
|
|
+ if (!(window as any).mediciRegisterIds) {
|
|
|
+ (window as any).mediciRegisterIds = [];
|
|
|
+ }
|
|
|
+ const mediciRegisterIds = (window as any).mediciRegisterIds;
|
|
|
+ if (!Array.from(mediciRegisterIds).includes(this._appId) && this._appId) {
|
|
|
+ global.document.addEventListener('readystatechange', this.handleReadystatechange.bind(this), true);
|
|
|
+ global.history.pushState = hook(global.history, 'pushState', this.handlePushState.bind(this));
|
|
|
+ global.history.replaceState = hook(global.history, 'replaceState', this.handlePushState.bind(this));
|
|
|
+ (window as any).mediciRegisterIds.push(this._appId);
|
|
|
+ }
|
|
|
+
|
|
|
this.initPlayload();
|
|
|
}
|
|
|
|