Chat effects fixes for threads (#7183)
							parent
							
								
									a8a34ea756
								
							
						
					
					
						commit
						87201c8bfb
					
				|  | @ -139,9 +139,17 @@ export class Command { | |||
|         return this.getCommand() + " " + this.args; | ||||
|     } | ||||
| 
 | ||||
|     run(roomId: string, args: string) { | ||||
|     run(roomId: string, threadId: string, args: string) { | ||||
|         // if it has no runFn then its an ignored/nop command (autocomplete only) e.g `/me`
 | ||||
|         if (!this.runFn) return reject(_t("Command error")); | ||||
| 
 | ||||
|         const renderingType = threadId | ||||
|             ? TimelineRenderingType.Thread | ||||
|             : TimelineRenderingType.Room; | ||||
|         if (this.renderingTypes && !this.renderingTypes?.includes(renderingType)) { | ||||
|             return reject(_t("Command error")); | ||||
|         } | ||||
| 
 | ||||
|         return this.runFn.bind(this)(roomId, args); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -321,7 +321,9 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt | |||
|     } | ||||
| 
 | ||||
|     private async runSlashCommand(cmd: Command, args: string, roomId: string): Promise<void> { | ||||
|         const result = cmd.run(roomId, args); | ||||
|         const threadId = this.props.editState?.getEvent()?.getThread()?.id || null; | ||||
| 
 | ||||
|         const result = cmd.run(roomId, threadId, args); | ||||
|         let messageContent; | ||||
|         let error = result.error; | ||||
|         if (result.promise) { | ||||
|  |  | |||
|  | @ -350,7 +350,11 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro | |||
|     } | ||||
| 
 | ||||
|     private async runSlashCommand(cmd: Command, args: string): Promise<void> { | ||||
|         const result = cmd.run(this.props.room.roomId, args); | ||||
|         const threadId = this.props.relation?.rel_type === RelationType.Thread | ||||
|             ? this.props.relation?.event_id | ||||
|             : null; | ||||
| 
 | ||||
|         const result = cmd.run(this.props.room.roomId, threadId, args); | ||||
|         let messageContent; | ||||
|         let error = result.error; | ||||
|         if (result.promise) { | ||||
|  | @ -495,7 +499,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro | |||
|                     // For initial threads launch, chat effects are disabled
 | ||||
|                     // see #19731
 | ||||
|                     const isNotThread = this.props.relation?.rel_type !== RelationType.Thread; | ||||
|                     if (!SettingsStore.getValue("feature_thread") || !isNotThread) { | ||||
|                     if (!SettingsStore.getValue("feature_thread") || isNotThread) { | ||||
|                         dis.dispatch({ action: `effects.${effect.command}` }); | ||||
|                     } | ||||
|                 } | ||||
|  |  | |||
|  | @ -168,7 +168,7 @@ export class StopGapWidgetDriver extends WidgetDriver { | |||
|                         // For initial threads launch, chat effects are disabled
 | ||||
|                         // see #19731
 | ||||
|                         const isNotThread = content["m.relates_to"].rel_type !== RelationType.Thread; | ||||
|                         if (!SettingsStore.getValue("feature_thread") || !isNotThread) { | ||||
|                         if (!SettingsStore.getValue("feature_thread") || isNotThread) { | ||||
|                             dis.dispatch({ action: `effects.${effect.command}` }); | ||||
|                         } | ||||
|                     } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Germain
						Germain