mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 22:02:42 +08:00
BUGFIX: when RTT is short likes may not appear to work
BUGFIX: site settings db provider not triggering updates at the correct point
This commit is contained in:
@ -20,7 +20,7 @@ class PostAction < ActiveRecord::Base
|
|||||||
|
|
||||||
after_save :update_counters
|
after_save :update_counters
|
||||||
after_save :enforce_rules
|
after_save :enforce_rules
|
||||||
after_save :notify_subscribers
|
after_commit :notify_subscribers
|
||||||
|
|
||||||
def self.update_flagged_posts_count
|
def self.update_flagged_posts_count
|
||||||
posts_flagged_count = PostAction.joins(post: :topic)
|
posts_flagged_count = PostAction.joins(post: :topic)
|
||||||
@ -154,7 +154,10 @@ class PostAction < ActiveRecord::Base
|
|||||||
|
|
||||||
def remove_act!(user)
|
def remove_act!(user)
|
||||||
trash!(user)
|
trash!(user)
|
||||||
run_callbacks(:save)
|
# NOTE: save is called to ensure all callbacks are called
|
||||||
|
# trash will not trigger callbacks, and triggering after_commit
|
||||||
|
# is not trivial
|
||||||
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_bookmark?
|
def is_bookmark?
|
||||||
|
@ -214,8 +214,10 @@ module SiteSettingExtension
|
|||||||
provider.save(name, val, type)
|
provider.save(name, val, type)
|
||||||
current[name] = convert(val, type)
|
current[name] = convert(val, type)
|
||||||
clear_cache!
|
clear_cache!
|
||||||
|
end
|
||||||
|
|
||||||
@last_message_sent = MessageBus.publish('/site_settings', {process: process_id})
|
def notify_changed!
|
||||||
|
MessageBus.publish('/site_settings', {process: process_id})
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_setting?(name)
|
def has_setting?(name)
|
||||||
|
@ -3,6 +3,10 @@ module SiteSettings; end
|
|||||||
class SiteSettings::DbProvider
|
class SiteSettings::DbProvider
|
||||||
|
|
||||||
def initialize(model)
|
def initialize(model)
|
||||||
|
model.after_commit do
|
||||||
|
model.notify_changed!
|
||||||
|
end
|
||||||
|
|
||||||
@model = model
|
@model = model
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -28,18 +32,18 @@ class SiteSettings::DbProvider
|
|||||||
|
|
||||||
return unless table_exists?
|
return unless table_exists?
|
||||||
|
|
||||||
count = @model.where({
|
model = @model.find_by({
|
||||||
name: name
|
name: name
|
||||||
}).update_all({
|
|
||||||
name: name,
|
|
||||||
value: value,
|
|
||||||
data_type: data_type,
|
|
||||||
updated_at: Time.now
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if count == 0
|
model ||= @model.new
|
||||||
@model.create!(name: name, value: value, data_type: data_type)
|
|
||||||
end
|
model.name = name
|
||||||
|
model.value = value
|
||||||
|
model.data_type = data_type
|
||||||
|
|
||||||
|
# save! used to ensure after_commit is called
|
||||||
|
model.save!
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user