refactor: Extract can_toggle_subscription(sub).

We don't want to rely so much on calculated fields,
and the `should_display_subscription_button` name
is a bit misleading in certain contexts.
This commit is contained in:
Steve Howell
2021-04-04 15:23:40 +00:00
committed by Tim Abbott
parent 9c9d74fd6d
commit 93471ed3e4
9 changed files with 16 additions and 15 deletions

View File

@@ -661,7 +661,7 @@ export function validation_error(error_type, stream_name) {
case "not-subscribed": {
const sub = stream_data.get_sub(stream_name);
const new_row = render_compose_not_subscribed({
should_display_sub_button: sub.should_display_subscription_button,
should_display_sub_button: stream_data.can_toggle_subscription(sub),
});
compose_not_subscribed_error(new_row, $("#stream_message_recipient_stream"));
return false;