mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	js: Add braces to case blocks declaring variables.
This helps to prepare for the migration of `var` to `let` and `const`. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
		
				
					committed by
					
						 Tim Abbott
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							12bd3c04c0
						
					
				
				
					commit
					a547413347
				
			| @@ -499,13 +499,14 @@ exports.validation_error = function (error_type, stream_name) { | ||||
|         compose_error(i18n.t("Error checking subscription"), | ||||
|                       $("#stream_message_recipient_stream")); | ||||
|         return false; | ||||
|     case "not-subscribed": | ||||
|     case "not-subscribed": { | ||||
|         var sub = stream_data.get_sub(stream_name); | ||||
|         var new_row = render_compose_not_subscribed({ | ||||
|             should_display_sub_button: sub.should_display_subscription_button}); | ||||
|         compose_not_subscribed_error(new_row, $('#stream_message_recipient_stream')); | ||||
|         return false; | ||||
|     } | ||||
|     } | ||||
|     return true; | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -74,7 +74,7 @@ function message_matches_search_term(message, operator, operand) { | ||||
|     case 'id': | ||||
|         return message.id.toString() === operand; | ||||
|  | ||||
|     case 'stream': | ||||
|     case 'stream': { | ||||
|         if (message.type !== 'stream') { | ||||
|             return false; | ||||
|         } | ||||
| @@ -95,6 +95,7 @@ function message_matches_search_term(message, operator, operand) { | ||||
|         // loaded for a stream that we are no longer | ||||
|         // subscribed to (or that was deleted). | ||||
|         return message.stream.toLowerCase() === operand; | ||||
|     } | ||||
|  | ||||
|     case 'topic': | ||||
|         if (message.type !== 'stream') { | ||||
| @@ -111,7 +112,7 @@ function message_matches_search_term(message, operator, operand) { | ||||
|     case 'sender': | ||||
|         return people.id_matches_email_operand(message.sender_id, operand); | ||||
|  | ||||
|     case 'group-pm-with': | ||||
|     case 'group-pm-with': { | ||||
|         var operand_ids = people.pm_with_operand_ids(operand); | ||||
|         if (!operand_ids) { | ||||
|             return false; | ||||
| @@ -123,23 +124,25 @@ function message_matches_search_term(message, operator, operand) { | ||||
|         return user_ids.indexOf(operand_ids[0]) !== -1; | ||||
|         // We should also check if the current user is in the recipient list (user_ids) of the | ||||
|         // message, but it is implicit by the fact that the current user has access to the message. | ||||
|     } | ||||
|  | ||||
|     case 'pm-with': | ||||
|     case 'pm-with': { | ||||
|         // TODO: use user_ids, not emails here | ||||
|         if (message.type !== 'private') { | ||||
|             return false; | ||||
|         } | ||||
|         operand_ids = people.pm_with_operand_ids(operand); | ||||
|         const operand_ids = people.pm_with_operand_ids(operand); | ||||
|         if (!operand_ids) { | ||||
|             return false; | ||||
|         } | ||||
|         user_ids = people.pm_with_user_ids(message); | ||||
|         const user_ids = people.pm_with_user_ids(message); | ||||
|         if (!user_ids) { | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         return _.isEqual(operand_ids, user_ids); | ||||
|     } | ||||
|     } | ||||
|  | ||||
|     return true; // unknown operators return true (effectively ignored) | ||||
| } | ||||
|   | ||||
| @@ -78,7 +78,7 @@ function do_hashchange_normal(from_reload) { | ||||
|     // be #ABCD. | ||||
|     var hash = window.location.hash.split("/"); | ||||
|     switch (hash[0]) { | ||||
|     case "#narrow": | ||||
|     case "#narrow": { | ||||
|         ui_util.change_tab_to("#home"); | ||||
|         var operators = hash_util.parse_narrow(hash); | ||||
|         if (operators === undefined) { | ||||
| @@ -103,6 +103,7 @@ function do_hashchange_normal(from_reload) { | ||||
|         narrow.activate(operators, narrow_opts); | ||||
|         floating_recipient_bar.update(); | ||||
|         return true; | ||||
|     } | ||||
|     case "": | ||||
|     case "#": | ||||
|         activate_home_tab(); | ||||
|   | ||||
| @@ -749,12 +749,13 @@ exports.process_hotkey = function (e, hotkey) { | ||||
|     case 'toggle_reactions_popover': // ':': open reactions to message | ||||
|         reactions.open_reactions_popover(); | ||||
|         return true; | ||||
|     case 'thumbs_up_emoji': // '+': reacts with thumbs up emoji on selected message | ||||
|     case 'thumbs_up_emoji': { // '+': reacts with thumbs up emoji on selected message | ||||
|         // Use canonical name. | ||||
|         var thumbs_up_emoji_code = '1f44d'; | ||||
|         var canonical_name = emoji_codes.codepoint_to_name[thumbs_up_emoji_code]; | ||||
|         reactions.toggle_emoji_reaction(msg.id, canonical_name); | ||||
|         return true; | ||||
|     } | ||||
|     case 'toggle_mute': | ||||
|         muting_ui.toggle_mute(msg); | ||||
|         return true; | ||||
| @@ -764,11 +765,12 @@ exports.process_hotkey = function (e, hotkey) { | ||||
|     case 'compose_quote_reply': // > : respond to selected message with quote | ||||
|         compose_actions.quote_and_reply({trigger: 'hotkey'}); | ||||
|         return true; | ||||
|     case 'edit_message': | ||||
|     case 'edit_message': { | ||||
|         var row = current_msg_list.get_row(msg.id); | ||||
|         message_edit.start(row); | ||||
|         return true; | ||||
|     } | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
| }; | ||||
|   | ||||
| @@ -122,10 +122,11 @@ function get_custom_profile_field_data(user, field, field_types, dateFormat) { | ||||
|         profile_field.is_user_field = true; | ||||
|         profile_field.value = field_value.value; | ||||
|         break; | ||||
|     case field_types.CHOICE.id: | ||||
|     case field_types.CHOICE.id: { | ||||
|         var field_choice_dict = JSON.parse(field.field_data); | ||||
|         profile_field.value = field_choice_dict[field_value.value].text; | ||||
|         break; | ||||
|     } | ||||
|     case field_types.SHORT_TEXT.id: | ||||
|     case field_types.LONG_TEXT.id: | ||||
|         profile_field.value = field_value.value; | ||||
|   | ||||
| @@ -53,7 +53,7 @@ function get_events_success(events) { | ||||
|     // rarely modified logic for non-normal events. | ||||
|     var dispatch_event = function dispatch_event(event) { | ||||
|         switch (event.type) { | ||||
|         case 'message': | ||||
|         case 'message': { | ||||
|             var msg = event.message; | ||||
|             msg.flags = event.flags; | ||||
|             if (event.local_message_id) { | ||||
| @@ -62,6 +62,7 @@ function get_events_success(events) { | ||||
|             } | ||||
|             messages.push(msg); | ||||
|             break; | ||||
|         } | ||||
|  | ||||
|         case 'pointer': | ||||
|             new_pointer = event.pointer; | ||||
|   | ||||
| @@ -21,7 +21,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         settings_streams.update_default_streams_table(); | ||||
|         break; | ||||
|  | ||||
|     case 'delete_message': | ||||
|     case 'delete_message': { | ||||
|         var msg_id = event.message_id; | ||||
|         // message is passed to unread.get_unread_messages, | ||||
|         // which returns all the unread messages out of a given list. | ||||
| @@ -36,6 +36,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|         ui.remove_message(msg_id); | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     case 'hotspots': | ||||
|         hotspots.load_new(event.hotspots); | ||||
| @@ -58,7 +59,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         activity.update_presence_info(event.email, event.presence, event.server_timestamp); | ||||
|         break; | ||||
|  | ||||
|     case 'restart': | ||||
|     case 'restart': { | ||||
|         var reload_options = { | ||||
|             save_pointer: true, | ||||
|             save_narrow: true, | ||||
| @@ -70,6 +71,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|         reload.initiate(reload_options); | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     case 'reaction': | ||||
|         if (event.op === 'add') { | ||||
| @@ -79,7 +81,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|         break; | ||||
|  | ||||
|     case 'realm': | ||||
|     case 'realm': { | ||||
|         var realm_settings = { | ||||
|             add_emoji_by_admins_only: settings_emoji.update_custom_emoji_ui, | ||||
|             allow_edit_history: noop, | ||||
| @@ -184,6 +186,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|  | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     case 'realm_bot': | ||||
|         if (event.op === 'add') { | ||||
| @@ -221,7 +224,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         settings_linkifiers.populate_filters(page_params.realm_filters); | ||||
|         break; | ||||
|  | ||||
|     case 'realm_domains': | ||||
|     case 'realm_domains': { | ||||
|         var i; | ||||
|         if (event.op === 'add') { | ||||
|             page_params.realm_domains.push(event.realm_domain); | ||||
| @@ -243,6 +246,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|         settings_org.populate_realm_domains(page_params.realm_domains); | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     case 'realm_user': | ||||
|         if (event.op === 'add') { | ||||
| @@ -300,7 +304,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|         break; | ||||
|  | ||||
|     case 'submessage': | ||||
|     case 'submessage': { | ||||
|         // The fields in the event don't quite exactly | ||||
|         // match the layout of a submessage, since there's | ||||
|         // an event id.  We also want to be explicit here. | ||||
| @@ -313,6 +317,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         }; | ||||
|         submessage.handle_event(submsg); | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     case 'subscription': | ||||
|         if (event.op === 'add') { | ||||
| @@ -369,7 +374,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|         break; | ||||
|  | ||||
|     case 'update_display_settings': | ||||
|     case 'update_display_settings': { | ||||
|         var user_display_settings = [ | ||||
|             'default_language', | ||||
|             'demote_inactive_streams', | ||||
| @@ -446,6 +451,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         } | ||||
|         settings_display.update_page(); | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     case 'update_global_notifications': | ||||
|         notifications.handle_global_notification_updates(event.notification_name, | ||||
| @@ -457,7 +463,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|         // (E.g. update_stream_push_notifications). | ||||
|         break; | ||||
|  | ||||
|     case 'update_message_flags': | ||||
|     case 'update_message_flags': { | ||||
|         var new_value = event.operation === "add"; | ||||
|         switch (event.flag) { | ||||
|         case 'starred': | ||||
| @@ -475,6 +481,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { | ||||
|             break; | ||||
|         } | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     case 'user_group': | ||||
|         if (event.op === 'add') { | ||||
|   | ||||
| @@ -113,10 +113,11 @@ exports.options = function (config) { | ||||
|         case 413: // HTTP status "Request Entity Too Large" | ||||
|             msg = i18n.t("Sorry, the file was too large."); | ||||
|             break; | ||||
|         case 400: | ||||
|         case 400: { | ||||
|             var server_message = server_response && server_response.msg; | ||||
|             msg = server_message || i18n.t("An unknown error occurred."); | ||||
|             break; | ||||
|         } | ||||
|         default: | ||||
|             msg = i18n.t("An unknown error occurred."); | ||||
|             break; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user