mirror of
https://github.com/snowfallorg/nix-software-center.git
synced 2024-09-11 21:27:09 +03:00
Speed up category page
This commit is contained in:
parent
ee0c62b3da
commit
f414005ba5
@ -165,19 +165,28 @@ impl Component for CategoryPageModel {
|
||||
let mut recapps_guard = self.recommendedapps.guard();
|
||||
recapps_guard.clear();
|
||||
recapps_guard.drop();
|
||||
for app in catrec {
|
||||
sender.oneshot_command(async move {
|
||||
CategoryPageAsyncMsg::PushRec(app)
|
||||
});
|
||||
}
|
||||
let mut apps_guard = self.apps.guard();
|
||||
apps_guard.clear();
|
||||
apps_guard.drop();
|
||||
for app in catall {
|
||||
sender.oneshot_command(async move {
|
||||
CategoryPageAsyncMsg::Push(app)
|
||||
});
|
||||
}
|
||||
|
||||
sender.command(|out, shutdown| {
|
||||
shutdown.register(async move {
|
||||
for app in catrec {
|
||||
out.send(CategoryPageAsyncMsg::PushRec(app));
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(5)).await;
|
||||
}
|
||||
}).drop_on_shutdown()
|
||||
});
|
||||
|
||||
sender.command(|out, shutdown| {
|
||||
shutdown.register(async move {
|
||||
for app in catall {
|
||||
out.send(CategoryPageAsyncMsg::Push(app));
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(5)).await;
|
||||
}
|
||||
}).drop_on_shutdown()
|
||||
});
|
||||
|
||||
self.busy = false;
|
||||
info!("DONE CategoryPageMsg::Open");
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ pub struct PkgModel {
|
||||
installedsystempkgs: HashSet<String>,
|
||||
|
||||
workqueue: HashSet<WorkPkg>,
|
||||
visible: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
|
||||
@ -230,6 +231,8 @@ impl Component for PkgModel {
|
||||
set_hexpand: true,
|
||||
set_hscrollbar_policy: gtk::PolicyType::Never,
|
||||
set_vscrollbar_policy: gtk::PolicyType::Automatic,
|
||||
#[track(model.changed(PkgModel::visible()) && !self.visible)]
|
||||
set_vadjustment: gtk::Adjustment::NONE,
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
adw::Clamp {
|
||||
@ -616,7 +619,6 @@ impl Component for PkgModel {
|
||||
set_homogeneous: true,
|
||||
set_row_spacing: 5,
|
||||
set_column_spacing: 4,
|
||||
// set_margin_all: 15,
|
||||
set_selection_mode: gtk::SelectionMode::None,
|
||||
set_max_children_per_line: 2,
|
||||
append = >k::FlowBoxChild {
|
||||
@ -959,13 +961,11 @@ impl Component for PkgModel {
|
||||
maintainers: vec![],
|
||||
installeduserpkgs: HashSet::new(),
|
||||
installedsystempkgs: HashSet::new(),
|
||||
// installinguserpkgs: HashSet::new(),
|
||||
// installingsystempkgs: HashSet::new(),
|
||||
// removinguserpkgs: HashSet::new(),
|
||||
syspkgtype: initparams.syspkgs,
|
||||
userpkgtype: initparams.userpkgs,
|
||||
workqueue: HashSet::new(),
|
||||
launchable: None,
|
||||
visible: false,
|
||||
tracker: 0,
|
||||
};
|
||||
|
||||
@ -1050,6 +1050,7 @@ impl Component for PkgModel {
|
||||
self.installworker.emit(InstallAsyncHandlerMsg::SetPkgTypes(syspkgs, userpkgs));
|
||||
}
|
||||
PkgMsg::Open(pkgmodel) => {
|
||||
self.set_visible(true);
|
||||
self.set_pkg(pkgmodel.pkg);
|
||||
self.set_name(pkgmodel.name);
|
||||
self.set_icon(pkgmodel.icon);
|
||||
@ -1123,22 +1124,6 @@ impl Component for PkgModel {
|
||||
}
|
||||
|
||||
self.homepage = pkgmodel.homepage;
|
||||
// if let Some(h) = pkgmodel.homepage {
|
||||
// match h {
|
||||
// StrOrVec::Single(h) => {
|
||||
// self.homepage = Some(h.to_string());
|
||||
// }
|
||||
// StrOrVec::List(h) => {
|
||||
// if let Some(first) = h.get(0) {
|
||||
// self.homepage = Some(first.to_string());
|
||||
// } else {
|
||||
// self.homepage = None;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// self.homepage = None;
|
||||
// }
|
||||
|
||||
if pkgmodel.screenshots.len() <= 1 {
|
||||
self.carpage = CarouselPage::Single;
|
||||
@ -1197,7 +1182,6 @@ impl Component for PkgModel {
|
||||
let mut content = Cursor::new(b);
|
||||
if std::io::copy(&mut content, &mut file).is_ok() {
|
||||
fn openimg(scrnpath: &str) -> Result<(), Box<dyn Error>> {
|
||||
// let mut reader = Reader::new(Cursor::new(imgdata.buffer())).with_guessed_format().expect("Cursor io never fails");
|
||||
let img = if let Ok(x) = image::load(BufReader::new(File::open(scrnpath)?), image::ImageFormat::Png) {
|
||||
x
|
||||
} else if let Ok(x) = image::load(BufReader::new(File::open(scrnpath)?), image::ImageFormat::Jpeg) {
|
||||
@ -1296,6 +1280,7 @@ impl Component for PkgModel {
|
||||
// self.icon = None;
|
||||
// let mut scrn_guard = self.screenshots.guard();
|
||||
// scrn_guard.clear();
|
||||
self.set_visible(false);
|
||||
sender.output(AppMsg::FrontPage)
|
||||
}
|
||||
PkgMsg::InstallUser => {
|
||||
@ -1390,9 +1375,7 @@ impl Component for PkgModel {
|
||||
PkgAction::Remove => {
|
||||
self.installedsystempkgs.remove(&work.pkg);
|
||||
}
|
||||
};
|
||||
// sender.output(AppMsg::UpdateUpdatePkgs);
|
||||
// sender.output(AppMsg::UpdateInstalledPkgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.output(AppMsg::UpdateInstalledPkgs);
|
||||
|
@ -16,10 +16,8 @@ pub struct SearchPageModel {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum SearchPageMsg {
|
||||
Open,
|
||||
Search(Vec<SearchItem>),
|
||||
UpdateInstalled(HashSet<String>, HashSet<String>),
|
||||
Close,
|
||||
OpenRow(gtk::ListBoxRow)
|
||||
}
|
||||
|
||||
@ -82,8 +80,6 @@ impl SimpleComponent for SearchPageModel {
|
||||
searchitem_guard.drop();
|
||||
self.update_searchitemtracker(|_| ());
|
||||
}
|
||||
SearchPageMsg::Open => {}
|
||||
SearchPageMsg::Close => {}
|
||||
SearchPageMsg::OpenRow(row) => {
|
||||
let searchitem_guard = self.searchitems.guard();
|
||||
for (i, child) in searchitem_guard.widget().iter_children().enumerate() {
|
||||
|
@ -1259,7 +1259,7 @@ FROM pkgs JOIN meta ON (pkgs.attribute = meta.attribute) WHERE pkgs.attribute =
|
||||
.await
|
||||
.unwrap();
|
||||
let (description,): (String,) = sqlx::query_as(
|
||||
"SELECT description FROM meta WHERE attribute LIKE $1",
|
||||
"SELECT description FROM meta WHERE attribute = $1",
|
||||
)
|
||||
.bind(installedpkg)
|
||||
.fetch_one(pool)
|
||||
@ -1289,7 +1289,6 @@ FROM pkgs JOIN meta ON (pkgs.attribute = meta.attribute) WHERE pkgs.attribute =
|
||||
}
|
||||
}
|
||||
}
|
||||
// if let Some(item) = self.pkgitems.get(installedpkg) {
|
||||
installeduseritems.push(InstalledItem {
|
||||
name: name.to_string(),
|
||||
pname: pname.to_string(),
|
||||
@ -1500,16 +1499,13 @@ FROM pkgs JOIN meta ON (pkgs.attribute = meta.attribute) WHERE pkgs.attribute =
|
||||
info!("AppMsg::Search");
|
||||
debug!("Searching for: {}", search);
|
||||
self.viewstack.set_visible_child_name("search");
|
||||
self.searchpage.emit(SearchPageMsg::Open);
|
||||
self.set_searchquery(search.to_string());
|
||||
// // let pkgitems: Vec<PkgItem> = self.pkgitems.values().cloned().collect();
|
||||
let installeduserpkgs = self.installeduserpkgs.clone();
|
||||
let installedsystempkgs = self.installedsystempkgs.clone();
|
||||
let userpkgtype = self.userpkgtype.clone();
|
||||
let pkgdb = self.pkgdb.clone();
|
||||
let appdata = self.appdata.clone();
|
||||
sender.command(move |out, shutdown| {
|
||||
// let pkgs = pkgitems.clone();
|
||||
let search = search.clone();
|
||||
let installeduserpkgs = installeduserpkgs.clone();
|
||||
let installedsystempkgs = installedsystempkgs;
|
||||
@ -1579,8 +1575,8 @@ FROM pkgs JOIN meta ON (pkgs.attribute = meta.attribute) WHERE pkgs.attribute =
|
||||
}
|
||||
}
|
||||
outpkgs.sort_by(|a, b| {
|
||||
let mut aleft = a.pkg.to_lowercase();
|
||||
let mut bleft = b.pkg.to_lowercase();
|
||||
let mut aleft = a.name.to_lowercase() + &a.pkg.to_lowercase();
|
||||
let mut bleft = b.name.to_lowercase() + &b.pkg.to_lowercase();
|
||||
for q in searchsplit.iter() {
|
||||
let q = &q.to_lowercase();
|
||||
if aleft.contains(q) {
|
||||
@ -1594,8 +1590,8 @@ FROM pkgs JOIN meta ON (pkgs.attribute = meta.attribute) WHERE pkgs.attribute =
|
||||
bleft.push_str(q);
|
||||
}
|
||||
}
|
||||
let mut apoints = aleft.len();
|
||||
let mut bpoints = bleft.len();
|
||||
let mut apoints = aleft.len() + 5;
|
||||
let mut bpoints = bleft.len() + 5;
|
||||
// for q in searchsplit.iter() {
|
||||
// if a.name.contains(q) {
|
||||
// apoints -= 1;
|
||||
@ -1604,11 +1600,11 @@ FROM pkgs JOIN meta ON (pkgs.attribute = meta.attribute) WHERE pkgs.attribute =
|
||||
// bpoints -= 1;
|
||||
// }
|
||||
// }
|
||||
if a.icon.is_some() {
|
||||
apoints -= 3;
|
||||
if appdata.get(&a.pkg).is_some() {
|
||||
apoints -= 5;
|
||||
}
|
||||
if b.icon.is_some() {
|
||||
bpoints -= 3;
|
||||
if appdata.get(&b.pkg).is_some() {
|
||||
bpoints -= 5;
|
||||
}
|
||||
apoints.cmp(&bpoints)
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user