Minor bugfixes
- Revoke photo notifications if visibility moving to inner circle - No longer show usernames in chat on the landing page
This commit is contained in:
parent
fdc6c5c0a7
commit
a70e1c2b73
|
@ -59,8 +59,9 @@ func Edit() http.HandlerFunc {
|
||||||
setProfilePic = r.FormValue("intent") == "profile-pic"
|
setProfilePic = r.FormValue("intent") == "profile-pic"
|
||||||
crop = pphoto.ParseCropCoords(r.FormValue("crop"))
|
crop = pphoto.ParseCropCoords(r.FormValue("crop"))
|
||||||
|
|
||||||
// Are we GOING private?
|
// Are we GOING private or changing to Inner Circle?
|
||||||
goingPrivate = visibility == models.PhotoPrivate && visibility != photo.Visibility
|
goingPrivate = visibility == models.PhotoPrivate && visibility != photo.Visibility
|
||||||
|
goingCircle = visibility == models.PhotoInnerCircle && visibility != photo.Visibility
|
||||||
)
|
)
|
||||||
|
|
||||||
photo.Caption = caption
|
photo.Caption = caption
|
||||||
|
@ -113,8 +114,8 @@ func Edit() http.HandlerFunc {
|
||||||
session.Flash(w, r, "Photo settings updated!")
|
session.Flash(w, r, "Photo settings updated!")
|
||||||
|
|
||||||
// If this picture has moved to Private, revoke any notification we gave about it before.
|
// If this picture has moved to Private, revoke any notification we gave about it before.
|
||||||
if goingPrivate {
|
if goingPrivate || goingCircle {
|
||||||
log.Info("The picture is GOING PRIVATE, revoke any notifications about it")
|
log.Info("The picture is GOING PRIVATE (to %s), revoke any notifications about it", photo.Visibility)
|
||||||
models.RemoveNotification("photos", photo.ID)
|
models.RemoveNotification("photos", photo.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
// ChatStatistics is the json result of the BareRTC /api/statistics endpoint.
|
// ChatStatistics is the json result of the BareRTC /api/statistics endpoint.
|
||||||
type ChatStatistics struct {
|
type ChatStatistics struct {
|
||||||
UserCount int
|
UserCount int
|
||||||
Usernames []string
|
Usernames []string `json:",omitempty"`
|
||||||
Cameras struct {
|
Cameras struct {
|
||||||
Blue int
|
Blue int
|
||||||
Red int
|
Red int
|
||||||
|
@ -41,6 +41,14 @@ func SetChatStatistics(stats *ChatStatistics) {
|
||||||
cachedChatStatistics = stats
|
cachedChatStatistics = stats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Privatized returns a copy of ChatStatistics with the usernames list scrubbed.
|
||||||
|
func (cs ChatStatistics) Privatized() ChatStatistics {
|
||||||
|
return ChatStatistics{
|
||||||
|
UserCount: cs.UserCount,
|
||||||
|
Cameras: cs.Cameras,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// IsOnline returns whether the username is currently logged-in to chat.
|
// IsOnline returns whether the username is currently logged-in to chat.
|
||||||
func (cs ChatStatistics) IsOnline(username string) bool {
|
func (cs ChatStatistics) IsOnline(username string) bool {
|
||||||
for _, user := range cs.Usernames {
|
for _, user := range cs.Usernames {
|
||||||
|
|
|
@ -44,8 +44,6 @@
|
||||||
|
|
||||||
<div class="notification is-success is-light" id="chatStatsBanner" style="display: none">
|
<div class="notification is-success is-light" id="chatStatsBanner" style="display: none">
|
||||||
<span id="usersOnline"></span>
|
<span id="usersOnline"></span>
|
||||||
<a id="whoLink" href="#" style="visibility: hidden">Who?</a>
|
|
||||||
<span id="whoList" style="display: none"></span>
|
|
||||||
|
|
||||||
<!-- Camera stats if active -->
|
<!-- Camera stats if active -->
|
||||||
<div id="cameraStats" style="display: none" class="mt-2">
|
<div id="cameraStats" style="display: none" class="mt-2">
|
||||||
|
@ -159,8 +157,6 @@
|
||||||
<script>
|
<script>
|
||||||
function showWhoBanner(chatStatistics) {
|
function showWhoBanner(chatStatistics) {
|
||||||
const $banner = document.querySelector("#chatStatsBanner"),
|
const $banner = document.querySelector("#chatStatsBanner"),
|
||||||
$whoLink = document.querySelector("#whoLink"),
|
|
||||||
$whoList = document.querySelector("#whoList"),
|
|
||||||
$usersOnline = document.querySelector("#usersOnline")
|
$usersOnline = document.querySelector("#usersOnline")
|
||||||
$cameraStats = document.querySelector("#cameraStats")
|
$cameraStats = document.querySelector("#cameraStats")
|
||||||
$cameraCount = document.querySelector("#cameraCount")
|
$cameraCount = document.querySelector("#cameraCount")
|
||||||
|
@ -171,16 +167,7 @@ function showWhoBanner(chatStatistics) {
|
||||||
|
|
||||||
let people = chatStatistics.UserCount === 1 ? 'person' : 'people';
|
let people = chatStatistics.UserCount === 1 ? 'person' : 'people';
|
||||||
let isAre = chatStatistics.UserCount === 1 ? 'is' : 'are';
|
let isAre = chatStatistics.UserCount === 1 ? 'is' : 'are';
|
||||||
$usersOnline.innerHTML = `There ${isAre} currently <strong>${chatStatistics.UserCount}</strong> ${people}</span> in the chat room`;
|
$usersOnline.innerHTML = `There ${isAre} currently <strong>${chatStatistics.UserCount}</strong> ${people}</span> in the chat room.`;
|
||||||
$whoList.innerHTML = chatStatistics.Usernames.join(", ");
|
|
||||||
|
|
||||||
// Show the "Who?" link if there's anybody.
|
|
||||||
if (chatStatistics.UserCount > 0) {
|
|
||||||
$usersOnline.innerHTML += ":";
|
|
||||||
$whoLink.style.visibility = "visible";
|
|
||||||
} else {
|
|
||||||
$usersOnline.innerHTML += ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Camera stats too?
|
// Camera stats too?
|
||||||
if (chatStatistics.Cameras.Blue + chatStatistics.Cameras.Red > 0) {
|
if (chatStatistics.Cameras.Blue + chatStatistics.Cameras.Red > 0) {
|
||||||
|
@ -192,30 +179,14 @@ function showWhoBanner(chatStatistics) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
let url = "{{.ChatAPI}}",
|
let ChatStatistics = {{.ChatStatistics.Privatized}},
|
||||||
ChatStatistics = {{.ChatStatistics}},
|
|
||||||
$banner = document.querySelector("#chatStatsBanner"),
|
$banner = document.querySelector("#chatStatsBanner"),
|
||||||
$whoLink = document.querySelector("#whoLink"),
|
|
||||||
$whoList = document.querySelector("#whoList"),
|
|
||||||
$usersOnline = document.querySelector("#usersOnline");
|
$usersOnline = document.querySelector("#usersOnline");
|
||||||
|
|
||||||
// If we already know people are online, show the banner immediately while we refresh from live data
|
// If we already know people are online, show the banner immediately while we refresh from live data
|
||||||
if (ChatStatistics.UserCount > 0) {
|
if (ChatStatistics.UserCount > 0) {
|
||||||
showWhoBanner(ChatStatistics);
|
showWhoBanner(ChatStatistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
$whoLink.addEventListener("click", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
$whoLink.style.display = "none";
|
|
||||||
$whoList.style.display = "";
|
|
||||||
});
|
|
||||||
|
|
||||||
fetch(url, {
|
|
||||||
mode: 'cors',
|
|
||||||
cache: 'no-cache',
|
|
||||||
}).then(resp => resp.json()).then(result => {
|
|
||||||
showWhoBanner(result);
|
|
||||||
}).catch(console.error);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user