mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 13:14:17 +02:00
app suggenstions when no app is installed
This commit is contained in:
@@ -137,3 +137,18 @@ class SnapManager(ApplicationManager):
|
||||
def list_warnings(self) -> List[str]:
|
||||
if snap.get_snapd_version() == 'unavailable':
|
||||
return [self.locale_keys['snap.notification.snapd_unavailable']]
|
||||
|
||||
def list_suggestions(self, limit: int) -> List[SnapApplication]:
|
||||
|
||||
suggestions = []
|
||||
|
||||
if limit != 0:
|
||||
for name in ('whatsdesk', 'slack', 'yakyak', 'instagraph', 'eclipse', 'gimp', 'supertuxkart'):
|
||||
res = snap.search(name, exact_name=True)
|
||||
if res:
|
||||
suggestions.append(self.map_json(res[0], installed=False, disk_loader=None))
|
||||
|
||||
if len(suggestions) == limit:
|
||||
break
|
||||
|
||||
return suggestions
|
||||
|
||||
@@ -86,7 +86,7 @@ def read_installed() -> List[dict]:
|
||||
return apps
|
||||
|
||||
|
||||
def search(word: str) -> List[dict]:
|
||||
def search(word: str, exact_name: bool = False) -> List[dict]:
|
||||
apps = []
|
||||
|
||||
res = system.run_cmd('{} find "{}"'.format(BASE_CMD, word), print_error=False)
|
||||
@@ -98,6 +98,10 @@ def search(word: str) -> List[dict]:
|
||||
for idx, app_str in enumerate(res):
|
||||
if idx > 0 and app_str:
|
||||
app_data = [word for word in app_str.split(' ') if word]
|
||||
|
||||
if exact_name and app_data[0] != word:
|
||||
continue
|
||||
|
||||
apps.append({
|
||||
'name': app_data[0],
|
||||
'version': app_data[1],
|
||||
@@ -109,6 +113,9 @@ def search(word: str) -> List[dict]:
|
||||
'type': None
|
||||
})
|
||||
|
||||
if exact_name and len(apps) > 0:
|
||||
break
|
||||
|
||||
return apps
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user