refactor: Call stream_data.initialize() more directly.

This function used to be called initialize_from_page_params(),
and we called it indirectly through `subs.js`.

Now we call it directly from `ui_init.js`, which gives us a
bit more control over how things are initialized.  In fact,
this sets us up for the next commit, where I fix a recent
regression I introduced.
This commit is contained in:
Steve Howell 2018-12-15 18:37:17 +00:00 committed by Tim Abbott
parent e0c8492464
commit 625388ccf0
4 changed files with 6 additions and 6 deletions

View File

@ -631,7 +631,7 @@ run_test('create_sub', () => {
assert.equal(antarctica_sub.color, '#76ce90');
});
run_test('initialize_from_page_params', () => {
run_test('initialize', () => {
function initialize() {
page_params.subscriptions = [{
name: 'subscriptions',
@ -651,7 +651,7 @@ run_test('initialize_from_page_params', () => {
initialize();
page_params.realm_notifications_stream_id = -1;
stream_data.initialize_from_page_params();
stream_data.initialize();
const stream_names = stream_data.get_streams_for_admin().map(elem => elem.name);
assert(stream_names.indexOf('subscriptions') !== -1);
@ -665,7 +665,7 @@ run_test('initialize_from_page_params', () => {
// Simulate a private stream the user isn't subscribed to
initialize();
page_params.realm_notifications_stream_id = 89;
stream_data.initialize_from_page_params();
stream_data.initialize();
assert.equal(page_params.notifications_stream, "");
// Now actually subscribe the user to the stream
@ -676,7 +676,7 @@ run_test('initialize_from_page_params', () => {
};
stream_data.add_sub('foo', foo);
stream_data.initialize_from_page_params();
stream_data.initialize();
assert.equal(page_params.notifications_stream, "foo");
});

View File

@ -565,7 +565,7 @@ exports.get_streams_for_admin = function () {
return subs;
};
exports.initialize_from_page_params = function () {
exports.initialize = function () {
color_data.claim_colors(page_params.subscriptions);
function populate_subscriptions(subs, subscribed, previously_subscribed) {

View File

@ -770,7 +770,6 @@ exports.sub_or_unsub = function (sub) {
exports.initialize = function () {
stream_data.initialize_from_page_params();
stream_list.create_initial_sidebar_rows();
// We build the stream_list now. It may get re-built again very shortly

View File

@ -283,6 +283,7 @@ $(function () {
echo.initialize();
stream_color.initialize();
stream_edit.initialize();
stream_data.initialize();
subs.initialize();
condense.initialize();
lightbox.initialize();