Reduce logging by moving getConversationById serviceId normalization
This commit is contained in:
parent
72a55da2b2
commit
348503c7f9
2 changed files with 36 additions and 11 deletions
|
@ -881,6 +881,10 @@ export const getConversationByAnyIdSelector = createSelector(
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onGroupId = getOwn(byGroupId, id);
|
||||||
|
if (onGroupId) {
|
||||||
|
return onGroupId;
|
||||||
|
}
|
||||||
const onServiceId = getOwn(
|
const onServiceId = getOwn(
|
||||||
byServiceId,
|
byServiceId,
|
||||||
normalizeServiceId(id, 'getConversationSelector')
|
normalizeServiceId(id, 'getConversationSelector')
|
||||||
|
@ -892,10 +896,6 @@ export const getConversationByAnyIdSelector = createSelector(
|
||||||
if (onE164) {
|
if (onE164) {
|
||||||
return onE164;
|
return onE164;
|
||||||
}
|
}
|
||||||
const onGroupId = getOwn(byGroupId, id);
|
|
||||||
if (onGroupId) {
|
|
||||||
return onGroupId;
|
|
||||||
}
|
|
||||||
const onId = getOwn(byId, id);
|
const onId = getOwn(byId, id);
|
||||||
if (onId) {
|
if (onId) {
|
||||||
return onId;
|
return onId;
|
||||||
|
|
|
@ -149,7 +149,7 @@ describe('both/state/selectors/conversations-extra', () => {
|
||||||
assert.deepEqual(actual, getPlaceholderContact());
|
assert.deepEqual(actual, getPlaceholderContact());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns conversation by uuid first', () => {
|
it('returns conversation by uuid', () => {
|
||||||
const id = 'id';
|
const id = 'id';
|
||||||
|
|
||||||
const conversation = makeConversation(id);
|
const conversation = makeConversation(id);
|
||||||
|
@ -168,9 +168,6 @@ describe('both/state/selectors/conversations-extra', () => {
|
||||||
conversationsByServiceId: {
|
conversationsByServiceId: {
|
||||||
[id]: conversation,
|
[id]: conversation,
|
||||||
},
|
},
|
||||||
conversationsByGroupId: {
|
|
||||||
[id]: wrongConversation,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -196,9 +193,6 @@ describe('both/state/selectors/conversations-extra', () => {
|
||||||
conversationsByE164: {
|
conversationsByE164: {
|
||||||
[id]: conversation,
|
[id]: conversation,
|
||||||
},
|
},
|
||||||
conversationsByGroupId: {
|
|
||||||
[id]: wrongConversation,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -233,6 +227,37 @@ describe('both/state/selectors/conversations-extra', () => {
|
||||||
|
|
||||||
assert.strictEqual(actual, conversation);
|
assert.strictEqual(actual, conversation);
|
||||||
});
|
});
|
||||||
|
it('returns conversation by groupId first', () => {
|
||||||
|
const id = 'id';
|
||||||
|
|
||||||
|
const conversation = makeConversation(id);
|
||||||
|
const wrongConversation = makeConversation('wrong');
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
...getEmptyRootState(),
|
||||||
|
conversations: {
|
||||||
|
...getEmptyState(),
|
||||||
|
conversationLookup: {
|
||||||
|
[id]: wrongConversation,
|
||||||
|
},
|
||||||
|
conversationsByGroupId: {
|
||||||
|
[id]: conversation,
|
||||||
|
},
|
||||||
|
conversationsByE164: {
|
||||||
|
[id]: wrongConversation,
|
||||||
|
},
|
||||||
|
conversationsByServiceId: {
|
||||||
|
[id]: wrongConversation,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const selector = getConversationSelector(state);
|
||||||
|
|
||||||
|
const actual = selector(id);
|
||||||
|
|
||||||
|
assert.strictEqual(actual, conversation);
|
||||||
|
});
|
||||||
it('returns conversation by conversationId', () => {
|
it('returns conversation by conversationId', () => {
|
||||||
const id = 'id';
|
const id = 'id';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue