Skip to content

Commit c56222b

Browse files
committed
chore: use tStrippedWithObj and remove strippedWithObj
1 parent 8540aa6 commit c56222b

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

ts/localization/localeTools.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,6 @@ export function tStrippedWithObj<T extends MergedLocalizerTokens>(
128128
return builder.toString();
129129
}
130130

131-
export function strippedWithObj<T extends MergedLocalizerTokens>(
132-
opts: LocalizerComponentProps<T, string>
133-
): string | T {
134-
const sanitizedArgs = opts.args ? sanitizeArgs(opts.args, '\u200B') : undefined;
135-
136-
// Note: the `as any` is needed sanitizeArgs does not preserve argument types
137-
const i18nString = new LocalizedStringBuilder<T>(opts.token as any, localeInUse)
138-
.withArgs(sanitizedArgs as any)
139-
.toString();
140-
141-
const strippedString = i18nString.replaceAll(/<[^>]*>/g, '');
142-
143-
return deSanitizeHtmlTags(strippedString, '\u200B');
144-
}
145-
146131
/**
147132
* Sanitizes the args to be used in the i18n function
148133
* @param args The args to sanitize

ts/models/message.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ import { getTimerNotificationStr } from './timerNotifications';
9393
import { ExpirationTimerUpdate } from '../session/disappearing_messages/types';
9494
import { Model } from './models';
9595
import { ReduxOnionSelectors } from '../state/selectors/onions';
96-
import { strippedWithObj, tr, tStripped } from '../localization/localeTools';
96+
import { tStrippedWithObj, tr, tStripped } from '../localization/localeTools';
9797

9898
// tslint:disable: cyclomatic-complexity
9999

@@ -246,20 +246,20 @@ export class MessageModel extends Model<MessageAttributes> {
246246
this.getConversation()?.getNicknameOrRealUsernameOrPlaceholder() || tr('unknown');
247247

248248
if (groupUpdate.left) {
249-
return strippedWithObj(getLeftGroupUpdateChangeStr(groupUpdate.left));
249+
return tStrippedWithObj(getLeftGroupUpdateChangeStr(groupUpdate.left));
250250
}
251251

252252
if (groupUpdate.name) {
253-
return strippedWithObj(getGroupNameChangeStr(groupUpdate.name));
253+
return tStrippedWithObj(getGroupNameChangeStr(groupUpdate.name));
254254
}
255255

256256
if (groupUpdate.avatarChange) {
257-
return strippedWithObj(getGroupDisplayPictureChangeStr());
257+
return tStrippedWithObj(getGroupDisplayPictureChangeStr());
258258
}
259259

260260
if (groupUpdate.joined?.length) {
261261
const opts = getJoinedGroupUpdateChangeStr(groupUpdate.joined, isGroupV2, false, groupName);
262-
return strippedWithObj(opts);
262+
return tStrippedWithObj(opts);
263263
}
264264

265265
if (groupUpdate.joinedWithHistory?.length) {
@@ -269,16 +269,16 @@ export class MessageModel extends Model<MessageAttributes> {
269269
true,
270270
groupName
271271
);
272-
return strippedWithObj(opts);
272+
return tStrippedWithObj(opts);
273273
}
274274

275275
if (groupUpdate.kicked?.length) {
276276
const opts = getKickedGroupUpdateStr(groupUpdate.kicked, groupName);
277-
return strippedWithObj(opts);
277+
return tStrippedWithObj(opts);
278278
}
279279
if (groupUpdate.promoted?.length) {
280280
const opts = getPromotedGroupUpdateChangeStr(groupUpdate.promoted);
281-
return strippedWithObj(opts);
281+
return tStrippedWithObj(opts);
282282
}
283283
window.log.warn('did not build a specific change for getDescription of ', groupUpdate);
284284

@@ -381,7 +381,7 @@ export class MessageModel extends Model<MessageAttributes> {
381381
timespanSeconds: expireTimer,
382382
});
383383

384-
return strippedWithObj(i18nProps);
384+
return tStrippedWithObj(i18nProps);
385385
}
386386
const body = this.get('body');
387387
if (body) {

ts/session/utils/Toast.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { toast } from 'react-toastify';
22
import { SessionToast, SessionToastType } from '../../components/basic/SessionToast';
33
import { sectionActions, SectionType } from '../../state/ducks/section';
44
import { getPromotedGroupUpdateChangeStr } from '../../models/groupUpdate';
5-
import { strippedWithObj, tStripped } from '../../localization/localeTools';
5+
import { tStripped, tStrippedWithObj } from '../../localization/localeTools';
66

77
// if you push a toast manually with toast...() be sure to set the type attribute of the SessionToast component
88
export function pushToastError(id: string, description: string) {
@@ -212,7 +212,7 @@ export function pushFailedToRemoveFromModerator(names: Array<string>) {
212212

213213
export function pushUserAddedToModerators(userNames: Array<string>) {
214214
const opts = getPromotedGroupUpdateChangeStr(userNames);
215-
pushToastSuccess('adminPromotedToAdmin', strippedWithObj(opts));
215+
pushToastSuccess('adminPromotedToAdmin', tStrippedWithObj(opts));
216216
}
217217

218218
export function pushUserRemovedFromModerators(names: Array<string>) {

0 commit comments

Comments
 (0)