mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-15 07:28:59 +00:00
Reduce logging by moving getConversationById serviceId normalization
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user