Skip to content

Commit

Permalink
feat: show login number in rc-login-status-notify (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
embbnux authored Feb 4, 2020
1 parent 89b93f0 commit d2f24e7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/widget-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ window.addEventListener('message', (e) => {
switch (data.type) {
case 'rc-login-status-notify':
// get login status from widget
console.log('rc-login-status-notify:', data.loggedIn);
console.log('rc-login-status-notify:', data.loggedIn, data.loginNumber);
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Adapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Adapter extends AdapterCore {
console.log(data.call);
break;
case 'rc-login-status-notify':
console.log('rc-login-status-notify:', data.loggedIn);
console.log('rc-login-status-notify:', data.loggedIn, data.loginNumber);
break;
case 'rc-calling-settings-notify':
console.log('rc-calling-settings-notify:', data);
Expand Down
22 changes: 22 additions & 0 deletions src/modules/Adapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const CALL_NOTIFY_DELAY = 1500;
name: 'Adapter',
deps: [
'Auth',
'ExtensionInfo',
'AccountInfo',
'RouterInteraction',
'Presence',
'ComposeText',
Expand All @@ -42,6 +44,8 @@ const CALL_NOTIFY_DELAY = 1500;
export default class Adapter extends AdapterModuleCore {
constructor({
auth,
extensionInfo,
accountInfo,
presence,
composeText,
call,
Expand Down Expand Up @@ -81,6 +85,8 @@ export default class Adapter extends AdapterModuleCore {
this._messageStore = this::ensureExist(messageStore, 'messageStore');
this._tabManager = this::ensureExist(tabManager, 'tabManager');
this._callLogger = callLogger;
this._extensionInfo = extensionInfo;
this._accountInfo = accountInfo;

this._reducer = getReducer(this.actionTypes);
this._callSessions = new Map();
Expand Down Expand Up @@ -322,10 +328,26 @@ export default class Adapter extends AdapterModuleCore {
if (this._loggedIn === this._auth.loggedIn) {
return;
}
if (this._auth.loggedIn && (
!this._extensionInfo.ready || !this._extensionInfo.ready
)) {
return;
}
this._loggedIn = this._auth.loggedIn;
let loginNumber;
if (this._loggedIn) {
const extensionNumber =
this._extensionInfo.extensionNumber && this._extensionInfo.extensionNumber !== '0'
? this._extensionInfo.extensionNumber
: null;
loginNumber = [this._accountInfo.mainCompanyNumber, extensionNumber].join(
'*',
);
}
this._postMessage({
type: 'rc-login-status-notify',
loggedIn: this._loggedIn,
loginNumber,
});
}

Expand Down

0 comments on commit d2f24e7

Please sign in to comment.