Fix new cm tab not replace the old persisted tab (#9127)
* This happens when after changing DesktopTab to StatefulWidget, 1.2.7 and 1.3.0 have this problem. * When `addConnection` in server_model.dart is called, the old closed client is removed, the client parameter of buildConnectionCard is new, but client id inside Consumer is old. * The only state in cm page is timer, its value is kept in test. * There may be a better way to solve the ui update. Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
		
							parent
							
								
									8745fcbb6a
								
							
						
					
					
						commit
						f34b8411a7
					
				| @ -552,6 +552,13 @@ class _DesktopTabState extends State<DesktopTab> | |||||||
|             controller: state.value.pageController, |             controller: state.value.pageController, | ||||||
|             physics: NeverScrollableScrollPhysics(), |             physics: NeverScrollableScrollPhysics(), | ||||||
|             children: () { |             children: () { | ||||||
|  |               if (DesktopTabType.cm == tabType) { | ||||||
|  |                 // Fix when adding a new tab still showing closed tabs with the same peer id, which would happen after the DesktopTab was stateful. | ||||||
|  |                 return state.value.tabs.map((tab) { | ||||||
|  |                   return tab.page; | ||||||
|  |                 }).toList(); | ||||||
|  |               } | ||||||
|  | 
 | ||||||
|               /// to-do refactor, separate connection state and UI state for remote session. |               /// to-do refactor, separate connection state and UI state for remote session. | ||||||
|               /// [workaround] PageView children need an immutable list, after it has been passed into PageView |               /// [workaround] PageView children need an immutable list, after it has been passed into PageView | ||||||
|               final tabLen = state.value.tabs.length; |               final tabLen = state.value.tabs.length; | ||||||
|  | |||||||
| @ -826,7 +826,7 @@ class Client { | |||||||
|   Map<String, dynamic> toJson() { |   Map<String, dynamic> toJson() { | ||||||
|     final Map<String, dynamic> data = <String, dynamic>{}; |     final Map<String, dynamic> data = <String, dynamic>{}; | ||||||
|     data['id'] = id; |     data['id'] = id; | ||||||
|     data['is_start'] = authorized; |     data['authorized'] = authorized; | ||||||
|     data['is_file_transfer'] = isFileTransfer; |     data['is_file_transfer'] = isFileTransfer; | ||||||
|     data['port_forward'] = portForward; |     data['port_forward'] = portForward; | ||||||
|     data['name'] = name; |     data['name'] = name; | ||||||
| @ -840,6 +840,8 @@ class Client { | |||||||
|     data['block_input'] = blockInput; |     data['block_input'] = blockInput; | ||||||
|     data['disconnected'] = disconnected; |     data['disconnected'] = disconnected; | ||||||
|     data['from_switch'] = fromSwitch; |     data['from_switch'] = fromSwitch; | ||||||
|  |     data['in_voice_call'] = inVoiceCall; | ||||||
|  |     data['incoming_voice_call'] = incomingVoiceCall; | ||||||
|     return data; |     return data; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user