mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +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:
@ -3,6 +3,10 @@ module SiteSettings; end
|
||||
class SiteSettings::DbProvider
|
||||
|
||||
def initialize(model)
|
||||
model.after_commit do
|
||||
model.notify_changed!
|
||||
end
|
||||
|
||||
@model = model
|
||||
end
|
||||
|
||||
@ -28,18 +32,18 @@ class SiteSettings::DbProvider
|
||||
|
||||
return unless table_exists?
|
||||
|
||||
count = @model.where({
|
||||
model = @model.find_by({
|
||||
name: name
|
||||
}).update_all({
|
||||
name: name,
|
||||
value: value,
|
||||
data_type: data_type,
|
||||
updated_at: Time.now
|
||||
})
|
||||
|
||||
if count == 0
|
||||
@model.create!(name: name, value: value, data_type: data_type)
|
||||
end
|
||||
model ||= @model.new
|
||||
|
||||
model.name = name
|
||||
model.value = value
|
||||
model.data_type = data_type
|
||||
|
||||
# save! used to ensure after_commit is called
|
||||
model.save!
|
||||
|
||||
true
|
||||
end
|
||||
|
Reference in New Issue
Block a user