rename avatar to img to save a few bytes in alerts

This commit is contained in:
Azareal 2020-03-12 13:29:19 +10:00
parent 61688a0c6d
commit 17c8f7604a
2 changed files with 10 additions and 10 deletions

View File

@ -167,7 +167,7 @@ func buildAlertString(msg string, sub []string, path, avatar string, asid int) s
return sb.String()
}
const AlertsGrowHint2 = len(`{"msg":"","sub":[],"path":"","avatar":"","id":}`) + 5 + 3 + 1 + 1 + 1
const AlertsGrowHint2 = len(`{"msg":"","sub":[],"path":"","img":"","id":}`) + 5 + 3 + 1 + 1 + 1
// TODO: Use a string builder?
func buildAlertSb(sb *strings.Builder, msg string, sub []string, path, avatar string, asid int) {
@ -185,7 +185,7 @@ func buildAlertSb(sb *strings.Builder, msg string, sub []string, path, avatar st
}
sb.WriteString(`],"path":"`)
sb.WriteString(escapeTextInJson(path))
sb.WriteString(`","avatar":"`)
sb.WriteString(`","img":"`)
sb.WriteString(escapeTextInJson(avatar))
sb.WriteString(`","id":`)
sb.WriteString(strconv.Itoa(asid))
@ -289,7 +289,7 @@ func BuildAlertSb(sb *strings.Builder, a *Alert, user User /* The current user *
sb.WriteString(escapeTextInJson(area))
sb.WriteString(`"],"path":"`)
sb.WriteString(escapeTextInJson(url))
sb.WriteString(`","avatar":"`)
sb.WriteString(`","img":"`)
sb.WriteString(escapeTextInJson(a.Actor.Avatar))
sb.WriteString(`","id":`)
sb.WriteString(strconv.Itoa(a.ASID))
@ -298,7 +298,7 @@ func BuildAlertSb(sb *strings.Builder, a *Alert, user User /* The current user *
return nil
}
//var AlertsGrowHint3 = len(`{"msg":"._","sub":["",""],"path":"","avatar":"","id":}`) + 3 + 2 + 2 + 2 + 2 + 1
//var AlertsGrowHint3 = len(`{"msg":"._","sub":["",""],"path":"","img":"","id":}`) + 3 + 2 + 2 + 2 + 2 + 1
func AddActivityAndNotifyAll(a Alert) error {
id, err := Activity.Add(a)

View File

@ -68,7 +68,7 @@ function addAlert(msg, notice = false) {
let aItem = Template_alert({
ASID: msg.id,
Path: msg.path,
Avatar: msg.avatar || "",
Avatar: msg.img || "",
Message: mmsg
})
//alertMapping[msg.id] = aItem;
@ -83,7 +83,7 @@ function addAlert(msg, notice = false) {
if(Notification.permission === "granted") {
var n = new Notification("Something Happened",{
body: mmsg,
icon: msg.avatar,
icon: msg.img,
});
setTimeout(n.close.bind(n), 8000);
}
@ -138,7 +138,7 @@ function loadAlerts(menuAlerts, eTc = false) {
type:'get',
dataType:'json',
url:'/api/?m=alerts' + tc,
success: (data) => {
success: data => {
if("errmsg" in data) {
setAlertError(menuAlerts,data.errmsg)
return;