mirror of https://github.com/zulip/zulip.git
util: Kill off set_topic_links/get_topic_links.
These functions were just shims that were
used in the somewhat painful migration from
subject_* to topic_*.
The commit 4572be8c27
fixed it so that the client never needs to
deal with "subject_links".
So now we just go back to simpler code:
message.topic_links = links
links = message.topic_links
This commit is contained in:
parent
39405fccdc
commit
cb91b7f312
|
@ -3,7 +3,6 @@ set_global('katex', zrequire('katex', 'katex/dist/katex.min.js'));
|
||||||
set_global('marked', zrequire('marked', 'third/marked/lib/marked'));
|
set_global('marked', zrequire('marked', 'third/marked/lib/marked'));
|
||||||
set_global('i18n', global.stub_i18n);
|
set_global('i18n', global.stub_i18n);
|
||||||
|
|
||||||
const util = zrequire('util');
|
|
||||||
zrequire('fenced_code');
|
zrequire('fenced_code');
|
||||||
zrequire('stream_data');
|
zrequire('stream_data');
|
||||||
zrequire('people');
|
zrequire('people');
|
||||||
|
@ -441,50 +440,50 @@ run_test('marked', () => {
|
||||||
run_test('topic_links', () => {
|
run_test('topic_links', () => {
|
||||||
let message = {type: 'stream', topic: "No links here"};
|
let message = {type: 'stream', topic: "No links here"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 0);
|
assert.equal(message.topic_links.length, 0);
|
||||||
|
|
||||||
message = {type: 'stream', topic: "One #123 link here"};
|
message = {type: 'stream', topic: "One #123 link here"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 1);
|
assert.equal(message.topic_links.length, 1);
|
||||||
assert.equal(util.get_topic_links(message)[0], "https://trac.zulip.net/ticket/123");
|
assert.equal(message.topic_links[0], "https://trac.zulip.net/ticket/123");
|
||||||
|
|
||||||
message = {type: 'stream', topic: "Two #123 #456 link here"};
|
message = {type: 'stream', topic: "Two #123 #456 link here"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 2);
|
assert.equal(message.topic_links.length, 2);
|
||||||
assert.equal(util.get_topic_links(message)[0], "https://trac.zulip.net/ticket/123");
|
assert.equal(message.topic_links[0], "https://trac.zulip.net/ticket/123");
|
||||||
assert.equal(util.get_topic_links(message)[1], "https://trac.zulip.net/ticket/456");
|
assert.equal(message.topic_links[1], "https://trac.zulip.net/ticket/456");
|
||||||
|
|
||||||
message = {type: 'stream', topic: "New ZBUG_123 link here"};
|
message = {type: 'stream', topic: "New ZBUG_123 link here"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 1);
|
assert.equal(message.topic_links.length, 1);
|
||||||
assert.equal(util.get_topic_links(message)[0], "https://trac2.zulip.net/ticket/123");
|
assert.equal(message.topic_links[0], "https://trac2.zulip.net/ticket/123");
|
||||||
|
|
||||||
message = {type: 'stream', topic: "New ZBUG_123 with #456 link here"};
|
message = {type: 'stream', topic: "New ZBUG_123 with #456 link here"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 2);
|
assert.equal(message.topic_links.length, 2);
|
||||||
assert(util.get_topic_links(message).includes("https://trac2.zulip.net/ticket/123"));
|
assert(message.topic_links.includes("https://trac2.zulip.net/ticket/123"));
|
||||||
assert(util.get_topic_links(message).includes("https://trac.zulip.net/ticket/456"));
|
assert(message.topic_links.includes("https://trac.zulip.net/ticket/456"));
|
||||||
|
|
||||||
message = {type: 'stream', topic: "One ZGROUP_123:45 link here"};
|
message = {type: 'stream', topic: "One ZGROUP_123:45 link here"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 1);
|
assert.equal(message.topic_links.length, 1);
|
||||||
assert.equal(util.get_topic_links(message)[0], "https://zone_45.zulip.net/ticket/123");
|
assert.equal(message.topic_links[0], "https://zone_45.zulip.net/ticket/123");
|
||||||
|
|
||||||
message = {type: 'stream', topic: "Hello https://google.com"};
|
message = {type: 'stream', topic: "Hello https://google.com"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 1);
|
assert.equal(message.topic_links.length, 1);
|
||||||
assert.equal(util.get_topic_links(message)[0], "https://google.com");
|
assert.equal(message.topic_links[0], "https://google.com");
|
||||||
|
|
||||||
message = {type: 'stream', topic: "#456 https://google.com https://github.com"};
|
message = {type: 'stream', topic: "#456 https://google.com https://github.com"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 3);
|
assert.equal(message.topic_links.length, 3);
|
||||||
assert(util.get_topic_links(message).includes("https://google.com"));
|
assert(message.topic_links.includes("https://google.com"));
|
||||||
assert(util.get_topic_links(message).includes("https://github.com"));
|
assert(message.topic_links.includes("https://github.com"));
|
||||||
assert(util.get_topic_links(message).includes("https://trac.zulip.net/ticket/456"));
|
assert(message.topic_links.includes("https://trac.zulip.net/ticket/456"));
|
||||||
|
|
||||||
message = {type: "not-stream"};
|
message = {type: "not-stream"};
|
||||||
markdown.add_topic_links(message);
|
markdown.add_topic_links(message);
|
||||||
assert.equal(util.get_topic_links(message).length, 0);
|
assert.equal(message.topic_links.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('message_flags', () => {
|
run_test('message_flags', () => {
|
||||||
|
|
|
@ -292,7 +292,7 @@ exports.process_from_server = function process_from_server(messages) {
|
||||||
// the backend.
|
// the backend.
|
||||||
client_message.timestamp = message.timestamp;
|
client_message.timestamp = message.timestamp;
|
||||||
|
|
||||||
util.set_topic_links(client_message, util.get_topic_links(message));
|
client_message.topic_links = message.topic_links;
|
||||||
client_message.is_me_message = message.is_me_message;
|
client_message.is_me_message = message.is_me_message;
|
||||||
client_message.submessages = message.submessages;
|
client_message.submessages = message.submessages;
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ exports.apply_markdown = function (message) {
|
||||||
|
|
||||||
exports.add_topic_links = function (message) {
|
exports.add_topic_links = function (message) {
|
||||||
if (message.type !== 'stream') {
|
if (message.type !== 'stream') {
|
||||||
util.set_topic_links(message, []);
|
message.topic_links = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const topic = util.get_message_topic(message);
|
const topic = util.get_message_topic(message);
|
||||||
|
@ -207,7 +207,7 @@ exports.add_topic_links = function (message) {
|
||||||
links = links.concat(match);
|
links = links.concat(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
util.set_topic_links(message, links);
|
message.topic_links = links;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.is_status_message = function (raw_content) {
|
exports.is_status_message = function (raw_content) {
|
||||||
|
|
|
@ -197,7 +197,7 @@ exports.update_messages = function update_messages(events) {
|
||||||
unread.update_unread_topics(msg, event);
|
unread.update_unread_topics(msg, event);
|
||||||
|
|
||||||
util.set_message_topic(msg, new_topic);
|
util.set_message_topic(msg, new_topic);
|
||||||
util.set_topic_links(msg, util.get_topic_links(event));
|
msg.topic_links = event.topic_links;
|
||||||
|
|
||||||
// Add the recent topics entry for the new topics; must
|
// Add the recent topics entry for the new topics; must
|
||||||
// be called after we call set_message_topic.
|
// be called after we call set_message_topic.
|
||||||
|
|
|
@ -182,7 +182,7 @@ function populate_group_from_message_container(group, message_container) {
|
||||||
group.display_reply_to = message_store.get_pm_full_names(message_container.msg);
|
group.display_reply_to = message_store.get_pm_full_names(message_container.msg);
|
||||||
}
|
}
|
||||||
group.display_recipient = message_container.msg.display_recipient;
|
group.display_recipient = message_container.msg.display_recipient;
|
||||||
group.topic_links = util.get_topic_links(message_container.msg);
|
group.topic_links = message_container.msg.topic_links;
|
||||||
|
|
||||||
set_topic_edit_properties(group, message_container.msg);
|
set_topic_edit_properties(group, message_container.msg);
|
||||||
render_group_display_date(group, message_container);
|
render_group_display_date(group, message_container);
|
||||||
|
|
|
@ -234,14 +234,6 @@ exports.sorted_ids = function (ids) {
|
||||||
return id_list;
|
return id_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.set_topic_links = function (obj, topic_links) {
|
|
||||||
obj.topic_links = topic_links;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.get_topic_links = function (obj) {
|
|
||||||
return obj.topic_links;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.set_match_data = function (target, source) {
|
exports.set_match_data = function (target, source) {
|
||||||
target.match_subject = source.match_subject;
|
target.match_subject = source.match_subject;
|
||||||
target.match_content = source.match_content;
|
target.match_content = source.match_content;
|
||||||
|
|
Loading…
Reference in New Issue