Correct stickerpicker naming,

This commit is contained in:
Richard Lewis 2018-02-25 22:10:38 +00:00
parent ee4310cc41
commit e249e3d622
3 changed files with 30 additions and 30 deletions

View file

@ -24,7 +24,7 @@ import sdk from '../../../index';
import dis from '../../../dispatcher';
import RoomViewStore from '../../../stores/RoomViewStore';
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
import Stickerpack from './Stickerpack';
import Stickerpicker from './Stickerpicker';
export default class MessageComposer extends React.Component {
constructor(props, context) {
@ -344,7 +344,7 @@ export default class MessageComposer extends React.Component {
hangupButton,
callButton,
videoCallButton,
<Stickerpack key='stickerpack_controls_button' room={this.props.room} />,
<Stickerpicker key='stickerpicker_controls_button' room={this.props.room} />,
);
} else {
controls.push(

View file

@ -26,14 +26,14 @@ import SdkConfig from '../../../SdkConfig';
import ScalarAuthClient from '../../../ScalarAuthClient';
import dis from '../../../dispatcher';
export default class Stickerpack extends React.Component {
export default class Stickerpicker extends React.Component {
constructor(props) {
super(props);
this.onShowStickersClick = this.onShowStickersClick.bind(this);
this.onHideStickersClick = this.onHideStickersClick.bind(this);
this.onFinished = this.onFinished.bind(this);
this._launchManageIntegrations = this._launchManageIntegrations.bind(this);
this._removeStickerpackWidgets = this._removeStickerpackWidgets.bind(this);
this._removeStickerpickerWidgets = this._removeStickerpickerWidgets.bind(this);
this._onWidgetAction = this._onWidgetAction.bind(this);
this.defaultStickersContent = (
@ -53,8 +53,8 @@ export default class Stickerpack extends React.Component {
};
}
_removeStickerpackWidgets() {
console.warn('Removing stickerpack widgets');
_removeStickerpickerWidgets() {
console.warn('Removing Stickerpicker widgets');
if (this.widgetId) {
this.scalarClient.disableWidgetAssets('stickerpack', this.widgetId).then(() => {
console.warn('Assets disabled');
@ -64,7 +64,7 @@ export default class Stickerpack extends React.Component {
} else {
console.warn('No widget ID specified, not disabling assets');
}
Widgets.removeStickerpackWidgets();
Widgets.removeStickerpickerWidgets();
this._getStickerPickerWidget();
this.stickersMenu.close();
}
@ -109,16 +109,16 @@ export default class Stickerpack extends React.Component {
_getStickerPickerWidget() {
// Stickers
// TODO - Add support for stickerpacks from multiple app stores.
// Render content from multiple stickerpack sources, each within their own iframe, within the stickerpack UI element.
const stickerpackWidget = Widgets.getStickerpackWidgets()[0];
// TODO - Add support for Stickerpickers from multiple app stores.
// Render content from multiple stickerpack sources, each within their own iframe, within the stickerpicker UI element.
const stickerpickerWidget = Widgets.getStickerpickerWidgets()[0];
let stickersContent;
// Load stickerpack content
if (stickerpackWidget && stickerpackWidget.content && stickerpackWidget.content.url) {
if (stickerpickerWidget && stickerpickerWidget.content && stickerpickerWidget.content.url) {
// Set default name
stickerpackWidget.content.name = stickerpackWidget.name || "Stickerpack";
this.widgetId = stickerpackWidget.id;
stickerpickerWidget.content.name = stickerpickerWidget.name || "Stickerpack";
this.widgetId = stickerpickerWidget.id;
stickersContent = (
<div
@ -137,19 +137,19 @@ export default class Stickerpack extends React.Component {
}}
>
<AppTile
id={stickerpackWidget.id}
url={stickerpackWidget.content.url}
name={stickerpackWidget.content.name}
id={stickerpickerWidget.id}
url={stickerpickerWidget.content.url}
name={stickerpickerWidget.content.name}
room={this.props.room}
type={stickerpackWidget.content.type}
type={stickerpickerWidget.content.type}
fullWidth={true}
userId={stickerpackWidget.sender || MatrixClientPeg.get().credentials.userId}
userId={stickerpickerWidget.sender || MatrixClientPeg.get().credentials.userId}
creatorUserId={MatrixClientPeg.get().credentials.userId}
waitForIframeLoad={true}
show={true}
showMenubar={true}
onEditClick={this._launchManageIntegrations}
onDeleteClick={this._removeStickerpackWidgets}
onDeleteClick={this._removeStickerpickerWidgets}
showTitle={false}
showMinimise={false}
/>
@ -157,7 +157,7 @@ export default class Stickerpack extends React.Component {
</div>
);
} else {
// Default content to show if stickerpack widget not added
// Default content to show if stickerpicker widget not added
console.warn("No available sticker picker widgets");
stickersContent = this.defaultStickersContent;
this.widgetId = null;

View file

@ -45,26 +45,26 @@ function getUserWidgets() {
}
/**
* Get active stickerpack widgets (stickerpacks are user widgets by nature)
* @return {[object]} Array containing current / active stickerpack widgets
* Get active stickerpicker widgets (stickerpickers are user widgets by nature)
* @return {[object]} Array containing current / active stickerpicker widgets
*/
function getStickerpackWidgets() {
function getStickerpickerWidgets() {
const widgets = getUserWidgets();
const stickerpackWidgets = widgets.filter((widget) => widget.type='stickerpack');
return stickerpackWidgets;
const stickerpickerWidgets = widgets.filter((widget) => widget.type='m.stickerpicker');
return stickerpickerWidgets;
}
/**
* Remove all stickerpack widgets (stickerpacks are user widgets by nature)
* Remove all stickerpicker widgets (stickerpickers are user widgets by nature)
*/
function removeStickerpackWidgets() {
function removeStickerpickerWidgets() {
const client = MatrixClientPeg.get();
if (!client) {
throw new Error('User not logged in');
}
const userWidgets = client.getAccountData('m.widgets').getContent() || {};
Object.entries(userWidgets).forEach(([key, widget]) => {
if (widget.type === 'stickerpack') {
if (widget.type === 'm.stickerpicker') {
delete userWidgets[key];
}
});
@ -76,6 +76,6 @@ export default {
getWidgets,
getRoomWidgets,
getUserWidgets,
getStickerpackWidgets,
removeStickerpackWidgets,
getStickerpickerWidgets,
removeStickerpickerWidgets,
};