Who's Online Plugin (discourse-whos-online)


(David Taylor) #184

This would be possible by overriding the template using a theme component.

You can change the duration that people are considered “online” for. The plugin doesn’t support multiple thresholds though, so that would be quite a lot of extra work.


(Sevos) #185

Would you like to give me an example of code?


(David Taylor) #186

This should work as a starting point (in the </head> section of a theme component):

<script type="text/x-handlebars" data-template-name="javascripts/components/whos-online-avatar">
{{user.username}}
</script>

(Sevos) #187

Awesome! That’s what I wanted to achieve. How can I make it display on the bottom of the page (under the categories)?


(David Taylor) #188

Just pick another ‘plugin outlet’, like discovery-below, and include the whos-online component there:

<script type="text/x-handlebars" data-template-name="javascripts/connectors/discovery-below/online_users_widget">
{{whos-online}}
</script>

Then you can hide the old one by replacing the template with an empty one:

<script type="text/x-handlebars" data-template-name="javascripts/connectors/discovery-list-container-top/online_users_widget">
</script>

#189

Seems something in latest version of discourse did break cause some errors for the plugin. I see some errors in the web browser console.

Dont know this stack is related to the plugin, but i think so:

_ember_jquery-07f49b58317ea9292d939348ec0091eb50a9d8aaabd9e86cc074ef5f049918aa.js:29446 TypeError: Cannot read property 'id' of undefined
    at r (_ember_jquery-07f49b58317ea9292d939348ec0091eb50a9d8aaabd9e86cc074ef5f049918aa.js:33677)
    at s.valueForContentItem (_application-52b80238d9b51e1973651364cd4f314c0d43d772c656752f457378e6d54fe608.js:7390)
    at s.computeContentItem (_application-52b80238d9b51e1973651364cd4f314c0d43d772c656752f457378e6d54fe608.js:4876)
    at _application-52b80238d9b51e1973651364cd4f314c0d43d772c656752f457378e6d54fe608.js:4838
    at Array.map (<anonymous>)
    at s._beforeDidComputeContent (_application-52b80238d9b51e1973651364cd4f314c0d43d772c656752f457378e6d54fe608.js:4837)
    at _application-52b80238d9b51e1973651364cd4f314c0d43d772c656752f457378e6d54fe608.js:5433
    at invokeWithOnError (_ember_jquery-07f49b58317ea9292d939348ec0091eb50a9d8aaabd9e86cc074ef5f049918aa.js:12554)
    at a.flush (_ember_jquery-07f49b58317ea9292d939348ec0091eb50a9d8aaabd9e86cc074ef5f049918aa.js:12613)
    at u.flush (_ember_jquery-07f49b58317ea9292d939348ec0091eb50a9d8aaabd9e86cc074ef5f049918aa.js:12737)
u @ _ember_jquery-07f49b58317ea9292d939348ec0091eb50a9d8aaabd9e86cc074ef5f049918aa.js:29446
_vendor-2a1bb89f3d07740a4bc406effec61ca52331df5c8cb4f7cfe38037f91321ee44.js:1425 

This is defintiv related to it:

MESSAGE BUS FAIL: callback /whos-online caused exception t.user.get is not a function

You can see this error on my discourse instance: https://rivven.community


TypeError: Cannot read property 'id' of undefined
(David Taylor) #190

I don’t think it was actually affecting the functionality, but I have now fixed it:

cc @nothing @dax


(Daniela) #191

No, the plugin works great even with that error. Thanks for the fix :blush:


(David Taylor) #192

Actually I just looked at it again - I think it was probably preventing the “green dot/glow/circle” updating live on user avatars. The list of users at the top was still working.

Nobody noticed - so I guess that proves live presence indicators aren’t really necessary :wink:


(Daniela) #193

Unless you are active on the site (replying to someone - one or more people - in real time) I think 99% of users only watch avatars on the top.


(PethuVignesh) #194

It’s really a cool plugin.:slightly_smiling_face:
Is it possible to add Guest users count along with the Registered users?


(B Iggy) #195

Hey @david

just wondering: would it be easy for you to add a fifth level and only allow Moderator to see who’s online? :slight_smile:
That would help me a lot.
image


(David Taylor) #196

It is not possible at the moment, but a contribution to add the feature would be welcome.

You can do this right now using CSS in a theme component. Something like

.online_users_widget {
  display:none;
}

body.staff .online_users_widget {
  display:block;
}

#197

Lately, I have a few errors in logs regarding this plugin. It doesn’t seem really important, but I wanted to share in case someone alse noticed this :thinking:

Message (15 copies reported)

Job exception: break from proc-closure

Backtrace

/var/www/discourse/plugins/discourse-whos-online/plugin.rb:91:in `block (2 levels) in activate!'
/var/www/discourse/lib/plugin/instance.rb:307:in `block in on'
/var/www/discourse/lib/discourse_event.rb:12:in `block in trigger'
/usr/local/lib/ruby/2.5.0/set.rb:338:in `each_key'
/usr/local/lib/ruby/2.5.0/set.rb:338:in `each'
/var/www/discourse/lib/discourse_event.rb:11:in `trigger'
/var/www/discourse/app/models/user.rb:684:in `update_last_seen!'
/var/www/discourse/lib/auth/default_current_user_provider.rb:120:in `block in current_user'
/var/www/discourse/lib/scheduler/defer.rb:94:in `block in do_work'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rails_multisite-2.0.6/lib/rails_multisite/connection_management.rb:63:in `with_connection'
/var/www/discourse/lib/scheduler/defer.rb:89:in `do_work'
/var/www/discourse/lib/scheduler/defer.rb:79:in `block (2 levels) in start_thread'

Env

hostname vps34xxxx-app
process_id 361
application_version 7e4edcfae8a3c0e664b836ee7c5f28b47853a2f8
current_db default
current_hostname iunctis.fr
message Running deferred code ‘Updating Last Seen’

(David Taylor) #198

I fixed that 8 minutes ago :wink: :

It wasn’t affecting functionality, just creating a lot of noise in the logs


#199

You minority reported this, you’re good

(I should’ve checked before tho)


(Jason) #200

will there be any update in the future to allow us to be able to change the green circle around the profile picture to a different color?


(Daniela) #201

You can change color with a simple line of CSS

This is good if whos online avatar indicator is set for ring

    html.whos-online-ring .topic-avatar.user-online img.avatar {
        box-shadow: 0 0 0 1px #fff,0 0 0 3px red;
    }

Obviously you need to change the color.


(Jason) #202

thank you.
now i must write something to reach 20 characters :joy:


(Bhanu Sharma) #203

Like button works just fine :slight_smile: