Stranik
(Evgeny)
25 أغسطس 2018، 4:26م
1
I don’t want to use this approach in widgets:
$.ajax({
url: "/u/"+ username +".json",
dataType: 'json',
async: false,
success: function(data) {
....data.user.time_read;
Is there any other way to get this variable: time_read
? This is an example.
from the template
discourse/app/assets/javascripts/discourse/templates/discovery.hbs
through
{{plugin-outlet name="discovery-list-container-top"
args=(hash category=category listLoading=loading)}}
no data is transmitted.
Is there any other way (other than json) to get this data (time_read, badge_count etc.)
Extras. currentUser
does not have this data.
Thank
gdpelican
(James Kiesel)
25 أغسطس 2018، 4:55م
2
Do you only need it for the current user?
gdpelican
(James Kiesel)
25 أغسطس 2018، 5:02م
4
You might try something like this:
DiscoursePluginRegistry.serialized_current_user_fields << 'recent_time_read'
to add it to the serialized current user.
User.current().recent_time_read
Keep in mind that this will only be serialized once, on app load, and that to get an updated value you’ll either need to query for it directly, or use MessageBus to ‘live update’ the user’s read_time.
إعجاب واحد (1)
Stranik
(Evgeny)
25 أغسطس 2018، 6:06م
5
gdpelican:
to query for it directly
What is the best way to do that is with minimal load.?
This method is not quite suitable.