Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stream_topic_history: Pluralize remove_message.

Tim Abbott3087fbe85406
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index 7317a9d90d0..639c988f277 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -811,11 +811,12 @@ with_overrides(function (override) {
assert_same(args.message_ids, [1337]);
});
global.with_stub(function (stub) {
- override('stream_topic_history.remove_message', stub.f);
+ override('stream_topic_history.remove_messages', stub.f);
dispatch(event);
const args = stub.get_args('opts');
assert_same(args.opts.stream_id, 99);
assert_same(args.opts.topic_name, 'topic1');
+ assert_same(args.opts.num_messages, 1);
});
});
diff --git a/frontend_tests/node_tests/stream_topic_history.js b/frontend_tests/node_tests/stream_topic_history.js
index 0e3ade6187a..f9e91719e23 100644
--- a/frontend_tests/node_tests/stream_topic_history.js
+++ b/frontend_tests/node_tests/stream_topic_history.js
@@ -41,9 +41,10 @@ run_test('basics', () => {
assert.deepEqual(max_message_id, 103);
// Removing first topic1 message has no effect.
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: stream_id,
topic_name: 'toPic1',
+ num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
assert.deepEqual(history, ['topic2', 'Topic1']);
@@ -52,24 +53,27 @@ run_test('basics', () => {
assert.deepEqual(max_message_id, 103);
// Removing second topic1 message removes the topic.
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: stream_id,
topic_name: 'Topic1',
+ num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
assert.deepEqual(history, ['topic2']);
// Test that duplicate remove does not crash us.
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: stream_id,
topic_name: 'Topic1',
+ num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
assert.deepEqual(history, ['topic2']);
// get to 100% coverage for defensive code
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: 9999999,
+ num_messages: 1,
});
});
@@ -173,18 +177,20 @@ run_test('server_history', () => {
// Removing a local message removes the topic if we have
// our counts right.
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: stream_id,
topic_name: 'local',
+ num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
assert.deepEqual(history, ['hist2', 'hist1']);
// We can try to remove a historical message, but it should
// have no effect.
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: stream_id,
topic_name: 'hist2',
+ num_messages: 1,
});
history = stream_topic_history.get_recent_topic_names(stream_id);
assert.deepEqual(history, ['hist2', 'hist1']);
diff --git a/static/js/echo.js b/static/js/echo.js
index a61f755222e..b3714abdeb2 100644
--- a/static/js/echo.js
+++ b/static/js/echo.js
@@ -193,9 +193,10 @@ exports.edit_locally = function (message, request) {
if (request.new_topic !== undefined || request.new_stream_id !== undefined) {
const new_stream_id = request.new_stream_id;
const new_topic = request.new_topic;
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: message.stream_id,
topic_name: message.topic,
+ num_messages: 1,
});
if (new_stream_id !== undefined) {
diff --git a/static/js/message_events.js b/static/js/message_events.js
index cf3dbc38786..0fef5266047 100644
--- a/static/js/message_events.js
+++ b/static/js/message_events.js
@@ -187,9 +187,10 @@ exports.update_messages = function update_messages(events) {
// complexity; the present loop assumes stream_topic_history has
// only messages in message_store, but that's been false
// since we added the server_history feature.
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: msg.stream_id,
topic_name: msg.topic,
+ num_messages: 1,
});
// Update the unread counts; again, this must be called
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index d494041b526..d13e328eb89 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -29,7 +29,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
unread_ops.process_read_messages_event(msg_ids);
if (event.message_type === 'stream') {
- stream_topic_history.remove_message({
+ stream_topic_history.remove_messages({
stream_id: event.stream_id,
topic_name: event.topic,
num_messages: msg_ids.length,
diff --git a/static/js/stream_topic_history.js b/static/js/stream_topic_history.js
index 79510a00089..31223b725e2 100644
--- a/static/js/stream_topic_history.js
+++ b/static/js/stream_topic_history.js
@@ -196,10 +196,10 @@ exports.per_stream_history = function (stream_id) {
return self;
};
-exports.remove_message = function (opts) {
+exports.remove_messages = function (opts) {
const stream_id = opts.stream_id;
const topic_name = opts.topic_name;
- const num_messages = opts.num_messages || 1;
+ const num_messages = opts.num_messages;
const history = stream_dict.get(stream_id);
// This is the special case of "removing" a message from