mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 09:17:30 +08:00
37e6e3be7f
Whenever we create a chat message that is `in_reply_to` another message, we want to lazily populate the thread record for the message chain. If there is no thread yet for the root message in the reply chain, we create a new thread with the appropriate details, and use that thread ID for every message in the chain that does not yet have a thread ID. * Root message (ID 1) - no thread ID * Message (ID 2, in_reply_to 1) - no thread ID * When I as a user create a message in reply to ID 2, we create a thread and apply it to ID 1, ID 2, and the new message If there is a thread for the root message in the reply chain, we do not create one, and use the thread ID for the newly created chat message. * Root message (ID 1) - thread ID 700 * Message (ID 2, in_reply_to 1) - thread ID 700 * When I as a user create a message in reply to ID 2, we use the existing thread ID 700 for the new message We also support passing in the `thread_id` to `ChatMessageCreator`, which will be used when replying to a message that is already part of a thread, and we validate whether that `thread_id` is okay in the context of the channel and also the reply chain. This work is always done, regardless of channel `thread_enabled` settings or the `enable_experimental_chat_threaded_discussions` site setting. This commit does not include a large data migration to backfill threads for all existing reply chains, its unnecessary to do this so early in the project, we can do this later if necessary. This commit also includes thread considerations in the `MessageMover` class: * If the original message and N other messages of a thread is moved, the remaining messages in the thread have a new thread created in the old channel and are moved to it. * The reply chain is not preserved for moved messages, so new threads are not created in the destination channel. In addition to this, I added a fix to also clear the `in_reply_to_id` of messages in the old channel which are moved out of that channel for data cleanliness. |
||
---|---|---|
.. | ||
app | ||
assets | ||
config | ||
db | ||
docs | ||
lib | ||
public | ||
spec | ||
test/javascripts | ||
plugin.rb | ||
README.md |
⚠️ This plugin is still in active development and may change frequently
Documentation
The Discourse Chat plugin adds chat functionality to your Discourse so it can natively support both long-form and short-form communication needs of your online community.
For documentation, see Discourse Chat
Plugin API
registerChatComposerButton
Usage
api.registerChatComposerButton({ id: "foo", ... });
Options
Every option accepts a value
or a function
, when passing a function this
will be the chat-composer
component instance. Example of an option using a function:
api.registerChatComposerButton({
id: "foo",
displayed() {
return this.site.mobileView && this.canAttachUploads;
},
});
Required
id
unique, used to identify your button, eg: "gifs"action
callback when the button is pressed, can be an action name or an anonymous function, eg: "onFooClicked" or() => { console.log("clicked") }
A button requires at least an icon or a label:
icon
, eg: "times"label
, text displayed on the button, a translatable key, eg: "foo.bar"translatedLabel
, text displayed on the button, a string, eg: "Add gifs"
Optional
position
, can be "inline" or "dropdown", defaults to "inline"title
, title attribute of the button, a translatable key, eg: "foo.bar"translatedTitle
, title attribute of the button, a string, eg: "Add gifs"ariaLabel
, aria-label attribute of the button, a translatable key, eg: "foo.bar"translatedAriaLabel
, aria-label attribute of the button, a string, eg: "Add gifs"classNames
, additional names to add to the button’s class attribute, eg: ["foo", "bar"]displayed
, hide/or show the button, expects a booleandisabled
, sets the disabled attribute on the button, expects a booleanpriority
, an integer defining the order of the buttons, higher comes first, eg:700
dependentKeys
, list of property names which should trigger a refresh of the buttons when changed, eg:["foo.bar", "bar.baz"]