diff --git a/dev-server/Phone.js b/dev-server/Phone.js
index 7d9c52585a..cdf6e32b7b 100644
--- a/dev-server/Phone.js
+++ b/dev-server/Phone.js
@@ -6,11 +6,14 @@ import RcModule from 'ringcentral-integration/lib/RcModule';
import AccountExtension from 'ringcentral-integration/modules/AccountExtension';
import AccountInfo from 'ringcentral-integration/modules/AccountInfo';
+import AccountPhoneNumber from 'ringcentral-integration/modules/AccountPhoneNumber';
+import AddressBook from 'ringcentral-integration/modules/AddressBook';
import Alert from 'ringcentral-integration/modules/Alert';
import Auth from 'ringcentral-integration/modules/Auth';
import Brand from 'ringcentral-integration/modules/Brand';
import Call from 'ringcentral-integration/modules/Call';
import CallingSettings from 'ringcentral-integration/modules/CallingSettings';
+import Contacts from 'ringcentral-integration/modules/Contacts';
import ConnectivityMonitor from 'ringcentral-integration/modules/ConnectivityMonitor';
import DialingPlan from 'ringcentral-integration/modules/DialingPlan';
import ExtensionDevice from 'ringcentral-integration/modules/ExtensionDevice';
@@ -239,6 +242,12 @@ export default class Phone extends RcModule {
tabManager: this.tabManager,
getState: () => this.state.forwardingNumber,
}));
+ this.addModule('contactMatcher', new ContactMatcher({
+ ...options,
+ storage: this.storage,
+ getState: () => this.state.contactMatcher,
+ }));
+ reducers.contactMatcher = this.contactMatcher.reducer;
this.addModule('webphone', new Webphone({
appKey: apiConfig.appKey,
appName: 'RingCentral Widget',
@@ -248,6 +257,7 @@ export default class Phone extends RcModule {
client: this.client,
storage: this.storage,
rolesAndPermissions: this.rolesAndPermissions,
+ contactMatcher: this.contactMatcher,
webphoneLogLevel: 3,
extensionDevice: this.extensionDevice,
getState: () => this.state.webphone,
@@ -438,6 +448,9 @@ export default class Phone extends RcModule {
contactMatcher: this.contactMatcher,
webphone: this.webphone,
onRinging: async () => {
+ if (this.webphone._webphone) {
+ return;
+ }
// TODO refactor some of these logic into appropriate modules
this.router.push('/calls');
},
@@ -454,12 +467,6 @@ export default class Phone extends RcModule {
getState: () => this.state.callHistory,
}));
reducers.callHistory = this.callHistory.reducer;
- this.addModule('contactMatcher', new ContactMatcher({
- ...options,
- storage: this.storage,
- getState: () => this.state.contactMatcher,
- }));
- reducers.contactMatcher = this.contactMatcher.reducer;
this.addModule('activityMatcher', new ActivityMatcher({
...options,
storage: this.storage,
@@ -477,6 +484,34 @@ export default class Phone extends RcModule {
getState: () => this.state.callLogger,
}));
reducers.callLogger = this.callLogger.reducer;
+ this.addModule('accountPhoneNumber', new AccountPhoneNumber({
+ auth: this.auth,
+ client: this.client,
+ storage: this.storage,
+ tabManager: this.tabManager,
+ getState: () => this.state.accountPhoneNumber,
+ }));
+ reducers.accountPhoneNumber = this.accountPhoneNumber.reducer;
+ this.addModule('addressBook', new AddressBook({
+ client: this.client,
+ auth: this.auth,
+ storage: this.storage,
+ getState: () => this.state.addressBook,
+ }));
+ reducers.addressBook = this.addressBook.reducer;
+ this.addModule('contacts', new Contacts({
+ client: this.client,
+ addressBook: this.addressBook,
+ accountPhoneNumber: this.accountPhoneNumber,
+ accountExtension: this.accountExtension,
+ getState: () => this.state.contacts,
+ }));
+ reducers.contacts = this.contacts.reducer;
+ this.contactMatcher.addSearchProvider({
+ name: 'contacts',
+ searchFn: async ({ queries }) => this.contacts.matchContacts({ phoneNumbers: queries }),
+ readyCheckFn: () => this.contacts.ready,
+ });
this.addModule('conversationMatcher', new ConversationMatcher({
storage: this.storage,
getState: () => this.state.conversationMatcher,
diff --git a/dev-server/containers/App/index.js b/dev-server/containers/App/index.js
index 24c64d3254..8266c20448 100644
--- a/dev-server/containers/App/index.js
+++ b/dev-server/containers/App/index.js
@@ -45,6 +45,13 @@ export default function App({
webphone={phone.webphone}
regionSettings={phone.regionSettings}
router={phone.router}
+ contactMatcher={phone.contactMatcher}
+ getAvatarUrl={
+ async (contact) => {
+ const avatarUrl = await phone.contacts.getImageProfile(contact);
+ return avatarUrl;
+ }
+ }
>
);
+ } else {
+ avatar = ();
+ }
return (