Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import * as R from 'ramda';
import { combineReducers } from 'redux';
import getModuleStatusReducer from 'ringcentral-integration/lib/getModuleStatusReducer';

function getCallsSavingStatusReducer(types) {
return (state = {}, { type, identify }) => {
switch (type) {
case types.saving:
return R.assoc(identify, true, state);
case types.saveSuccess: case types.saveError:
return R.assoc(identify, false, state);
case types.cleanUp:
return {};
default:
return state;
}
};
}

export default function getCallLogSectionReducer(types) {
return combineReducers({
status: getModuleStatusReducer(types),
callsSavingStatus: getCallsSavingStatusReducer(types),
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function getCallsMappingReducer(types) {
...state,
[identify]: {
...state[identify],
isSaving: true
},
};
case types.saveSuccess:
Expand All @@ -25,7 +24,6 @@ function getCallsMappingReducer(types) {
[identify]: {
...state[identify],
isEdited: false,
isSaving: false,
},
};
case types.saveError:
Expand All @@ -34,7 +32,6 @@ function getCallsMappingReducer(types) {
[identify]: {
...state[identify],
isEdited: true,
isSaving: false,
},
};
case types.cleanUp:
Expand Down
23 changes: 22 additions & 1 deletion packages/ringcentral-widgets/modules/CallLogSection/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as R from 'ramda';
import RcModule from 'ringcentral-integration/lib/RcModule';
import { Module } from 'ringcentral-integration/lib/di';
import ensureExist from 'ringcentral-integration/lib/ensureExist';
Expand Down Expand Up @@ -216,14 +217,34 @@ export default class CallLogSection extends RcModule {
(list, mapping) => list.map(identify => mapping[identify])
);

/**
* Merge isSaving property from reducer to callsMapping
*/
@getter
callsMapping = createSelector(
() => this._callsMapping,
() => this._callsSavingStatus,
R.converge(
R.mergeWith(R.flip(R.assoc('isSaving'))),
[R.identity, R.useWith(R.pick, [R.keys, R.identity])]
)
)

get callsList() {
return this._storage.getItem(this._storageKey).callsList;
}

get callsMapping() {
/**
* Private calls mapping relationship without isSaving property
*/
get _callsMapping() {
return this._storage.getItem(this._storageKey).callsMapping;
}

get _callsSavingStatus() {
return this.state.callsSavingStatus;
}

get currentIdentify() {
return this._storage.getItem(this._storageKey).currentIdentify;
}
Expand Down