mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 13:04:32 +08:00
FEATURE: Allow users to save draft and close composer (#12439)
We previously included this option conditionally when users were replying or creating a new topic while they had content already in the composer. This makes the dialog always include three buttons: - Close and discard - Close and save draft for later - Keed editing This also changes how the backend notifies the frontend when there is a current draft topic. This is now sent via the `has_topic_draft` property in the current user serializer.
This commit is contained in:
@ -132,6 +132,12 @@ class Draft < ActiveRecord::Base
|
||||
data if current_sequence == draft_sequence
|
||||
end
|
||||
|
||||
def self.has_topic_draft(user)
|
||||
return if !user || !user.id || !User.human_user_id?(user.id)
|
||||
|
||||
Draft.where(user_id: user.id, draft_key: NEW_TOPIC).present?
|
||||
end
|
||||
|
||||
def self.clear(user, key, sequence)
|
||||
return if !user || !user.id || !User.human_user_id?(user.id)
|
||||
|
||||
|
Reference in New Issue
Block a user