Fix rendering of group joins and remove checkServiceIdEquivalence

This commit is contained in:
Scott Nonnenberg 2024-05-03 07:28:36 -07:00 committed by GitHub
parent 214fae0c6e
commit a1f0afdae8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 108 additions and 65 deletions

View file

@ -37,10 +37,6 @@ export type RenderOptionsType<T extends string | JSX.Element> = {
ourAci: AciString | undefined;
ourPni: PniString | undefined;
renderContact: SmartContactRendererType<T>;
checkServiceIdEquivalence(
left: ServiceIdString | undefined,
right: ServiceIdString | undefined
): boolean;
renderIntl: StringRendererType<T>;
};
@ -87,7 +83,6 @@ function renderChangeDetail<T extends string | JSX.Element>(
options: RenderOptionsType<T>
): string | T | ReadonlyArray<string | T> {
const {
checkServiceIdEquivalence,
from,
i18n: localizer,
ourAci,
@ -301,11 +296,14 @@ function renderChangeDetail<T extends string | JSX.Element>(
});
}
if (detail.type === 'member-add-from-invite') {
const { aci, inviter } = detail;
const { aci, inviter, pni } = detail;
const weAreJoiner = isOurServiceId(aci);
const weAreInviter = isOurServiceId(inviter);
if (!from || !checkServiceIdEquivalence(from, aci)) {
const fromPni = pni && from === pni;
const fromAci = from === aci;
if (!from || (!fromPni && !fromAci)) {
if (weAreJoiner) {
// They can't be the same, no fromYou check here
if (from) {
@ -433,7 +431,7 @@ function renderChangeDetail<T extends string | JSX.Element>(
memberName: renderContact(aci),
});
}
if (from && fromYou) {
if (from && from === aci) {
return i18n('icu:GroupV2--member-remove--other--self', {
memberName: renderContact(from),
});