diff --git a/common/alerts.go b/common/alerts.go index 0d0533ec..33cf52ea 100644 --- a/common/alerts.go +++ b/common/alerts.go @@ -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) diff --git a/public/global.js b/public/global.js index d93766ab..000d192e 100644 --- a/public/global.js +++ b/public/global.js @@ -58,7 +58,7 @@ function bindToAlerts() { }); } -function addAlert(msg, notice = false) { +function addAlert(msg, notice=false) { var mmsg = msg.msg; if(mmsg[0]==".") mmsg = phraseBox["alerts"]["alerts"+mmsg]; if("sub" in msg) { @@ -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); } @@ -130,7 +130,7 @@ function setAlertError(menuAlerts,msg) { var alertsInitted = false; var lastTc = 0; -function loadAlerts(menuAlerts, eTc = false) { +function loadAlerts(menuAlerts, eTc=false) { if(!alertsInitted) return; let tc = ""; if(eTc && lastTc != 0) tc = "&t=" + lastTc + "&c=" + alertCount; @@ -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; @@ -207,7 +207,7 @@ function wsAlertEvent(data) { updateAlertList(generalAlerts/*, alist*/); } -function runWebSockets(resume = false) { +function runWebSockets(resume=false) { let s = ""; if(window.location.protocol == "https:") s = "s"; conn = new WebSocket("ws"+s+"://" + document.location.host + "/ws/");