Rename properties related to Stickers (#7662)

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Andy Balaam 2022-01-28 10:58:58 +00:00 committed by GitHub
parent cbc671b19f
commit 344b506184
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 25 deletions

View file

@ -255,7 +255,7 @@ interface IState {
me?: RoomMember; me?: RoomMember;
narrowMode?: boolean; narrowMode?: boolean;
isMenuOpen: boolean; isMenuOpen: boolean;
showStickers: boolean; isStickerPickerOpen: boolean;
showStickersButton: boolean; showStickersButton: boolean;
showLocationButton: boolean; showLocationButton: boolean;
} }
@ -286,7 +286,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
haveRecording: false, haveRecording: false,
recordingTimeLeftSeconds: null, // when set to a number, shows a toast recordingTimeLeftSeconds: null, // when set to a number, shows a toast
isMenuOpen: false, isMenuOpen: false,
showStickers: false, isStickerPickerOpen: false,
showStickersButton: SettingsStore.getValue("MessageComposerInput.showStickersButton"), showStickersButton: SettingsStore.getValue("MessageComposerInput.showStickersButton"),
showLocationButton: ( showLocationButton: (
!window.electron && !window.electron &&
@ -315,7 +315,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
this.setState({ this.setState({
narrowMode, narrowMode,
isMenuOpen: !narrowMode ? false : this.state.isMenuOpen, isMenuOpen: !narrowMode ? false : this.state.isMenuOpen,
showStickers: false, isStickerPickerOpen: false,
}); });
} }
}; };
@ -499,8 +499,8 @@ export default class MessageComposer extends React.Component<IProps, IState> {
} }
}; };
private showStickers = (showStickers: boolean) => { private setStickerPickerOpen = (isStickerPickerOpen: boolean) => {
this.setState({ showStickers }); this.setState({ isStickerPickerOpen });
}; };
private toggleButtonMenu = (): void => { private toggleButtonMenu = (): void => {
@ -547,7 +547,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
if (this.state.showStickersButton) { if (this.state.showStickersButton) {
let title: string; let title: string;
if (!this.state.narrowMode) { if (!this.state.narrowMode) {
title = this.state.showStickers ? _t("Hide Stickers") : _t("Show Stickers"); title = this.state.isStickerPickerOpen ? _t("Hide Stickers") : _t("Show Stickers");
} }
buttons.push( buttons.push(
@ -555,7 +555,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
id='stickersButton' id='stickersButton'
key="controls_stickers" key="controls_stickers"
className="mx_MessageComposer_button mx_MessageComposer_stickers" className="mx_MessageComposer_button mx_MessageComposer_stickers"
onClick={() => this.showStickers(!this.state.showStickers)} onClick={() => this.setStickerPickerOpen(!this.state.isStickerPickerOpen)}
title={title} title={title}
label={this.state.narrowMode ? _t("Send a sticker") : null} label={this.state.narrowMode ? _t("Send a sticker") : null}
/>, />,
@ -692,8 +692,8 @@ export default class MessageComposer extends React.Component<IProps, IState> {
<Stickerpicker <Stickerpicker
room={this.props.room} room={this.props.room}
threadId={threadId} threadId={threadId}
showStickers={this.state.showStickers} isStickerPickerOpen={this.state.isStickerPickerOpen}
setShowStickers={this.showStickers} setStickerPickerOpen={this.setStickerPickerOpen}
menuPosition={menuPosition} menuPosition={menuPosition}
key="stickers" key="stickers"
/>, />,

View file

@ -48,9 +48,9 @@ const PERSISTED_ELEMENT_KEY = "stickerPicker";
interface IProps { interface IProps {
room: Room; room: Room;
threadId?: string | null; threadId?: string | null;
showStickers: boolean; isStickerPickerOpen: boolean;
menuPosition?: any; menuPosition?: any;
setShowStickers: (showStickers: boolean) => void; setStickerPickerOpen: (isStickerPickerOpen: boolean) => void;
} }
interface IState { interface IState {
@ -113,7 +113,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
if (scalarClient) { if (scalarClient) {
scalarClient.disableWidgetAssets(WidgetType.STICKERPICKER, this.state.widgetId).then(() => { scalarClient.disableWidgetAssets(WidgetType.STICKERPICKER, this.state.widgetId).then(() => {
logger.log('Assets disabled'); logger.log('Assets disabled');
}).catch((err) => { }).catch(() => {
logger.error('Failed to disable assets'); logger.error('Failed to disable assets');
}); });
} else { } else {
@ -123,7 +123,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
logger.warn('No widget ID specified, not disabling assets'); logger.warn('No widget ID specified, not disabling assets');
} }
this.props.setShowStickers(false); this.props.setStickerPickerOpen(false);
WidgetUtils.removeStickerpickerWidgets().then(() => { WidgetUtils.removeStickerpickerWidgets().then(() => {
this.forceUpdate(); this.forceUpdate();
}).catch((e) => { }).catch((e) => {
@ -155,8 +155,8 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
} }
} }
public componentDidUpdate(prevProps: IProps, prevState: IState): void { public componentDidUpdate(): void {
this.sendVisibilityToWidget(this.props.showStickers); this.sendVisibilityToWidget(this.props.isStickerPickerOpen);
} }
private imError(errorMsg: string, e: Error): void { private imError(errorMsg: string, e: Error): void {
@ -164,7 +164,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
this.setState({ this.setState({
imError: _t(errorMsg), imError: _t(errorMsg),
}); });
this.props.setShowStickers(false); this.props.setStickerPickerOpen(false);
} }
private updateWidget = (): void => { private updateWidget = (): void => {
@ -204,17 +204,17 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
this.forceUpdate(); this.forceUpdate();
break; break;
case "stickerpicker_close": case "stickerpicker_close":
this.props.setShowStickers(false); this.props.setStickerPickerOpen(false);
break; break;
case "show_left_panel": case "show_left_panel":
case "hide_left_panel": case "hide_left_panel":
this.props.setShowStickers(false); this.props.setStickerPickerOpen(false);
break; break;
} }
}; };
private onRightPanelStoreUpdate = () => { private onRightPanelStoreUpdate = () => {
this.props.setShowStickers(false); this.props.setStickerPickerOpen(false);
}; };
private defaultStickerpickerContent(): JSX.Element { private defaultStickerpickerContent(): JSX.Element {
@ -355,7 +355,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
const y = (buttonRect.top + (buttonRect.height / 2) + window.pageYOffset) - 19; const y = (buttonRect.top + (buttonRect.height / 2) + window.pageYOffset) - 19;
this.props.setShowStickers(true); this.props.setStickerPickerOpen(true);
this.setState({ this.setState({
stickerpickerX: x, stickerpickerX: x,
stickerpickerY: y, stickerpickerY: y,
@ -367,8 +367,8 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
* Called when the window is resized * Called when the window is resized
*/ */
private onResize = (): void => { private onResize = (): void => {
if (this.props.showStickers) { if (this.props.isStickerPickerOpen) {
this.props.setShowStickers(false); this.props.setStickerPickerOpen(false);
} }
}; };
@ -376,8 +376,8 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
* The stickers picker was hidden * The stickers picker was hidden
*/ */
private onFinished = (): void => { private onFinished = (): void => {
if (this.props.showStickers) { if (this.props.isStickerPickerOpen) {
this.props.setShowStickers(false); this.props.setStickerPickerOpen(false);
} }
}; };
@ -402,7 +402,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
}; };
public render(): JSX.Element { public render(): JSX.Element {
if (!this.props.showStickers) return null; if (!this.props.isStickerPickerOpen) return null;
return <ContextMenu return <ContextMenu
chevronOffset={this.state.stickerpickerChevronOffset} chevronOffset={this.state.stickerpickerChevronOffset}