Skip to content

Commit 0fc1d40

Browse files
authored
fix storage bug (#883)
* fix storage bug * use notLoggedIn
1 parent 3164055 commit 0fc1d40

File tree

2 files changed

+17
-12
lines changed
  • packages
    • ringcentral-integration/modules/Storage
    • ringcentral-widgets-demo/dev-server

2 files changed

+17
-12
lines changed

packages/ringcentral-integration/modules/Storage/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default class Storage extends StorageBase {
4444
this.store.subscribe(async () => {
4545
if (
4646
this._auth.loginStatus === loginStatus.loggedIn &&
47+
(!this._tabManager || this._tabManager.ready) &&
4748
!this.ready
4849
) {
4950
const storageKey =
@@ -61,7 +62,10 @@ export default class Storage extends StorageBase {
6162
this.store.dispatch({
6263
type: this.actionTypes.initSuccess,
6364
storageKey,
64-
data: storedData,
65+
// To fix same reference in redux store with storedData
66+
data: {
67+
...storedData,
68+
},
6569
});
6670
this._storageHandler = ({ key, value }) => {
6771
if (this.ready) {
@@ -75,8 +79,10 @@ export default class Storage extends StorageBase {
7579
};
7680
this._storage.on('storage', this._storageHandler);
7781
} else if (
78-
this._auth.loginStatus === loginStatus.notLoggedIn &&
79-
this.ready
82+
(
83+
(!!this._tabManager && !this._tabManager.ready) ||
84+
this._auth.notLoggedIn
85+
) && this.ready
8086
) {
8187
this.store.dispatch({
8288
type: this.actionTypes.reset,

packages/ringcentral-widgets-demo/dev-server/Phone.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,14 @@ import LocalForageStorage from 'ringcentral-integration/lib/LocalForageStorage';
140140
{ provide: 'DialerUI', useClass: DialerUI },
141141
{ provide: 'Feedback', useClass: Feedback },
142142
{ provide: 'UserGuide', useClass: UserGuide },
143-
// IndexedDB
144-
// {
145-
// provide: 'StorageOptions',
146-
// useValue: {
147-
// StorageProvider: LocalForageStorage,
148-
// disableAllowInactiveTabsWrite: false,
149-
// },
150-
// spread: true
151-
// },
143+
{
144+
provide: 'StorageOptions',
145+
useValue: {
146+
// StorageProvider: LocalForageStorage, // IndexedDB
147+
disableAllowInactiveTabsWrite: true,
148+
},
149+
spread: true
150+
},
152151
]
153152
})
154153
export default class BasePhone extends RcModule {

0 commit comments

Comments
 (0)