Getting data for the widget

(Evgeny) #1

I don’t want to use this approach in widgets:

  url: "/u/"+ username +".json", 
  dataType: 'json',
  async: false,
  success: function(data) {;

Is there any other way to get this variable: time_read? This is an example.

from the template



{{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.


(James Kiesel) #2

Do you only need it for the current user?

(Evgeny) #3

Yes. Only for this user.

(James Kiesel) #4

You might try something like this:

DiscoursePluginRegistry.serialized_current_user_fields << 'recent_time_read'

to add it to the serialized current user.


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.

(Evgeny) #5

What is the best way to do that is with minimal load.?

This method is not quite suitable.