Reduce logging by moving getConversationById serviceId normalization

This commit is contained in:
ayumi-signal 2024-06-05 17:19:48 -07:00 committed by GitHub
parent 72a55da2b2
commit 348503c7f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 11 deletions

View file

@ -881,6 +881,10 @@ export const getConversationByAnyIdSelector = createSelector(
return undefined;
}
const onGroupId = getOwn(byGroupId, id);
if (onGroupId) {
return onGroupId;
}
const onServiceId = getOwn(
byServiceId,
normalizeServiceId(id, 'getConversationSelector')
@ -892,10 +896,6 @@ export const getConversationByAnyIdSelector = createSelector(
if (onE164) {
return onE164;
}
const onGroupId = getOwn(byGroupId, id);
if (onGroupId) {
return onGroupId;
}
const onId = getOwn(byId, id);
if (onId) {
return onId;

View file

@ -149,7 +149,7 @@ describe('both/state/selectors/conversations-extra', () => {
assert.deepEqual(actual, getPlaceholderContact());
});
it('returns conversation by uuid first', () => {
it('returns conversation by uuid', () => {
const id = 'id';
const conversation = makeConversation(id);
@ -168,9 +168,6 @@ describe('both/state/selectors/conversations-extra', () => {
conversationsByServiceId: {
[id]: conversation,
},
conversationsByGroupId: {
[id]: wrongConversation,
},
},
};
@ -196,9 +193,6 @@ describe('both/state/selectors/conversations-extra', () => {
conversationsByE164: {
[id]: conversation,
},
conversationsByGroupId: {
[id]: wrongConversation,
},
},
};
@ -233,6 +227,37 @@ describe('both/state/selectors/conversations-extra', () => {
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', () => {
const id = 'id';