Replace deprecated String#substr with String#slice (#8314)

This commit is contained in:
CommanderRoot 2022-04-14 09:52:42 +02:00 committed by GitHub
parent 0e68c16a90
commit c35fc169f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 37 additions and 37 deletions

View file

@ -103,7 +103,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
createOpts.preset = Preset.PublicChat;
opts.guestAccess = false;
const { alias } = this.state;
createOpts.room_alias_name = alias.substr(1, alias.indexOf(":") - 1);
createOpts.room_alias_name = alias.substring(1, alias.indexOf(":"));
} else {
// If we cannot change encryption we pass `true` for safety, the server should automatically do this for us.
opts.encryption = this.state.canChangeEncryption ? this.state.isEncrypted : true;

View file

@ -55,7 +55,7 @@ const EffectsOverlay: FunctionComponent<IProps> = ({ roomWidth }) => {
const onAction = (payload: { action: string }) => {
const actionPrefix = 'effects.';
if (payload.action.indexOf(actionPrefix) === 0) {
const effect = payload.action.substr(actionPrefix.length);
const effect = payload.action.slice(actionPrefix.length);
lazyLoadEffectModule(effect).then((module) => module?.start(canvasRef.current));
}
};

View file

@ -364,7 +364,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
private insertText(textToInsert: string, inputType = "insertText"): void {
const sel = document.getSelection();
const { caret, text } = getCaretOffsetAndText(this.editorRef.current, sel);
const newText = text.substr(0, caret.offset) + textToInsert + text.substr(caret.offset);
const newText = text.slice(0, caret.offset) + textToInsert + text.slice(caret.offset);
caret.offset += textToInsert.length;
this.modifiedFlag = true;
this.props.model.update(newText, inputType, caret);

View file

@ -274,7 +274,7 @@ export default class MemberList extends React.Component<IProps, IState> {
this.sortNames.set(
member,
(member.name[0] === '@' ? member.name.substr(1) : member.name).replace(SORT_REGEX, ""),
(member.name[0] === '@' ? member.name.slice(1) : member.name).replace(SORT_REGEX, ""),
);
// XXX: this user may have no lastPresenceTs value!

View file

@ -56,7 +56,7 @@ export const createSpace = async (
events_default: 100,
invite: isPublic ? 0 : 50,
},
room_alias_name: isPublic && alias ? alias.substr(1, alias.indexOf(":") - 1) : undefined,
room_alias_name: isPublic && alias ? alias.substring(1, alias.indexOf(":")) : undefined,
topic,
...createOpts,
},