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);
|
||||
assert_same(page_params.realm_domains, [event.realm_domain]);
|
||||
|
||||
override(settings_org, "populate_realm_domains", noop);
|
||||
event = event_fixtures.realm_domains__change;
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_domains, [event.realm_domain]);
|
||||
|
||||
override(settings_org, "populate_realm_domains", noop);
|
||||
event = event_fixtures.realm_domains__remove;
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_domains, []);
|
||||
|
|
|
@ -307,11 +307,15 @@ export function dispatch_normal_event(event) {
|
|||
settings_linkifiers.populate_linkifiers(page_params.realm_filters);
|
||||
break;
|
||||
|
||||
case "realm_domains": {
|
||||
case "realm_domains":
|
||||
{
|
||||
let i;
|
||||
if (event.op === "add") {
|
||||
switch (event.op) {
|
||||
case "add":
|
||||
page_params.realm_domains.push(event.realm_domain);
|
||||
} else if (event.op === "change") {
|
||||
settings_org.populate_realm_domains(page_params.realm_domains);
|
||||
break;
|
||||
case "change":
|
||||
for (i = 0; i < page_params.realm_domains.length; i += 1) {
|
||||
if (page_params.realm_domains[i].domain === event.realm_domain.domain) {
|
||||
page_params.realm_domains[i].allow_subdomains =
|
||||
|
@ -319,17 +323,20 @@ export function dispatch_normal_event(event) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (event.op === "remove") {
|
||||
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;
|
||||
|
||||
case "realm_user":
|
||||
if (event.op === "add") {
|
||||
|
|
Loading…
Reference in New Issue