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:
Penar Musaraj
2021-03-19 09:19:15 -04:00
committed by GitHub
parent 6eab1e83c3
commit d470e4fade
23 changed files with 155 additions and 148 deletions

View File

@ -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)