From 344b50618447c77626a7cb429c2735ac03035f4c Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 28 Jan 2022 10:58:58 +0000 Subject: [PATCH] Rename properties related to Stickers (#7662) Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/rooms/MessageComposer.tsx | 18 +++++------ src/components/views/rooms/Stickerpicker.tsx | 32 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/components/views/rooms/MessageComposer.tsx b/src/components/views/rooms/MessageComposer.tsx index 20b21481a8..6cd4f6b685 100644 --- a/src/components/views/rooms/MessageComposer.tsx +++ b/src/components/views/rooms/MessageComposer.tsx @@ -255,7 +255,7 @@ interface IState { me?: RoomMember; narrowMode?: boolean; isMenuOpen: boolean; - showStickers: boolean; + isStickerPickerOpen: boolean; showStickersButton: boolean; showLocationButton: boolean; } @@ -286,7 +286,7 @@ export default class MessageComposer extends React.Component { haveRecording: false, recordingTimeLeftSeconds: null, // when set to a number, shows a toast isMenuOpen: false, - showStickers: false, + isStickerPickerOpen: false, showStickersButton: SettingsStore.getValue("MessageComposerInput.showStickersButton"), showLocationButton: ( !window.electron && @@ -315,7 +315,7 @@ export default class MessageComposer extends React.Component { this.setState({ narrowMode, isMenuOpen: !narrowMode ? false : this.state.isMenuOpen, - showStickers: false, + isStickerPickerOpen: false, }); } }; @@ -499,8 +499,8 @@ export default class MessageComposer extends React.Component { } }; - private showStickers = (showStickers: boolean) => { - this.setState({ showStickers }); + private setStickerPickerOpen = (isStickerPickerOpen: boolean) => { + this.setState({ isStickerPickerOpen }); }; private toggleButtonMenu = (): void => { @@ -547,7 +547,7 @@ export default class MessageComposer extends React.Component { if (this.state.showStickersButton) { let title: string; 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( @@ -555,7 +555,7 @@ export default class MessageComposer extends React.Component { id='stickersButton' key="controls_stickers" className="mx_MessageComposer_button mx_MessageComposer_stickers" - onClick={() => this.showStickers(!this.state.showStickers)} + onClick={() => this.setStickerPickerOpen(!this.state.isStickerPickerOpen)} title={title} label={this.state.narrowMode ? _t("Send a sticker") : null} />, @@ -692,8 +692,8 @@ export default class MessageComposer extends React.Component { , diff --git a/src/components/views/rooms/Stickerpicker.tsx b/src/components/views/rooms/Stickerpicker.tsx index e327d64953..aab1386082 100644 --- a/src/components/views/rooms/Stickerpicker.tsx +++ b/src/components/views/rooms/Stickerpicker.tsx @@ -48,9 +48,9 @@ const PERSISTED_ELEMENT_KEY = "stickerPicker"; interface IProps { room: Room; threadId?: string | null; - showStickers: boolean; + isStickerPickerOpen: boolean; menuPosition?: any; - setShowStickers: (showStickers: boolean) => void; + setStickerPickerOpen: (isStickerPickerOpen: boolean) => void; } interface IState { @@ -113,7 +113,7 @@ export default class Stickerpicker extends React.PureComponent { if (scalarClient) { scalarClient.disableWidgetAssets(WidgetType.STICKERPICKER, this.state.widgetId).then(() => { logger.log('Assets disabled'); - }).catch((err) => { + }).catch(() => { logger.error('Failed to disable assets'); }); } else { @@ -123,7 +123,7 @@ export default class Stickerpicker extends React.PureComponent { logger.warn('No widget ID specified, not disabling assets'); } - this.props.setShowStickers(false); + this.props.setStickerPickerOpen(false); WidgetUtils.removeStickerpickerWidgets().then(() => { this.forceUpdate(); }).catch((e) => { @@ -155,8 +155,8 @@ export default class Stickerpicker extends React.PureComponent { } } - public componentDidUpdate(prevProps: IProps, prevState: IState): void { - this.sendVisibilityToWidget(this.props.showStickers); + public componentDidUpdate(): void { + this.sendVisibilityToWidget(this.props.isStickerPickerOpen); } private imError(errorMsg: string, e: Error): void { @@ -164,7 +164,7 @@ export default class Stickerpicker extends React.PureComponent { this.setState({ imError: _t(errorMsg), }); - this.props.setShowStickers(false); + this.props.setStickerPickerOpen(false); } private updateWidget = (): void => { @@ -204,17 +204,17 @@ export default class Stickerpicker extends React.PureComponent { this.forceUpdate(); break; case "stickerpicker_close": - this.props.setShowStickers(false); + this.props.setStickerPickerOpen(false); break; case "show_left_panel": case "hide_left_panel": - this.props.setShowStickers(false); + this.props.setStickerPickerOpen(false); break; } }; private onRightPanelStoreUpdate = () => { - this.props.setShowStickers(false); + this.props.setStickerPickerOpen(false); }; private defaultStickerpickerContent(): JSX.Element { @@ -355,7 +355,7 @@ export default class Stickerpicker extends React.PureComponent { const y = (buttonRect.top + (buttonRect.height / 2) + window.pageYOffset) - 19; - this.props.setShowStickers(true); + this.props.setStickerPickerOpen(true); this.setState({ stickerpickerX: x, stickerpickerY: y, @@ -367,8 +367,8 @@ export default class Stickerpicker extends React.PureComponent { * Called when the window is resized */ private onResize = (): void => { - if (this.props.showStickers) { - this.props.setShowStickers(false); + if (this.props.isStickerPickerOpen) { + this.props.setStickerPickerOpen(false); } }; @@ -376,8 +376,8 @@ export default class Stickerpicker extends React.PureComponent { * The stickers picker was hidden */ private onFinished = (): void => { - if (this.props.showStickers) { - this.props.setShowStickers(false); + if (this.props.isStickerPickerOpen) { + this.props.setStickerPickerOpen(false); } }; @@ -402,7 +402,7 @@ export default class Stickerpicker extends React.PureComponent { }; public render(): JSX.Element { - if (!this.props.showStickers) return null; + if (!this.props.isStickerPickerOpen) return null; return