Correct stickerpicker naming,
This commit is contained in:
parent
ee4310cc41
commit
e249e3d622
3 changed files with 30 additions and 30 deletions
|
@ -24,7 +24,7 @@ import sdk from '../../../index';
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
import RoomViewStore from '../../../stores/RoomViewStore';
|
import RoomViewStore from '../../../stores/RoomViewStore';
|
||||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||||
import Stickerpack from './Stickerpack';
|
import Stickerpicker from './Stickerpicker';
|
||||||
|
|
||||||
export default class MessageComposer extends React.Component {
|
export default class MessageComposer extends React.Component {
|
||||||
constructor(props, context) {
|
constructor(props, context) {
|
||||||
|
@ -344,7 +344,7 @@ export default class MessageComposer extends React.Component {
|
||||||
hangupButton,
|
hangupButton,
|
||||||
callButton,
|
callButton,
|
||||||
videoCallButton,
|
videoCallButton,
|
||||||
<Stickerpack key='stickerpack_controls_button' room={this.props.room} />,
|
<Stickerpicker key='stickerpicker_controls_button' room={this.props.room} />,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
controls.push(
|
controls.push(
|
||||||
|
|
|
@ -26,14 +26,14 @@ import SdkConfig from '../../../SdkConfig';
|
||||||
import ScalarAuthClient from '../../../ScalarAuthClient';
|
import ScalarAuthClient from '../../../ScalarAuthClient';
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
|
|
||||||
export default class Stickerpack extends React.Component {
|
export default class Stickerpicker extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.onShowStickersClick = this.onShowStickersClick.bind(this);
|
this.onShowStickersClick = this.onShowStickersClick.bind(this);
|
||||||
this.onHideStickersClick = this.onHideStickersClick.bind(this);
|
this.onHideStickersClick = this.onHideStickersClick.bind(this);
|
||||||
this.onFinished = this.onFinished.bind(this);
|
this.onFinished = this.onFinished.bind(this);
|
||||||
this._launchManageIntegrations = this._launchManageIntegrations.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._onWidgetAction = this._onWidgetAction.bind(this);
|
||||||
|
|
||||||
this.defaultStickersContent = (
|
this.defaultStickersContent = (
|
||||||
|
@ -53,8 +53,8 @@ export default class Stickerpack extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeStickerpackWidgets() {
|
_removeStickerpickerWidgets() {
|
||||||
console.warn('Removing stickerpack widgets');
|
console.warn('Removing Stickerpicker widgets');
|
||||||
if (this.widgetId) {
|
if (this.widgetId) {
|
||||||
this.scalarClient.disableWidgetAssets('stickerpack', this.widgetId).then(() => {
|
this.scalarClient.disableWidgetAssets('stickerpack', this.widgetId).then(() => {
|
||||||
console.warn('Assets disabled');
|
console.warn('Assets disabled');
|
||||||
|
@ -64,7 +64,7 @@ export default class Stickerpack extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
console.warn('No widget ID specified, not disabling assets');
|
console.warn('No widget ID specified, not disabling assets');
|
||||||
}
|
}
|
||||||
Widgets.removeStickerpackWidgets();
|
Widgets.removeStickerpickerWidgets();
|
||||||
this._getStickerPickerWidget();
|
this._getStickerPickerWidget();
|
||||||
this.stickersMenu.close();
|
this.stickersMenu.close();
|
||||||
}
|
}
|
||||||
|
@ -109,16 +109,16 @@ export default class Stickerpack extends React.Component {
|
||||||
|
|
||||||
_getStickerPickerWidget() {
|
_getStickerPickerWidget() {
|
||||||
// Stickers
|
// Stickers
|
||||||
// TODO - Add support for stickerpacks from multiple app stores.
|
// TODO - Add support for Stickerpickers from multiple app stores.
|
||||||
// Render content from multiple stickerpack sources, each within their own iframe, within the stickerpack UI element.
|
// Render content from multiple stickerpack sources, each within their own iframe, within the stickerpicker UI element.
|
||||||
const stickerpackWidget = Widgets.getStickerpackWidgets()[0];
|
const stickerpickerWidget = Widgets.getStickerpickerWidgets()[0];
|
||||||
let stickersContent;
|
let stickersContent;
|
||||||
|
|
||||||
// Load stickerpack content
|
// Load stickerpack content
|
||||||
if (stickerpackWidget && stickerpackWidget.content && stickerpackWidget.content.url) {
|
if (stickerpickerWidget && stickerpickerWidget.content && stickerpickerWidget.content.url) {
|
||||||
// Set default name
|
// Set default name
|
||||||
stickerpackWidget.content.name = stickerpackWidget.name || "Stickerpack";
|
stickerpickerWidget.content.name = stickerpickerWidget.name || "Stickerpack";
|
||||||
this.widgetId = stickerpackWidget.id;
|
this.widgetId = stickerpickerWidget.id;
|
||||||
|
|
||||||
stickersContent = (
|
stickersContent = (
|
||||||
<div
|
<div
|
||||||
|
@ -137,19 +137,19 @@ export default class Stickerpack extends React.Component {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AppTile
|
<AppTile
|
||||||
id={stickerpackWidget.id}
|
id={stickerpickerWidget.id}
|
||||||
url={stickerpackWidget.content.url}
|
url={stickerpickerWidget.content.url}
|
||||||
name={stickerpackWidget.content.name}
|
name={stickerpickerWidget.content.name}
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
type={stickerpackWidget.content.type}
|
type={stickerpickerWidget.content.type}
|
||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
userId={stickerpackWidget.sender || MatrixClientPeg.get().credentials.userId}
|
userId={stickerpickerWidget.sender || MatrixClientPeg.get().credentials.userId}
|
||||||
creatorUserId={MatrixClientPeg.get().credentials.userId}
|
creatorUserId={MatrixClientPeg.get().credentials.userId}
|
||||||
waitForIframeLoad={true}
|
waitForIframeLoad={true}
|
||||||
show={true}
|
show={true}
|
||||||
showMenubar={true}
|
showMenubar={true}
|
||||||
onEditClick={this._launchManageIntegrations}
|
onEditClick={this._launchManageIntegrations}
|
||||||
onDeleteClick={this._removeStickerpackWidgets}
|
onDeleteClick={this._removeStickerpickerWidgets}
|
||||||
showTitle={false}
|
showTitle={false}
|
||||||
showMinimise={false}
|
showMinimise={false}
|
||||||
/>
|
/>
|
||||||
|
@ -157,7 +157,7 @@ export default class Stickerpack extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} 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");
|
console.warn("No available sticker picker widgets");
|
||||||
stickersContent = this.defaultStickersContent;
|
stickersContent = this.defaultStickersContent;
|
||||||
this.widgetId = null;
|
this.widgetId = null;
|
|
@ -45,26 +45,26 @@ function getUserWidgets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get active stickerpack widgets (stickerpacks are user widgets by nature)
|
* Get active stickerpicker widgets (stickerpickers are user widgets by nature)
|
||||||
* @return {[object]} Array containing current / active stickerpack widgets
|
* @return {[object]} Array containing current / active stickerpicker widgets
|
||||||
*/
|
*/
|
||||||
function getStickerpackWidgets() {
|
function getStickerpickerWidgets() {
|
||||||
const widgets = getUserWidgets();
|
const widgets = getUserWidgets();
|
||||||
const stickerpackWidgets = widgets.filter((widget) => widget.type='stickerpack');
|
const stickerpickerWidgets = widgets.filter((widget) => widget.type='m.stickerpicker');
|
||||||
return stickerpackWidgets;
|
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();
|
const client = MatrixClientPeg.get();
|
||||||
if (!client) {
|
if (!client) {
|
||||||
throw new Error('User not logged in');
|
throw new Error('User not logged in');
|
||||||
}
|
}
|
||||||
const userWidgets = client.getAccountData('m.widgets').getContent() || {};
|
const userWidgets = client.getAccountData('m.widgets').getContent() || {};
|
||||||
Object.entries(userWidgets).forEach(([key, widget]) => {
|
Object.entries(userWidgets).forEach(([key, widget]) => {
|
||||||
if (widget.type === 'stickerpack') {
|
if (widget.type === 'm.stickerpicker') {
|
||||||
delete userWidgets[key];
|
delete userWidgets[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -76,6 +76,6 @@ export default {
|
||||||
getWidgets,
|
getWidgets,
|
||||||
getRoomWidgets,
|
getRoomWidgets,
|
||||||
getUserWidgets,
|
getUserWidgets,
|
||||||
getStickerpackWidgets,
|
getStickerpickerWidgets,
|
||||||
removeStickerpackWidgets,
|
removeStickerpickerWidgets,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue