Allow stickers to be sent in a Thread (#7267)
This commit is contained in:
parent
141950d9e6
commit
f2fee53a0e
5 changed files with 35 additions and 6 deletions
|
@ -419,9 +419,16 @@ export default class ContentMessages {
|
||||||
private inprogress: IUpload[] = [];
|
private inprogress: IUpload[] = [];
|
||||||
private mediaConfig: IMediaConfig = null;
|
private mediaConfig: IMediaConfig = null;
|
||||||
|
|
||||||
sendStickerContentToRoom(url: string, roomId: string, info: IImageInfo, text: string, matrixClient: MatrixClient) {
|
sendStickerContentToRoom(
|
||||||
|
url: string,
|
||||||
|
roomId: string,
|
||||||
|
threadId: string | null,
|
||||||
|
info: IImageInfo,
|
||||||
|
text: string,
|
||||||
|
matrixClient: MatrixClient,
|
||||||
|
) {
|
||||||
const startTime = CountlyAnalytics.getTimestamp();
|
const startTime = CountlyAnalytics.getTimestamp();
|
||||||
const prom = matrixClient.sendStickerMessage(roomId, url, info, text).catch((e) => {
|
const prom = matrixClient.sendStickerMessage(roomId, threadId, url, info, text).catch((e) => {
|
||||||
logger.warn(`Failed to send content with URL ${url} to room ${roomId}`, e);
|
logger.warn(`Failed to send content with URL ${url} to room ${roomId}`, e);
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
|
|
|
@ -843,7 +843,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
this.injectSticker(
|
this.injectSticker(
|
||||||
payload.data.content.url,
|
payload.data.content.url,
|
||||||
payload.data.content.info,
|
payload.data.content.info,
|
||||||
payload.data.description || payload.data.name);
|
payload.data.description || payload.data.name,
|
||||||
|
payload.data.threadId);
|
||||||
break;
|
break;
|
||||||
case 'picture_snapshot':
|
case 'picture_snapshot':
|
||||||
ContentMessages.sharedInstance().sendContentListToRoom(
|
ContentMessages.sharedInstance().sendContentListToRoom(
|
||||||
|
@ -1352,13 +1353,14 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private injectSticker(url: string, info: object, text: string) {
|
private injectSticker(url: string, info: object, text: string, threadId: string | null) {
|
||||||
if (this.context.isGuest()) {
|
if (this.context.isGuest()) {
|
||||||
dis.dispatch({ action: 'require_registration' });
|
dis.dispatch({ action: 'require_registration' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentMessages.sharedInstance().sendStickerContentToRoom(url, this.state.room.roomId, info, text, this.context)
|
ContentMessages.sharedInstance()
|
||||||
|
.sendStickerContentToRoom(url, this.state.room.roomId, threadId, info, text, this.context)
|
||||||
.then(undefined, (error) => {
|
.then(undefined, (error) => {
|
||||||
if (error.name === "UnknownDeviceError") {
|
if (error.name === "UnknownDeviceError") {
|
||||||
// Let the staus bar handle this
|
// Let the staus bar handle this
|
||||||
|
|
|
@ -47,6 +47,7 @@ interface IProps {
|
||||||
// If room is not specified then it is an account level widget
|
// If room is not specified then it is an account level widget
|
||||||
// which bypasses permission prompts as it was added explicitly by that user
|
// which bypasses permission prompts as it was added explicitly by that user
|
||||||
room: Room;
|
room: Room;
|
||||||
|
threadId?: string | null;
|
||||||
// Specifying 'fullWidth' as true will render the app tile to fill the width of the app drawer continer.
|
// Specifying 'fullWidth' as true will render the app tile to fill the width of the app drawer continer.
|
||||||
// This should be set to true when there is only one widget in the app drawer, otherwise it should be false.
|
// This should be set to true when there is only one widget in the app drawer, otherwise it should be false.
|
||||||
fullWidth?: boolean;
|
fullWidth?: boolean;
|
||||||
|
@ -100,6 +101,7 @@ export default class AppTile extends React.Component<IProps, IState> {
|
||||||
handleMinimisePointerEvents: false,
|
handleMinimisePointerEvents: false,
|
||||||
userWidget: false,
|
userWidget: false,
|
||||||
miniMode: false,
|
miniMode: false,
|
||||||
|
threadId: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
private contextMenuButton = createRef<any>();
|
private contextMenuButton = createRef<any>();
|
||||||
|
@ -322,7 +324,13 @@ export default class AppTile extends React.Component<IProps, IState> {
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case 'm.sticker':
|
case 'm.sticker':
|
||||||
if (this.sgWidget.widgetApi.hasCapability(MatrixCapabilities.StickerSending)) {
|
if (this.sgWidget.widgetApi.hasCapability(MatrixCapabilities.StickerSending)) {
|
||||||
dis.dispatch({ action: 'post_sticker_message', data: payload.data });
|
dis.dispatch({
|
||||||
|
action: 'post_sticker_message',
|
||||||
|
data: {
|
||||||
|
...payload.data,
|
||||||
|
threadId: this.props.threadId,
|
||||||
|
},
|
||||||
|
});
|
||||||
dis.dispatch({ action: 'stickerpicker_close' });
|
dis.dispatch({ action: 'stickerpicker_close' });
|
||||||
} else {
|
} else {
|
||||||
logger.warn('Ignoring sticker message. Invalid capability');
|
logger.warn('Ignoring sticker message. Invalid capability');
|
||||||
|
|
|
@ -656,9 +656,15 @@ export default class MessageComposer extends React.Component<IProps, IState> {
|
||||||
yOffset={-50}
|
yOffset={-50}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const threadId = this.props.relation?.rel_type === RelationType.Thread
|
||||||
|
? this.props.relation.event_id
|
||||||
|
: null;
|
||||||
|
|
||||||
controls.push(
|
controls.push(
|
||||||
<Stickerpicker
|
<Stickerpicker
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
|
threadId={threadId}
|
||||||
showStickers={this.state.showStickers}
|
showStickers={this.state.showStickers}
|
||||||
setShowStickers={this.showStickers}
|
setShowStickers={this.showStickers}
|
||||||
menuPosition={menuPosition}
|
menuPosition={menuPosition}
|
||||||
|
|
|
@ -46,6 +46,7 @@ const PERSISTED_ELEMENT_KEY = "stickerPicker";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
|
threadId?: string | null;
|
||||||
showStickers: boolean;
|
showStickers: boolean;
|
||||||
menuPosition?: any;
|
menuPosition?: any;
|
||||||
setShowStickers: (showStickers: boolean) => void;
|
setShowStickers: (showStickers: boolean) => void;
|
||||||
|
@ -62,6 +63,10 @@ interface IState {
|
||||||
|
|
||||||
@replaceableComponent("views.rooms.Stickerpicker")
|
@replaceableComponent("views.rooms.Stickerpicker")
|
||||||
export default class Stickerpicker extends React.PureComponent<IProps, IState> {
|
export default class Stickerpicker extends React.PureComponent<IProps, IState> {
|
||||||
|
static defaultProps = {
|
||||||
|
threadId: null,
|
||||||
|
};
|
||||||
|
|
||||||
static currentWidget;
|
static currentWidget;
|
||||||
|
|
||||||
private dispatcherRef: string;
|
private dispatcherRef: string;
|
||||||
|
@ -287,6 +292,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
|
||||||
<AppTile
|
<AppTile
|
||||||
app={stickerApp}
|
app={stickerApp}
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
|
threadId={this.props.threadId}
|
||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
userId={MatrixClientPeg.get().credentials.userId}
|
userId={MatrixClientPeg.get().credentials.userId}
|
||||||
creatorUserId={stickerpickerWidget.sender || MatrixClientPeg.get().credentials.userId}
|
creatorUserId={stickerpickerWidget.sender || MatrixClientPeg.get().credentials.userId}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue