mirror of https://github.com/zulip/zulip.git
server_events_dispatch: Refactor realm_domain to use switch/case.
This should make no functional changes.
This commit is contained in:
parent
d575517035
commit
33fb78af42
|
@ -503,10 +503,12 @@ run_test("realm_domains", (override) => {
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(page_params.realm_domains, [event.realm_domain]);
|
assert_same(page_params.realm_domains, [event.realm_domain]);
|
||||||
|
|
||||||
|
override(settings_org, "populate_realm_domains", noop);
|
||||||
event = event_fixtures.realm_domains__change;
|
event = event_fixtures.realm_domains__change;
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(page_params.realm_domains, [event.realm_domain]);
|
assert_same(page_params.realm_domains, [event.realm_domain]);
|
||||||
|
|
||||||
|
override(settings_org, "populate_realm_domains", noop);
|
||||||
event = event_fixtures.realm_domains__remove;
|
event = event_fixtures.realm_domains__remove;
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(page_params.realm_domains, []);
|
assert_same(page_params.realm_domains, []);
|
||||||
|
|
|
@ -307,29 +307,36 @@ export function dispatch_normal_event(event) {
|
||||||
settings_linkifiers.populate_linkifiers(page_params.realm_filters);
|
settings_linkifiers.populate_linkifiers(page_params.realm_filters);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "realm_domains": {
|
case "realm_domains":
|
||||||
let i;
|
{
|
||||||
if (event.op === "add") {
|
let i;
|
||||||
page_params.realm_domains.push(event.realm_domain);
|
switch (event.op) {
|
||||||
} else if (event.op === "change") {
|
case "add":
|
||||||
for (i = 0; i < page_params.realm_domains.length; i += 1) {
|
page_params.realm_domains.push(event.realm_domain);
|
||||||
if (page_params.realm_domains[i].domain === event.realm_domain.domain) {
|
settings_org.populate_realm_domains(page_params.realm_domains);
|
||||||
page_params.realm_domains[i].allow_subdomains =
|
|
||||||
event.realm_domain.allow_subdomains;
|
|
||||||
break;
|
break;
|
||||||
}
|
case "change":
|
||||||
}
|
for (i = 0; i < page_params.realm_domains.length; i += 1) {
|
||||||
} else if (event.op === "remove") {
|
if (page_params.realm_domains[i].domain === event.realm_domain.domain) {
|
||||||
for (i = 0; i < page_params.realm_domains.length; i += 1) {
|
page_params.realm_domains[i].allow_subdomains =
|
||||||
if (page_params.realm_domains[i].domain === event.domain) {
|
event.realm_domain.allow_subdomains;
|
||||||
page_params.realm_domains.splice(i, 1);
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings_org.populate_realm_domains(page_params.realm_domains);
|
||||||
|
break;
|
||||||
|
case "remove":
|
||||||
|
for (i = 0; i < page_params.realm_domains.length; i += 1) {
|
||||||
|
if (page_params.realm_domains[i].domain === event.domain) {
|
||||||
|
page_params.realm_domains.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings_org.populate_realm_domains(page_params.realm_domains);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings_org.populate_realm_domains(page_params.realm_domains);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case "realm_user":
|
case "realm_user":
|
||||||
if (event.op === "add") {
|
if (event.op === "add") {
|
||||||
|
|
Loading…
Reference in New Issue