refactor: consolidate shared ui helpers and prune unused code
This commit is contained in:
@@ -56,49 +56,6 @@ pub(crate) struct SwitchRepository {
|
||||
#[action(namespace = signed, no_json)]
|
||||
pub(crate) struct CreateRepository;
|
||||
|
||||
pub(crate) fn bind_repository_shortcuts(cx: &mut App) {
|
||||
let context = match KeyBindingContextPredicate::parse(REPOSITORY_KEY_CONTEXT) {
|
||||
Ok(context) => Some(Rc::new(context)),
|
||||
Err(error) => {
|
||||
log::error!("failed to parse repository key context: {error}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let bindings = REPOSITORY_KEYSTROKES
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(index, keystroke)| {
|
||||
KeyBinding::load(
|
||||
keystroke,
|
||||
Box::new(SwitchRepository { index }),
|
||||
context.clone(),
|
||||
false,
|
||||
None,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.chain(std::iter::once(KeyBinding::load(
|
||||
CREATE_KEYSTROKE,
|
||||
Box::new(CreateRepository),
|
||||
context.clone(),
|
||||
false,
|
||||
None,
|
||||
cx,
|
||||
)))
|
||||
.collect::<Result<Vec<_>, _>>();
|
||||
|
||||
let bindings = match bindings {
|
||||
Ok(bindings) => bindings,
|
||||
Err(error) => {
|
||||
log::error!("failed to parse repository shortcut keystrokes: {error}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
cx.bind_keys(bindings);
|
||||
}
|
||||
|
||||
pub struct TitlebarView {
|
||||
weak: WeakEntity<Self>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
@@ -626,3 +583,46 @@ fn local_key(entry: &ResolvedLocalRepo) -> SharedString {
|
||||
None => SharedString::from(format!("repo-local:{}", entry.path.display())),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn bind_repository_shortcuts(cx: &mut App) {
|
||||
let context = match KeyBindingContextPredicate::parse(REPOSITORY_KEY_CONTEXT) {
|
||||
Ok(context) => Some(Rc::new(context)),
|
||||
Err(error) => {
|
||||
log::error!("failed to parse repository key context: {error}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let bindings = REPOSITORY_KEYSTROKES
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(index, keystroke)| {
|
||||
KeyBinding::load(
|
||||
keystroke,
|
||||
Box::new(SwitchRepository { index }),
|
||||
context.clone(),
|
||||
false,
|
||||
None,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.chain(std::iter::once(KeyBinding::load(
|
||||
CREATE_KEYSTROKE,
|
||||
Box::new(CreateRepository),
|
||||
context.clone(),
|
||||
false,
|
||||
None,
|
||||
cx,
|
||||
)))
|
||||
.collect::<Result<Vec<_>, _>>();
|
||||
|
||||
let bindings = match bindings {
|
||||
Ok(bindings) => bindings,
|
||||
Err(error) => {
|
||||
log::error!("failed to parse repository shortcut keystrokes: {error}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
cx.bind_keys(bindings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user