| 1 | use gpui_kit::*; |
| 2 | |
| 3 | #[derive(Clone, Copy)] |
| 4 | pub struct RenderHooks { |
| 5 | pub open_profile_link: fn(&str, Point<Pixels>, &mut App) -> bool, |
| 6 | pub jump_to_quoted: fn(String, &mut App), |
| 7 | } |
| 8 | |
| 9 | impl Global for RenderHooks {} |
| 10 | |
| 11 | pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bool { |
| 12 | match cx.try_global::<RenderHooks>().copied() { |
| 13 | Some(hooks) => (hooks.open_profile_link)(url, position, cx), |
| 14 | None => false, |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | pub fn jump_to_quoted(message_id: String, cx: &mut App) { |
| 19 | if let Some(hooks) = cx.try_global::<RenderHooks>().copied() { |
| 20 | (hooks.jump_to_quoted)(message_id, cx); |
| 21 | } |
| 22 | } |