mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Various improvements to welcome topic CTA (#21010)
- Update welcome topic copy - Edit the welcome topic automatically when the title or description changes - Remove “Create your Welcome Topic” banner/CTA - Add "edit welcome topic" user tip
This commit is contained in:
@@ -216,40 +216,4 @@ class Site
|
||||
# the cache is validated based on the sequence
|
||||
MessageBus.publish(SITE_JSON_CHANNEL, "")
|
||||
end
|
||||
|
||||
def self.welcome_topic_banner_cache_key(user_id)
|
||||
"show_welcome_topic_banner:#{user_id}"
|
||||
end
|
||||
|
||||
def self.welcome_topic_exists_and_is_not_edited?
|
||||
Post
|
||||
.joins(:topic)
|
||||
.where(
|
||||
"topics.id = :topic_id AND topics.deleted_at IS NULL AND posts.post_number = 1 AND posts.version = 1 AND posts.created_at > :created_at",
|
||||
topic_id: SiteSetting.welcome_topic_id,
|
||||
created_at: 1.month.ago,
|
||||
)
|
||||
.exists?
|
||||
end
|
||||
|
||||
def self.clear_show_welcome_topic_cache
|
||||
Discourse
|
||||
.cache
|
||||
.keys("show_welcome_topic_banner:*")
|
||||
.each { |key| Discourse.cache.redis.del(key) }
|
||||
end
|
||||
|
||||
def self.show_welcome_topic_banner?(guardian)
|
||||
return false if !guardian.is_admin?
|
||||
return false if guardian.user.id != User.first_login_admin_id
|
||||
user_id = guardian.user.id
|
||||
|
||||
show_welcome_topic_banner = Discourse.cache.read(welcome_topic_banner_cache_key(user_id))
|
||||
return show_welcome_topic_banner unless show_welcome_topic_banner.nil?
|
||||
|
||||
show_welcome_topic_banner = welcome_topic_exists_and_is_not_edited?
|
||||
|
||||
Discourse.cache.write(welcome_topic_banner_cache_key(user_id), show_welcome_topic_banner)
|
||||
show_welcome_topic_banner
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user