Skip to main content
Mention `parent_id` and `show_parent`
Source Link
Makyen
  • 1.7k
  • 1
  • 12
  • 20

Prior to most of the chat system processing of the event, the registered callbacks are executed in the order they were added. If any callback alters the event object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.

The first argument is a chat "event" Object. This answer on MSE has a list and description of the possible key/value pairs, at least for event_type == 1. The most common key/value pairs which may be included for messages which are not shown above are show_parent and parent_id. The show_parent key is only present if the message is an actual reply to the message ID indicated in parent_id. parent_id will be present for actual replies and @ pings. For @ pings, parent_id will be the most recent message by the pinged user and show_parent won't be present.

The type of event is indicated by the numeric value of event_type. There are 34 types which are possible for event_type.

Prior most of the chat system processing of the event, the registered callbacks are executed in the order they were added. If any callback alters the event object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.

The first argument is a chat "event" Object. The type of event is indicated by the numeric value of event_type. There are 34 types which are possible for event_type.

Prior to most of the chat system processing of the event, the registered callbacks are executed in the order they were added. If any callback alters the event object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.

The first argument is a chat "event" Object. This answer on MSE has a list and description of the possible key/value pairs, at least for event_type == 1. The most common key/value pairs which may be included for messages which are not shown above are show_parent and parent_id. The show_parent key is only present if the message is an actual reply to the message ID indicated in parent_id. parent_id will be present for actual replies and @ pings. For @ pings, parent_id will be the most recent message by the pinged user and show_parent won't be present.

The type of event is indicated by the numeric value of event_type. There are 34 types which are possible for event_type.

Mention that some processing is done prior to other callbacks
Source Link
Makyen
  • 1.7k
  • 1
  • 12
  • 20

Prior Prior to the chat system processing the eventmost of the chat system processing of the event, the registered callbacks are executed in the order they were added. If any callback alters the event object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.

The chat system itself uses CHAT.addEventHandlerHook(callback) to add its own callback for partial processing of some event types. This means that the processing for the following event types will be split between prior to other callbacks and after other callbacks: MessageDeleted, MessageEdited, MessageFlagged, MessagePosted, MessageReply, UserEntered, UserLeft, UserMentioned, and UserNameOrAvatarChanged.

Prior to the chat system processing the event, the registered callbacks are executed in the order they were added. If any callback alters the event object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.

Prior most of the chat system processing of the event, the registered callbacks are executed in the order they were added. If any callback alters the event object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.

The chat system itself uses CHAT.addEventHandlerHook(callback) to add its own callback for partial processing of some event types. This means that the processing for the following event types will be split between prior to other callbacks and after other callbacks: MessageDeleted, MessageEdited, MessageFlagged, MessagePosted, MessageReply, UserEntered, UserLeft, UserMentioned, and UserNameOrAvatarChanged.

IMO, there's no need to explicitly mention async functions. That async functions return a Promise, which is inherently truthy, is just standard JavaScript. The key information is that returning truthy stops processing.
Source Link
Makyen
  • 1.7k
  • 1
  • 12
  • 20

You can register a callback with Stack Exchange Chat, which gets called prior to the change happening in the DOM (i.e. if you want to find a new message in the DOM, you need to use a setTimeout() to act after the DOM change). Callbacks can be registered with CHAT.addEventHandlerHook(callback), which takes a function as its single argument. Note that

Prior to the chat system processing the event, the function must not return a truthy value (or beregistered callbacks are executed in the order they were added. If any callback alters the asyncevent); if it does object in argument 0, whilethen that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback will execute on every eventreturns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated and new messages will not show up). Effectively, returning a truthy value from a callback cancels the event.

You can register a callback with Stack Exchange Chat, which gets called prior to the change happening in the DOM (i.e. if you want to find a new message in the DOM, you need to use a setTimeout() to act after the DOM change). Callbacks can be registered with CHAT.addEventHandlerHook(callback), which takes a function as its single argument. Note that the function must not return a truthy value (or be async); if it does, while the callback will execute on every event, the DOM will not be updated and new messages will not show up.

You can register a callback with Stack Exchange Chat, which gets called prior to the change happening in the DOM (i.e. if you want to find a new message in the DOM, you need to use a setTimeout() to act after the DOM change). Callbacks can be registered with CHAT.addEventHandlerHook(callback), which takes a function as its single argument.

Prior to the chat system processing the event, the registered callbacks are executed in the order they were added. If any callback alters the event object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.

Actually, the issue is a bit broader than what my previous edit suggests
Source Link
Loading
Point out that the callback function MUST NOT be `async`; see link in edit for details
Source Link
Loading
minor grammar
Source Link
Makyen
  • 1.7k
  • 1
  • 12
  • 20
Loading
Source Link
Makyen
  • 1.7k
  • 1
  • 12
  • 20
Loading