Add id field to announcements and hide previously closed announcements

This commit is contained in:
Calvin Montgomery 2017-07-22 10:35:45 -07:00
parent ff3ececc36
commit 964feb7243
4 changed files with 17 additions and 2 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.42.0",
"version": "3.42.1",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -4,6 +4,7 @@ var db = require("./database");
var util = require("./utilities");
var Config = require("./config");
var Server = require("./server");
import { v4 as uuidv4 } from 'uuid';
function eventUsername(user) {
return user.getName() + "@" + user.realip;
@ -13,6 +14,7 @@ function handleAnnounce(user, data) {
var sv = Server.getServer();
sv.announce({
id: uuidv4(),
title: data.title,
text: data.content,
from: user.getName()

View File

@ -64,10 +64,21 @@ Callbacks = {
},
announcement: function(data) {
// Suppress this announcement for people who have already closed it
if (data.id && CyTube.ui.suppressedAnnouncementId
&& data.id === CyTube.ui.suppressedAnnouncementId) {
return;
}
$("#announcements").html("");
var signature = "<br>\u2014" + data.from;
var announcement = makeAlert(data.title, data.text + signature)
.appendTo($("#announcements"));
if (data.id) {
announcement.find(".close").click(function suppressThisAnnouncement() {
CyTube.ui.suppressedAnnouncementId = data.id;
setOpt("suppressed_announcement_id", data.id);
});
}
},
kick: function(data) {

View File

@ -69,7 +69,9 @@ var SOCKETIO_CONNECT_ERROR_COUNT = 0;
var HAS_CONNECTED_BEFORE = false;
var IMAGE_MATCH = /<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/gi;
var CyTube = {};
CyTube.ui = {};
CyTube.ui = {
suppressedAnnouncementId: getOpt("suppressed_announcement_id")
};
CyTube.featureFlag = {
efficientEmotes: false
};