fixed a crash and updated banner

This commit is contained in:
2026-02-05 16:46:11 +11:00
parent 162caa98b3
commit 82d7ff34ee
3 changed files with 39 additions and 20 deletions

View File

@@ -1,6 +1,9 @@
______ _ _______ __ __ __ $$$$$$\ $$\ $$\ $$\
/_ __/_ __(_) ____(_) /_/ /_ __ __/ /_ $$ __$$\ \__| $$ | \__|
/ / / / / / / / __/ / __/ __ \/ / / / __ \ $$ / \__|$$\ $$$$$$\ $$\ $$\ $$\
/ / / /_/ / / /_/ / / /_/ / / / /_/ / /_/ / $$ |$$$$\ $$ |\_$$ _| $$ | $$ |$$ |
/_/ \__,_/_/\____/_/\__/_/ /_/\__,_/_.___/ $$ |\_$$ |$$ | $$ | $$ | $$ |$$ |
$$ | $$ |$$ | $$ |$$\ $$ | $$ |$$ |
\$$$$$$ |$$ | \$$$$ |\$$$$$$ |$$ |
\______/ \__| \____/ \______/ \__|

View File

@@ -2,6 +2,7 @@ from textual.screen import Screen
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.widgets import Input, Select, LoadingIndicator, Static, DataTable, ContentSwitcher, Tabs, Tab, Button from textual.widgets import Input, Select, LoadingIndicator, Static, DataTable, ContentSwitcher, Tabs, Tab, Button
from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right
from textual import work
from widgets import Navbar from widgets import Navbar
@@ -84,7 +85,8 @@ class RepoViewScreen(Screen):
else: else:
return "\ue5ff" return "\ue5ff"
async def on_mount(self): @work(thread=True, exclusive=True)
def on_mount(self):
files: DataTable = self.query_one("#files") files: DataTable = self.query_one("#files")
loading = self.query_one(LoadingIndicator) loading = self.query_one(LoadingIndicator)
@@ -123,18 +125,31 @@ class RepoViewScreen(Screen):
rows = [] rows = []
commits = requests.get( commit_page_number = 1
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits", page_size = 50
params={
"path": "."
}
).json()
commit_data = {} commit_data = {}
for commit in commits:
commit_data[commit["sha"]] = commit while True:
commits = requests.get(
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
params={
#"path": ".",
"verification": False,
"files": False,
"page": commit_page_number,
"limit": page_size
}
).json()
commit_data.update({commit["sha"]: commit for commit in commits})
if len(commits) == page_size: # we reached end of the page
commit_page_number += 1
else:
break
for file in files_response.json(): for file in files_response.json():
commit = commit_data[file["last_commit_sha"]] commit = commit_data[file["last_commit_sha"]]
commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None) commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None)
@@ -142,7 +157,7 @@ class RepoViewScreen(Screen):
rows.append(( rows.append((
f"[cyan]{self.get_icon_from_name_and_type(file["name"], file["type"] != "file")}[/] {file["name"]}", f"[cyan]{self.get_icon_from_name_and_type(file["name"], file["type"] != "file")}[/] {file["name"]}",
f"[d]{commit["commit"]["message"]}", f"[d]{commit["commit"]["message"]}",
f"Updated {time_delta(datetime.now() - commit_created_at)} ago" f"[d]Updated {time_delta(datetime.now() - commit_created_at)} ago"
)) ))
files.add_rows(rows) files.add_rows(rows)

View File

@@ -1,9 +1,10 @@
from widgets import Navbar
from textual.screen import Screen from textual.screen import Screen
from textual.widgets import Input, Select, LoadingIndicator, Static from textual.widgets import Input, Select, LoadingIndicator, Static
from textual.containers import HorizontalGroup, ScrollableContainer from textual.containers import HorizontalGroup, ScrollableContainer
from textual.app import ComposeResult from textual.app import ComposeResult
from textual import work
from widgets import Navbar
from screens.repo_view_screen import RepoViewScreen from screens.repo_view_screen import RepoViewScreen
from human_readable import time_delta from human_readable import time_delta
@@ -66,7 +67,8 @@ class SearchScreen(Screen):
def action_view_repo(self, author: str, repo_name: str): def action_view_repo(self, author: str, repo_name: str):
self.app.switch_screen(RepoViewScreen(author, repo_name)) self.app.switch_screen(RepoViewScreen(author, repo_name))
def action_search_query(self): @work(exclusive=True)
async def action_search_query(self):
query_input = self.query_one("#query") query_input = self.query_one("#query")
loading = self.query_one(LoadingIndicator) loading = self.query_one(LoadingIndicator)
results = self.query_one(ScrollableContainer) results = self.query_one(ScrollableContainer)
@@ -92,7 +94,6 @@ class SearchScreen(Screen):
# display results # display results
results.remove_children(SearchResult) results.remove_children(SearchResult)
to_mount = [] to_mount = []
print(response.json())
for result in response.json()["data"]: for result in response.json()["data"]:
to_mount.append(SearchResult(result)) to_mount.append(SearchResult(result))
results.mount_all(to_mount) results.mount_all(to_mount)