mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	shared: Describe interface of typing_status in Flow.
This allows the mobile app to stay well-typed while using this code.
This commit is contained in:
		| @@ -30,8 +30,10 @@ var TYPING_STOPPED_WAIT_PERIOD = 5000; // 5s | ||||
|     appropriately.) | ||||
| */ | ||||
|  | ||||
| /** Exported only for tests. */ | ||||
| export const state = {}; | ||||
|  | ||||
| /** Exported only for tests. */ | ||||
| export function initialize_state() { | ||||
|     state.current_recipient =  undefined; | ||||
|     state.next_send_start_time =  undefined; | ||||
| @@ -40,6 +42,7 @@ export function initialize_state() { | ||||
|  | ||||
| initialize_state(); | ||||
|  | ||||
| /** Exported only for tests. */ | ||||
| export function stop_last_notification(worker) { | ||||
|     if (state.idle_timer) { | ||||
|         clearTimeout(state.idle_timer); | ||||
| @@ -48,6 +51,7 @@ export function stop_last_notification(worker) { | ||||
|     initialize_state(); | ||||
| } | ||||
|  | ||||
| /** Exported only for tests. */ | ||||
| export function start_or_extend_idle_timer(worker) { | ||||
|     function on_idle_timeout() { | ||||
|         // We don't do any real error checking here, because | ||||
| @@ -75,6 +79,7 @@ function actually_ping_server(worker, recipient, current_time) { | ||||
|     set_next_start_time(current_time); | ||||
| } | ||||
|  | ||||
| /** Exported only for tests. */ | ||||
| export function maybe_ping_server(worker, recipient) { | ||||
|     var current_time = worker.get_current_time(); | ||||
|     if (current_time > state.next_send_start_time) { | ||||
|   | ||||
							
								
								
									
										19
									
								
								static/shared/js/typing_status.js.flow
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								static/shared/js/typing_status.js.flow
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| /** | ||||
|  * @flow strict | ||||
|  */ | ||||
|  | ||||
| "use strict"; | ||||
|  | ||||
| type RecipientUserIds = number[]; | ||||
|  | ||||
| type Worker = {| | ||||
|   get_recipient: () => RecipientUserIds | void, | ||||
|   is_valid_conversation: (RecipientUserIds | void) => boolean, | ||||
|   get_current_time: () => number, // as ms since epoch | ||||
|   notify_server_start: RecipientUserIds => void, | ||||
|   notify_server_stop: RecipientUserIds => void | ||||
| |}; | ||||
|  | ||||
| declare export function handle_text_input(Worker): void; | ||||
|  | ||||
| declare export function stop(Worker): void; | ||||
		Reference in New Issue
	
	Block a user