mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-30 19:43:47 +00:00 
			
		
		
		
	This breaks an indirect dependency of stream_data on the channel module. It's a verbatim code move, apart from the one-line helper `has_history_for`. It's not totally clear to me why the original code doesn't call into `is_complete_for_stream_id` to early-exit, but figuring that out is outside the scope of my change. It's possible that we will eventually just subsume this tiny module into topic_list once we finish breaking all dependencies, but we may want to reuse this for something like Recent Topics or other similar UIs. It's also possible that we'll want to rename stream_topic_history -> stream_topic_history_data sometime soon, possibly after we clean up its dependency on message_util soon.
		
			
				
	
	
		
			22 lines
		
	
	
		
			568 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			568 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import * as channel from "./channel";
 | |
| import * as stream_topic_history from "./stream_topic_history";
 | |
| 
 | |
| export function get_server_history(stream_id, on_success) {
 | |
|     if (stream_topic_history.has_history_for(stream_id)) {
 | |
|         on_success();
 | |
|         return;
 | |
|     }
 | |
| 
 | |
|     const url = "/json/users/me/" + stream_id + "/topics";
 | |
| 
 | |
|     channel.get({
 | |
|         url,
 | |
|         data: {},
 | |
|         success(data) {
 | |
|             const server_history = data.topics;
 | |
|             stream_topic_history.add_history(stream_id, server_history);
 | |
|             on_success();
 | |
|         },
 | |
|     });
 | |
| }
 |