mirror of
https://github.com/vrc-get/vrc-get.git
synced 2026-06-21 09:58:08 +00:00
refactor: clean up issues found in branch review
- vpm: drop unused id-based reorder_user_repos; reorder_user_repos_by_indices is the only caller - CHANGELOG: reflect the actual public API surface (reorder_user_repos_by_indices, remove_repo_at_index) - gui: rollback optimistic delete on error in RemoveRepositoryDialog, matching setHideRepository - gui: demote per-reorder log from info to debug to reduce noise
This commit is contained in:
parent
1a947b7a6c
commit
334492e5c6
5 changed files with 8 additions and 18 deletions
|
|
@ -8,7 +8,8 @@ The format is based on [Keep a Changelog].
|
|||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Add `reorder_user_repos` to reorder `userRepos` in `settings.json`
|
||||
- Add `reorder_user_repos_by_indices` to reorder `userRepos` in `settings.json`
|
||||
- Add `remove_repo_at_index` to remove a specific entry from `userRepos` in `settings.json`
|
||||
|
||||
### Changed
|
||||
- Improved saving interacting with setting files `#2485` `#2710`
|
||||
|
|
|
|||
|
|
@ -847,6 +847,11 @@ function RemoveRepositoryDialog({
|
|||
),
|
||||
});
|
||||
}
|
||||
return data;
|
||||
},
|
||||
onError: (e, _index, ctx) => {
|
||||
queryClient.setQueryData(environmentRepositoriesInfo.queryKey, ctx);
|
||||
toastThrownError(e);
|
||||
},
|
||||
onSettled: () => queryClient.invalidateQueries(environmentRepositoriesInfo),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ pub async fn environment_reorder_repositories(
|
|||
indices: Vec<usize>,
|
||||
) -> Result<(), RustError> {
|
||||
let mut settings = settings.load_mut(io.inner()).await?;
|
||||
log::info!("reorder user repositories by indices: {:?}", indices);
|
||||
log::debug!("reorder user repositories by indices: {:?}", indices);
|
||||
settings.reorder_user_repos_by_indices(&indices);
|
||||
settings.save().await?;
|
||||
packages.clear_cache();
|
||||
|
|
|
|||
|
|
@ -269,10 +269,6 @@ impl Settings {
|
|||
self.vpm.retain_user_repos(|x| !condition(x))
|
||||
}
|
||||
|
||||
pub fn reorder_user_repos(&mut self, ids: &[&str]) {
|
||||
self.vpm.reorder_user_repos(ids);
|
||||
}
|
||||
|
||||
pub fn remove_repo_at_index(&mut self, index: usize) -> Option<UserRepoSetting> {
|
||||
self.vpm.remove_user_repo_at_index(index)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,18 +155,6 @@ impl VpmSettings {
|
|||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
pub fn reorder_user_repos(&mut self, ids: &[&str]) {
|
||||
let mut repos = std::mem::take(&mut self.parsed.user_repos);
|
||||
let mut result = Vec::with_capacity(repos.len());
|
||||
for id in ids {
|
||||
if let Some(pos) = repos.iter().position(|r| r.id() == Some(id)) {
|
||||
result.push(repos.remove(pos));
|
||||
}
|
||||
}
|
||||
result.append(&mut repos);
|
||||
self.parsed.user_repos = result;
|
||||
}
|
||||
|
||||
pub fn remove_user_repo_at_index(&mut self, index: usize) -> Option<UserRepoSetting> {
|
||||
let repos = &mut self.parsed.user_repos;
|
||||
if index < repos.len() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue