Skip to content

Commit b2a558f

Browse files
authored
fix: ie api request cache issue (#274)
1 parent 15e0bfe commit b2a558f

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

src/lib/hackSend.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default function hackSend(sdk) {
2+
const platform = sdk.platform();
3+
platform.originalSend = platform.send;
4+
const newSendFunc = (options) => {
5+
let { headers } = options;
6+
headers = {
7+
...headers,
8+
'Cache-Control': 'private, no-cache, no-store, must-revalidate',
9+
Pragma: 'no-cache',
10+
Expires: '-1'
11+
};
12+
return platform.originalSend({
13+
...options,
14+
headers,
15+
});
16+
};
17+
platform.send = newSendFunc;
18+
return sdk;
19+
}

src/modules/Environment/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Environment from 'ringcentral-integration/modules/Environment';
33
import isBlank from 'ringcentral-integration/lib/isBlank';
44
import { Module } from 'ringcentral-integration/lib/di';
55

6+
import hackSend from '../../lib/hackSend';
7+
68
import {
79
getAppKeyReducer,
810
getAppSecretReducer,
@@ -71,15 +73,25 @@ export default class DemoEnvironment extends Environment {
7173
appSecret: this.appSecret
7274
}
7375
);
74-
this._client.service = new SDK(config);
76+
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
77+
// if the browser is IE , no cache
78+
this._client.service = hackSend(new SDK(config));
79+
} else {
80+
this._client.service = new SDK(config);
81+
}
7582
}
7683
}
7784

7885
_changeEnvironment(enabled, server, appKey, appSecret) {
7986
const newConfig = this._getSdkConfig(
8087
{ enabled, server, appKey, appSecret }
8188
);
82-
this._client.service = new SDK(newConfig);
89+
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
90+
// if the browser is IE , no cache
91+
this._client.service = hackSend(new SDK(newConfig));
92+
} else {
93+
this._client.service = new SDK(newConfig);
94+
}
8395
}
8496

8597
async setData({ server, recordingHost, enabled, appKey, appSecret }) {

src/modules/Phone/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import CallLog from '../CallLog';
9494
import Webphone from '../Webphone';
9595

9696
import searchContactPhoneNumbers from '../../lib/searchContactPhoneNumbers';
97+
import hackSend from '../../lib/hackSend';
9798

9899
// user Dependency Injection with decorator to create a phone class
99100
// https://github.com/ringcentral/ringcentral-js-integration-commons/blob/master/docs/dependency-injection.md
@@ -167,7 +168,13 @@ import searchContactPhoneNumbers from '../../lib/searchContactPhoneNumbers';
167168
},
168169
{
169170
provide: 'Client',
170-
useFactory: ({ sdkConfig }) => new RingCentralClient(new SDK(sdkConfig)),
171+
useFactory: ({ sdkConfig }) => {
172+
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
173+
// if the browser is IE , no cache
174+
return new RingCentralClient(hackSend(new SDK(sdkConfig)));
175+
}
176+
return new RingCentralClient(new SDK(sdkConfig));
177+
},
171178
deps: [
172179
{ dep: 'SdkConfig', useParam: true, },
173180
],

0 commit comments

Comments
 (0)