js: Clean up poorly named const id variables.

We have conventions for naming message_id, stream_id, etc. values that
way for readability; these entries are violations of those conventions.
This commit is contained in:
Tim Abbott
2020-01-16 13:27:27 -08:00
parent f13f744874
commit e2681372f3
4 changed files with 18 additions and 21 deletions

View File

@@ -589,8 +589,8 @@ exports.open_message_menu = function (message) {
return true; return true;
} }
const id = message.id; const message_id = message.id;
exports.toggle_actions_popover($(".selected_message .actions_hover")[0], id); exports.toggle_actions_popover($(".selected_message .actions_hover")[0], message_id);
if (current_actions_popover_elem) { if (current_actions_popover_elem) {
focus_first_action_popover_item(); focus_first_action_popover_item();
} }
@@ -741,11 +741,11 @@ exports.register_click_handlers = function () {
}); });
$("#main_div").on("click", ".user-group-mention", function (e) { $("#main_div").on("click", ".user-group-mention", function (e) {
const id = parseInt($(this).attr('data-user-group-id'), 10); const user_group_id = parseInt($(this).attr('data-user-group-id'), 10);
const row = $(this).closest(".message_row"); const row = $(this).closest(".message_row");
e.stopPropagation(); e.stopPropagation();
const message = current_msg_list.get(rows.id(row)); const message = current_msg_list.get(rows.id(row));
const group = user_groups.get_user_group_from_id(id, true); const group = user_groups.get_user_group_from_id(user_group_id, true);
if (group === undefined) { if (group === undefined) {
// This user group has likely been deleted. // This user group has likely been deleted.
blueslip.info('Unable to find user group in message' + message.sender_id); blueslip.info('Unable to find user group in message' + message.sender_id);
@@ -928,8 +928,8 @@ exports.register_click_handlers = function () {
}); });
function reminder_click_handler(datestr, e) { function reminder_click_handler(datestr, e) {
const id = $(".remind.custom").data('message-id'); const message_id = $(".remind.custom").data('message-id');
reminder.do_set_reminder_for_message(id, datestr); reminder.do_set_reminder_for_message(message_id, datestr);
exports.hide_all(); exports.hide_all();
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
@@ -1051,8 +1051,8 @@ exports.register_click_handlers = function () {
$('body').on('click', '.copy_link', function (e) { $('body').on('click', '.copy_link', function (e) {
exports.hide_actions_popover(); exports.hide_actions_popover();
const id = $(this).attr("data-message-id"); const message_id = $(this).attr("data-message-id");
const row = $("[zid='" + id + "']"); const row = $("[zid='" + message_id + "']");
row.find(".alert-msg") row.find(".alert-msg")
.text(i18n.t("Copied!")) .text(i18n.t("Copied!"))
.css("display", "block") .css("display", "block")

View File

@@ -59,17 +59,17 @@ exports.set_colorpicker_color = function (colorpicker, color) {
exports.update_stream_color = function (sub, color, opts) { exports.update_stream_color = function (sub, color, opts) {
opts = _.defaults({}, opts, {update_historical: false}); opts = _.defaults({}, opts, {update_historical: false});
sub.color = color; sub.color = color;
const id = sub.stream_id; const stream_id = sub.stream_id;
// The swatch in the subscription row header. // The swatch in the subscription row header.
$(".stream-row[data-stream-id='" + id + "'] .icon").css('background-color', color); $(".stream-row[data-stream-id='" + stream_id + "'] .icon").css('background-color', color);
// The swatch in the color picker. // The swatch in the color picker.
exports.set_colorpicker_color($("#subscription_overlay .subscription_settings[data-stream-id='" + id + "'] .colorpicker"), color); exports.set_colorpicker_color($("#subscription_overlay .subscription_settings[data-stream-id='" + stream_id + "'] .colorpicker"), color);
$("#subscription_overlay .subscription_settings[data-stream-id='" + id + "'] .large-icon").css("color", color); $("#subscription_overlay .subscription_settings[data-stream-id='" + stream_id + "'] .large-icon").css("color", color);
if (opts.update_historical) { if (opts.update_historical) {
update_historical_message_color(sub.name, color); update_historical_message_color(sub.name, color);
} }
update_stream_sidebar_swatch_color(id, color); update_stream_sidebar_swatch_color(stream_id, color);
if (!page_params.search_pills_enabled) { if (!page_params.search_pills_enabled) {
tab_bar.colorize_tab_bar(); tab_bar.colorize_tab_bar();
} }

View File

@@ -19,8 +19,7 @@ exports.setup_subscriptions_tab_hash = function (tab_key_value) {
}; };
exports.settings_for_sub = function (sub) { exports.settings_for_sub = function (sub) {
const id = sub.stream_id; return $("#subscription_overlay .subscription_settings[data-stream-id='" + sub.stream_id + "']");
return $("#subscription_overlay .subscription_settings[data-stream-id='" + id + "']");
}; };
exports.is_sub_settings_active = function (sub) { exports.is_sub_settings_active = function (sub) {
@@ -96,8 +95,8 @@ function format_member_list_elem(email) {
} }
function get_subscriber_list(sub_row) { function get_subscriber_list(sub_row) {
const id = sub_row.data("stream-id"); const stream_id_str = sub_row.data("stream-id");
return $('.subscription_settings[data-stream-id="' + id + '"] .subscriber-list'); return $('.subscription_settings[data-stream-id="' + stream_id_str + '"] .subscriber-list');
} }
exports.update_stream_name = function (sub, new_name) { exports.update_stream_name = function (sub, new_name) {

View File

@@ -15,8 +15,7 @@ exports.show_subs_pane = {
}; };
exports.check_button_for_sub = function (sub) { exports.check_button_for_sub = function (sub) {
const id = sub.stream_id; return $(".stream-row[data-stream-id='" + sub.stream_id + "'] .check");
return $(".stream-row[data-stream-id='" + id + "'] .check");
}; };
exports.row_for_stream_id = function (stream_id) { exports.row_for_stream_id = function (stream_id) {
@@ -26,8 +25,7 @@ exports.row_for_stream_id = function (stream_id) {
exports.settings_button_for_sub = function (sub) { exports.settings_button_for_sub = function (sub) {
// We don't do expectOne() here, because this button is only // We don't do expectOne() here, because this button is only
// visible if the user has that stream selected in the streams UI. // visible if the user has that stream selected in the streams UI.
const id = sub.stream_id; return $(".subscription_settings[data-stream-id='" + sub.stream_id + "'] .subscribe-button");
return $(".subscription_settings[data-stream-id='" + id + "'] .subscribe-button");
}; };
function get_row_data(row) { function get_row_data(row) {