Order the Who List by Logged-in Time
This commit is contained in:
parent
6d26c2f141
commit
a6866bd129
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.kirsle.net/apps/barertc/pkg/config"
|
"git.kirsle.net/apps/barertc/pkg/config"
|
||||||
"git.kirsle.net/apps/barertc/pkg/jwt"
|
"git.kirsle.net/apps/barertc/pkg/jwt"
|
||||||
|
@ -87,6 +88,7 @@ func (s *Server) OnLogin(sub *Subscriber, msg Message) {
|
||||||
// Use their username.
|
// Use their username.
|
||||||
sub.Username = msg.Username
|
sub.Username = msg.Username
|
||||||
sub.authenticated = true
|
sub.authenticated = true
|
||||||
|
sub.loginAt = time.Now()
|
||||||
log.Debug("OnLogin: %s joins the room", sub.Username)
|
log.Debug("OnLogin: %s joins the room", sub.Username)
|
||||||
|
|
||||||
// Tell everyone they joined.
|
// Tell everyone they joined.
|
||||||
|
|
|
@ -81,6 +81,7 @@ type WhoList struct {
|
||||||
Nickname string `json:"nickname,omitempty"`
|
Nickname string `json:"nickname,omitempty"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Video int `json:"video"`
|
Video int `json:"video"`
|
||||||
|
LoginAt int64 `json:"loginAt"`
|
||||||
|
|
||||||
// JWT auth extra settings.
|
// JWT auth extra settings.
|
||||||
Operator bool `json:"op"`
|
Operator bool `json:"op"`
|
||||||
|
|
|
@ -27,6 +27,7 @@ type Subscriber struct {
|
||||||
VideoStatus int
|
VideoStatus int
|
||||||
JWTClaims *jwt.Claims
|
JWTClaims *jwt.Claims
|
||||||
authenticated bool // has passed the login step
|
authenticated bool // has passed the login step
|
||||||
|
loginAt time.Time
|
||||||
conn *websocket.Conn
|
conn *websocket.Conn
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
|
@ -395,6 +396,7 @@ func (s *Server) SendWhoList() {
|
||||||
Username: user.Username,
|
Username: user.Username,
|
||||||
Status: user.ChatStatus,
|
Status: user.ChatStatus,
|
||||||
Video: user.VideoStatus,
|
Video: user.VideoStatus,
|
||||||
|
LoginAt: user.loginAt.Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this person had booted us, force their camera to "off"
|
// If this person had booted us, force their camera to "off"
|
||||||
|
|
|
@ -438,6 +438,11 @@ const app = Vue.createApp({
|
||||||
return a.emoji < b.emoji ? -1 : 1;
|
return a.emoji < b.emoji ? -1 : 1;
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
|
case "login":
|
||||||
|
result.sort((a, b) => {
|
||||||
|
return b.loginAt - a.loginAt;
|
||||||
|
});
|
||||||
|
break;
|
||||||
case "gender":
|
case "gender":
|
||||||
result.sort((a, b) => {
|
result.sort((a, b) => {
|
||||||
if (a.gender === b.gender) return 0;
|
if (a.gender === b.gender) return 0;
|
||||||
|
|
|
@ -987,12 +987,13 @@
|
||||||
<select v-model="whoSort">
|
<select v-model="whoSort">
|
||||||
<option value="a-z">Username (a-z)</option>
|
<option value="a-z">Username (a-z)</option>
|
||||||
<option value="z-a">Username (z-a)</option>
|
<option value="z-a">Username (z-a)</option>
|
||||||
|
<option value="login">Login Time</option>
|
||||||
<option value="broadcasting">Broadcasting</option>
|
<option value="broadcasting">Broadcasting</option>
|
||||||
<option value="nsfw" v-show="config.permitNSFW">Red cameras</option>
|
<option value="nsfw" v-show="config.permitNSFW">Red cameras</option>
|
||||||
<option value="status">Status</option>
|
<option value="status">Status</option>
|
||||||
<option value="emoji">Emoji/country flag</option>
|
<option value="emoji">Emoji/country flag</option>
|
||||||
<option value="gender">Gender</option>
|
<option value="gender">Gender</option>
|
||||||
<option value="op">User level</option>
|
<option value="op">User level (operators)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user