Skip to content

Commit

Permalink
fixed not adding new apps
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalraja committed Feb 23, 2024
1 parent b75ed37 commit 063cd04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/app_drawer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class AppDrawerState extends State<AppDrawerPage> with WidgetsBindingObserver {
int? categoryId = await Util.platform.invokeMethod(
'getParam', <String, dynamic>{'key': 'category_id', 'type': 'int'});
debugPrint('_checkCategoryParam: ' + categoryId.toString());
if (categoryId == 0) {
if (categoryId == 0 || categoryId == null && _selectedCategory != null) {
return; // didn't do anything
}
// Reset stuff when it's coming from category shortcut
Expand Down
12 changes: 9 additions & 3 deletions lib/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ class DBProvider {
// Update or insert built-in categories
upsertCategories(mixedCategories, cats, batch, CategoryItem.TYPE_MIXED);
upsertCategories(packageCategories, cats, batch, CategoryItem.TYPE_PACKAGE);
if (!initialImport)
await batch.commit(noResult: false);

apps.forEach((app) async {
if (packages.containsKey(app.packageName)) {
Expand All @@ -684,19 +686,23 @@ class DBProvider {
hidden: false,
launchCount: 0,
lastLaunch: 0);
batch.insert(tableAppItem, appItem.toMap());
if (initialImport)
batch.insert(tableAppItem, appItem.toMap());
else
await db.insert(tableAppItem, appItem.toMap());
}
});
if (initialImport)
await batch.commit(noResult: false);

if (packages.length > 0) {
// some apps have been uninstalled let's delete it from database
hasChanged = true;
var packageIds = "'" + packages.keys.join("','") + "'";
batch.rawDelete(
await db.rawDelete(
'DELETE FROM $tableAppItem WHERE $columnAppItemPackage IN ($packageIds)');
packages.clear();
}
await batch.commit(noResult: false);

// Get all apps with category_id NULL
rows = await db.rawQuery("""
Expand Down

0 comments on commit 063cd04

Please sign in to comment.