Display who is currently online
marc-farre opened this issue · comments
I need to add the possibility to display who is online, in the conversation and on the left panel of all conversations.
It also could be when adding a new user to a conversation:
@luke- do you prefer a PR, or should I create new module (e.g. messenger-advanced
) for that?
Thanks!
@funkycram We need to check what is possible here with the user_session
table. Possibly also mark logged in & inactive users differently (orange).
Additionally, users/operators should have the possibility to hide the online status.
@Eladnarlea Can you take a look here regarding the UI?
@funkycram @luke- what do you think?
I would suggest the following:
- display a
green dot
next to the person that is online - don't display it in group chat preview (to see who's online you have got to click on participants list view->
green dot
and(online)
signalise the online status) - for now we should integrate only the
green dot
and the(online)
text instead of introducing several colors that display the different status options.
Thanks @luke- and @Eladnarlea . I agree with your suggestions @Eladnarlea , thanks for the screenshots, it will help me!
So I think I need to a property in humhub\modules\user\widgets\Image
, perhaps public $showOnlineStatus = false
. Have you got a better idea @luke- ?
We need to check what is possible here with the user_session table.
The session doesn't seem to be written in the DB.
If I'm logged in with user ID 1 and I do:
$user = \humhub\modules\user\models\User::findOne(1);
echo $user->getHttpSessions()->count();
I have 0.
I also tried var_dump($session->readSession(1));
but it returns an empty string.
And in my DB, I only have one line with a value nether changing:
On other Humhub instances, I can see many lines, so perhaps it's different depending some settings.
Anyway, I we have a JS calling humhub\modules\live\controllers\PollController
every 20 seconds, only if the page is open in the browser.
Perhaps we could use this controller to update a cache? Something like:
Yii::$app->cache->set(self::CACHE_ONLINE_PREFIX . Yii::$app->user->id, true, 60); // Expires in 60 seconds
And then, we can know if a user is online with Yii::$app->cache->get(self::CACHE_ONLINE_PREFIX . $userId)
.
What do you think about this idea?
@funkycram Sounds good!
- I like the feature
humhub\modules\user\widgets\Image::$showOnlineStatus
. - Would be great to have the "is online" handling logic in an extra service class e.g.
humhub\modules\user\services\IsOnlineService
. - Lets start with the Cache idea. Should be no big deal to change this logic afterwards, if everything is bundled in the service.
@luke- Summary of this new feature:
- Required issue for core: humhub/humhub#6295
- Required PR for core: humhub/humhub#6297
- PR for mail module: #328
@marc-farre Just merged. Can you please check it? There were some conflicts during merge.
@marc-farre Thank you. I'll release the module vor the v15 users.