mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
refactor: Stop using page_params.realm_default_streams.
We now only use `page_params.realm_default_streams` during initialization, and then after that we use `stream_data` APIs to get default stream ids and related info. (And for the event that replace the data, we just update our internal data structures as well.) Long term we should have the server just send us ids here, since we are now hydrating info from stream data in all places.
This commit is contained in:
@@ -746,7 +746,6 @@ run_test('remove_default_stream', () => {
|
||||
stream_data.set_realm_default_streams([remove_me]);
|
||||
stream_data.remove_default_stream(remove_me.stream_id);
|
||||
assert(!stream_data.is_default_stream_id(remove_me.stream_id));
|
||||
assert.equal(page_params.realm_default_streams.length, 0);
|
||||
});
|
||||
|
||||
run_test('canonicalized_name', () => {
|
||||
@@ -816,6 +815,9 @@ run_test('initialize', () => {
|
||||
stream_id: 2003,
|
||||
}];
|
||||
|
||||
params.realm_default_streams = [
|
||||
];
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -857,6 +859,7 @@ run_test('filter inactives', () => {
|
||||
params.unsubscribed = [];
|
||||
params.never_subscribed = [];
|
||||
params.subscriptions = [];
|
||||
params.realm_default_streams = [];
|
||||
|
||||
stream_data.initialize(params);
|
||||
assert(!stream_data.is_filtering_inactives());
|
||||
|
||||
@@ -584,7 +584,6 @@ exports.all_topics_in_cache = function (sub) {
|
||||
};
|
||||
|
||||
exports.set_realm_default_streams = function (realm_default_streams) {
|
||||
page_params.realm_default_streams = realm_default_streams;
|
||||
default_stream_ids.clear();
|
||||
|
||||
realm_default_streams.forEach(function (stream) {
|
||||
@@ -818,17 +817,14 @@ exports.initialize = function (params) {
|
||||
const subscriptions = params.subscriptions;
|
||||
const unsubscribed = params.unsubscribed;
|
||||
const never_subscribed = params.never_subscribed;
|
||||
const realm_default_streams = params.realm_default_streams;
|
||||
|
||||
/*
|
||||
We also consume some data directly from `page_params`.
|
||||
This data can be accessed by any other module,
|
||||
and we consider the authoritative source to be
|
||||
`page_params`. Some of this data should eventually
|
||||
be fully handled by stream_data. In particular,
|
||||
the way we handle `page_params.realm_default_streams`
|
||||
is kinda janky, because we maintain our own data
|
||||
structure, but then some legacy modules still
|
||||
refer directly to `page_params`. We should fix that.
|
||||
be fully handled by stream_data.
|
||||
*/
|
||||
|
||||
color_data.claim_colors(subscriptions);
|
||||
@@ -843,7 +839,7 @@ exports.initialize = function (params) {
|
||||
});
|
||||
}
|
||||
|
||||
exports.set_realm_default_streams(page_params.realm_default_streams);
|
||||
exports.set_realm_default_streams(realm_default_streams);
|
||||
|
||||
populate_subscriptions(subscriptions, true, true);
|
||||
populate_subscriptions(unsubscribed, false, true);
|
||||
@@ -869,9 +865,6 @@ exports.initialize = function (params) {
|
||||
};
|
||||
|
||||
exports.remove_default_stream = function (stream_id) {
|
||||
page_params.realm_default_streams = page_params.realm_default_streams.filter(
|
||||
stream => stream.stream_id !== stream_id
|
||||
);
|
||||
default_stream_ids.delete(stream_id);
|
||||
};
|
||||
|
||||
|
||||
@@ -410,7 +410,8 @@ exports.initialize_everything = function () {
|
||||
const stream_data_params = pop_fields(
|
||||
'subscriptions',
|
||||
'unsubscribed',
|
||||
'never_subscribed'
|
||||
'never_subscribed',
|
||||
'realm_default_streams'
|
||||
);
|
||||
|
||||
const user_groups_params = pop_fields(
|
||||
|
||||
Reference in New Issue
Block a user