Fix: Avatar preview does not update when same file is selected repeatedly (#8288)
* Fix: Avatar preview does not update when same file is selected repeatedly Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
7600182a35
commit
dbcb56f75e
9 changed files with 48 additions and 3 deletions
|
@ -26,6 +26,7 @@ import Spinner from '../elements/Spinner';
|
|||
import { mediaFromMxc } from "../../../customisations/Media";
|
||||
import RoomAvatar from '../avatars/RoomAvatar';
|
||||
import BaseAvatar from '../avatars/BaseAvatar';
|
||||
import { chromeFileInputFix } from "../../../utils/BrowserWorkarounds";
|
||||
|
||||
interface IProps {
|
||||
initialAvatarUrl?: string;
|
||||
|
@ -182,7 +183,7 @@ export default class ChangeAvatar extends React.Component<IProps, IState> {
|
|||
uploadSection = (
|
||||
<div className={this.props.className}>
|
||||
{ _t("Upload new:") }
|
||||
<input type="file" accept="image/*" onChange={this.onFileSelected} />
|
||||
<input type="file" accept="image/*" onClick={chromeFileInputFix} onChange={this.onFileSelected} />
|
||||
{ this.state.errorText }
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -29,6 +29,7 @@ import AccessibleButton from '../elements/AccessibleButton';
|
|||
import AvatarSetting from './AvatarSetting';
|
||||
import ExternalLink from '../elements/ExternalLink';
|
||||
import UserIdentifierCustomisations from '../../../customisations/UserIdentifier';
|
||||
import { chromeFileInputFix } from "../../../utils/BrowserWorkarounds";
|
||||
|
||||
interface IState {
|
||||
userId?: string;
|
||||
|
@ -188,6 +189,7 @@ export default class ProfileSettings extends React.Component<{}, IState> {
|
|||
type="file"
|
||||
ref={this.avatarUpload}
|
||||
className="mx_ProfileSettings_avatarUpload"
|
||||
onClick={chromeFileInputFix}
|
||||
onChange={this.onAvatarChanged}
|
||||
accept="image/*"
|
||||
/>
|
||||
|
|
|
@ -31,6 +31,7 @@ import { RoomNotifState } from '../../../../../RoomNotifs';
|
|||
import defaultDispatcher from "../../../../../dispatcher/dispatcher";
|
||||
import { Action } from "../../../../../dispatcher/actions";
|
||||
import { UserTab } from "../../../dialogs/UserTab";
|
||||
import { chromeFileInputFix } from "../../../../../utils/BrowserWorkarounds";
|
||||
|
||||
interface IProps {
|
||||
roomId: string;
|
||||
|
@ -77,7 +78,7 @@ export default class NotificationsSettingsTab extends React.Component<IProps, IS
|
|||
this.soundUpload.current.click();
|
||||
};
|
||||
|
||||
private onSoundUploadChanged = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => {
|
||||
private onSoundUploadChanged = (e: React.ChangeEvent<HTMLInputElement>): void => {
|
||||
if (!e.target.files || !e.target.files.length) {
|
||||
this.setState({
|
||||
uploadedFile: null,
|
||||
|
@ -254,7 +255,14 @@ export default class NotificationsSettingsTab extends React.Component<IProps, IS
|
|||
<h3>{ _t("Set a new custom sound") }</h3>
|
||||
<div className="mx_SettingsFlag">
|
||||
<form autoComplete="off" noValidate={true}>
|
||||
<input ref={this.soundUpload} className="mx_NotificationSound_soundUpload" type="file" onChange={this.onSoundUploadChanged} accept="audio/*" />
|
||||
<input
|
||||
ref={this.soundUpload}
|
||||
className="mx_NotificationSound_soundUpload"
|
||||
type="file"
|
||||
onClick={chromeFileInputFix}
|
||||
onChange={this.onSoundUploadChanged}
|
||||
accept="audio/*"
|
||||
/>
|
||||
</form>
|
||||
|
||||
{ currentUploadedFile }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue