(&mut self, cmd_id: CommandId, cx: &mut Context<Self>)
| 1699 | |
| 1700 | fn destination_options(entries: Vec<CollectionDestinationEntry>) -> Vec<DestinationOption> { |
| 1701 | entries |
| 1702 | .into_iter() |
| 1703 | .map(|entry| DestinationOption { |
| 1704 | destination: entry.destination, |
| 1705 | label: entry.label, |
| 1706 | }) |
| 1707 | .collect() |
| 1708 | } |
| 1709 | |
| 1710 | fn active_tab(&self) -> Option<&TabState> { |
| 1711 | self.tabs.get(self.active_tab_index) |
| 1712 | } |
| 1713 | |
| 1714 | fn cancel_in_flight_for_tab(&mut self, index: usize, cx: &mut Context<Self>) { |
| 1715 | let Some(tab) = self.tabs.get_mut(index) else { |
| 1716 | return; |
| 1717 | }; |
| 1718 | match &mut tab.content { |
| 1719 | TabContent::Request { |
| 1720 | request, |
| 1721 | response, |
| 1722 | in_flight_request, |
| 1723 | request_generation, |
| 1724 | .. |
| 1725 | } => { |
| 1726 | if let Some(mut in_flight) = in_flight_request.take() { |
| 1727 | let _ = in_flight.cancel(); |
| 1728 | request_generation.advance(); |
| 1729 | request.update(cx, |req, cx| req.set_sending(false, cx)); |
| 1730 | response.update(cx, |resp, cx| resp.set_cancelled(cx)); |
| 1731 | } |
| 1732 | } |
| 1733 | TabContent::WebSocket { view } => { |
| 1734 | view.update(cx, |v, cx| v.terminate(cx)); |
| 1735 | } |
| 1736 | TabContent::Environment { .. } => {} |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | /// Open a WebSocket tab with the given configuration. |
| 1741 | pub fn open_websocket_tab( |
| 1742 | &mut self, |
| 1743 | request: WebSocketRequestData, |
| 1744 | tab_name: String, |
| 1745 | collection_id: Option<Uuid>, |
| 1746 | _window: &mut Window, |
| 1747 | cx: &mut Context<Self>, |
| 1748 | ) { |
| 1749 | self.open_websocket_tab_with_history(request, None, tab_name, collection_id, _window, cx); |
| 1750 | } |
| 1751 | |
| 1752 | fn open_websocket_tab_with_history( |
| 1753 | &mut self, |
| 1754 | request: WebSocketRequestData, |
| 1755 | initial_history: Option<WebSocketHistoryResult>, |
| 1756 | tab_name: String, |
| 1757 | collection_id: Option<Uuid>, |
| 1758 | _window: &mut Window, |
no test coverage detected