mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
Move recent_subjects to stream_data.
This commit is contained in:
@@ -22,11 +22,11 @@ set_global('feature_flags', {
|
||||
set_global('page_params', {
|
||||
email: 'bob@zulip.com'
|
||||
});
|
||||
set_global('recent_subjects', new global.Dict({fold_case: true}));
|
||||
|
||||
var stream_data = require('js/stream_data.js');
|
||||
set_global('stream_data', {
|
||||
get_name: stream_data.get_name
|
||||
get_name: stream_data.get_name,
|
||||
recent_subjects: new global.Dict({fold_case: true})
|
||||
});
|
||||
|
||||
set_global('narrow', {});
|
||||
@@ -243,7 +243,7 @@ set_global('narrow', {});
|
||||
return 'office';
|
||||
};
|
||||
|
||||
global.recent_subjects = new global.Dict.from({
|
||||
global.stream_data.recent_subjects = new global.Dict.from({
|
||||
'devel': [
|
||||
{subject: 'REXX'}
|
||||
],
|
||||
@@ -311,7 +311,7 @@ set_global('narrow', {});
|
||||
return;
|
||||
};
|
||||
|
||||
global.recent_subjects = new global.Dict({fold_case: true});
|
||||
global.stream_data.recent_subjects = new global.Dict({fold_case: true});
|
||||
|
||||
var suggestions = search.get_suggestions(query);
|
||||
|
||||
@@ -333,7 +333,7 @@ set_global('narrow', {});
|
||||
return;
|
||||
};
|
||||
|
||||
global.recent_subjects = new global.Dict({fold_case: true});
|
||||
global.stream_data.recent_subjects = new global.Dict({fold_case: true});
|
||||
|
||||
var suggestions = search.get_suggestions(query);
|
||||
|
||||
@@ -371,7 +371,7 @@ set_global('narrow', {});
|
||||
}
|
||||
];
|
||||
|
||||
global.recent_subjects = new global.Dict.from({
|
||||
global.stream_data.recent_subjects = new global.Dict.from({
|
||||
office: [
|
||||
{subject: 'team'},
|
||||
{subject: 'ignore'},
|
||||
|
||||
@@ -11,7 +11,8 @@ add_dependencies({
|
||||
hashchange: 'js/hashchange'
|
||||
});
|
||||
|
||||
set_global('recent_subjects', new global.Dict());
|
||||
global.recent_subjects = new global.Dict();
|
||||
|
||||
set_global('unread', {});
|
||||
set_global('message_store', {
|
||||
recent_private_messages: new global.Array()
|
||||
@@ -38,7 +39,7 @@ global.use_template('stream_privacy');
|
||||
var topics = [
|
||||
{subject: "coding"}
|
||||
];
|
||||
global.recent_subjects.set("devel", topics);
|
||||
global.stream_data.recent_subjects.set("devel", topics);
|
||||
global.unread.num_unread_for_subject = function () {
|
||||
return 1;
|
||||
};
|
||||
|
||||
@@ -47,22 +47,20 @@ exports.process_message_for_recent_subjects = function process_message_for_recen
|
||||
var stream = message.stream;
|
||||
var canon_subject = stream_data.canonicalized_name(message.subject);
|
||||
|
||||
if (! recent_subjects.has(stream)) {
|
||||
recent_subjects.set(stream, []);
|
||||
if (! stream_data.recent_subjects.has(stream)) {
|
||||
stream_data.recent_subjects.set(stream, []);
|
||||
} else {
|
||||
recent_subjects.set(stream,
|
||||
_.filter(recent_subjects.get(stream), function (item) {
|
||||
stream_data.recent_subjects.set(stream, _.filter(stream_data.recent_subjects.get(stream), function (item) {
|
||||
var is_duplicate = (item.canon_subject.toLowerCase() === canon_subject.toLowerCase());
|
||||
if (is_duplicate) {
|
||||
current_timestamp = item.timestamp;
|
||||
count = item.count;
|
||||
}
|
||||
|
||||
return !is_duplicate;
|
||||
}));
|
||||
}
|
||||
|
||||
var recents = recent_subjects.get(stream);
|
||||
var recents = stream_data.recent_subjects.get(stream);
|
||||
|
||||
if (remove_message !== undefined) {
|
||||
count = count - 1;
|
||||
@@ -81,7 +79,7 @@ exports.process_message_for_recent_subjects = function process_message_for_recen
|
||||
return b.timestamp - a.timestamp;
|
||||
});
|
||||
|
||||
recent_subjects.set(stream, recents);
|
||||
stream_data.recent_subjects.set(stream, recents);
|
||||
};
|
||||
|
||||
exports.process_message_for_recent_private_messages = function process_message_for_recent_private_messages(message, remove_message) {
|
||||
|
||||
@@ -255,7 +255,7 @@ function get_topic_suggestions(query_operators) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var topics = recent_subjects.get(stream);
|
||||
var topics = stream_data.recent_subjects.get(stream);
|
||||
|
||||
stream = stream_data.get_name(stream);
|
||||
|
||||
@@ -263,7 +263,7 @@ function get_topic_suggestions(query_operators) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Be defensive here in case recent_subjects gets super huge, but
|
||||
// Be defensive here in case stream_data.recent_subjects gets super huge, but
|
||||
// still slice off enough topics to find matches.
|
||||
topics = topics.slice(0, 300);
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ exports.clear_subscriptions = function () {
|
||||
stream_info = new Dict({fold_case: true});
|
||||
subs_by_stream_id = new Dict();
|
||||
};
|
||||
|
||||
exports.recent_subjects = new Dict({fold_case: true});
|
||||
exports.clear_subscriptions();
|
||||
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ exports.build_stream_list = function () {
|
||||
|
||||
streams.sort(function (a, b) {
|
||||
if (sort_recent) {
|
||||
if (recent_subjects.has(b) && ! recent_subjects.has(a)) {
|
||||
if (stream_data.recent_subjects.has(b) && ! stream_data.recent_subjects.has(a)) {
|
||||
return 1;
|
||||
} else if (! recent_subjects.has(b) && recent_subjects.has(a)) {
|
||||
} else if (! stream_data.recent_subjects.has(b) && stream_data.recent_subjects.has(a)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ exports.build_stream_list = function () {
|
||||
_.each(streams, function (stream) {
|
||||
var li = $(stream_data.get_sub(stream).sidebar_li);
|
||||
if (sort_recent) {
|
||||
if (! recent_subjects.has(stream)) {
|
||||
if (! stream_data.recent_subjects.has(stream)) {
|
||||
li.addClass('inactive_stream');
|
||||
} else {
|
||||
li.removeClass('inactive_stream');
|
||||
@@ -291,7 +291,7 @@ exports.remove_narrow_filter = function (name, type) {
|
||||
};
|
||||
|
||||
exports._build_subject_list = function (stream, active_topic, max_subjects) {
|
||||
var subjects = recent_subjects.get(stream) || [];
|
||||
var subjects = stream_data.recent_subjects.get(stream) || [];
|
||||
|
||||
if (active_topic) {
|
||||
active_topic = active_topic.toLowerCase();
|
||||
|
||||
@@ -3,8 +3,6 @@ var home_msg_list = new message_list.MessageList('zhome',
|
||||
);
|
||||
var current_msg_list = home_msg_list;
|
||||
|
||||
var recent_subjects = new Dict({fold_case: true});
|
||||
|
||||
var queued_mark_as_read = [];
|
||||
var queued_flag_timer;
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ var globals =
|
||||
+ ' home_msg_list current_msg_list'
|
||||
+ ' respond_to_message'
|
||||
+ ' process_loaded_for_unread'
|
||||
+ ' recent_subjects'
|
||||
;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user