fixed a crash and updated banner
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
|
||||
______ _ _______ __ __ __
|
||||
/_ __/_ __(_) ____(_) /_/ /_ __ __/ /_
|
||||
/ / / / / / / / __/ / __/ __ \/ / / / __ \
|
||||
/ / / /_/ / / /_/ / / /_/ / / / /_/ / /_/ /
|
||||
/_/ \__,_/_/\____/_/\__/_/ /_/\__,_/_.___/
|
||||
$$$$$$\ $$\ $$\ $$\
|
||||
$$ __$$\ \__| $$ | \__|
|
||||
$$ / \__|$$\ $$$$$$\ $$\ $$\ $$\
|
||||
$$ |$$$$\ $$ |\_$$ _| $$ | $$ |$$ |
|
||||
$$ |\_$$ |$$ | $$ | $$ | $$ |$$ |
|
||||
$$ | $$ |$$ | $$ |$$\ $$ | $$ |$$ |
|
||||
\$$$$$$ |$$ | \$$$$ |\$$$$$$ |$$ |
|
||||
\______/ \__| \____/ \______/ \__|
|
||||
@@ -2,6 +2,7 @@ from textual.screen import Screen
|
||||
from textual.app import ComposeResult
|
||||
from textual.widgets import Input, Select, LoadingIndicator, Static, DataTable, ContentSwitcher, Tabs, Tab, Button
|
||||
from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right
|
||||
from textual import work
|
||||
|
||||
from widgets import Navbar
|
||||
|
||||
@@ -84,7 +85,8 @@ class RepoViewScreen(Screen):
|
||||
else:
|
||||
return "\ue5ff"
|
||||
|
||||
async def on_mount(self):
|
||||
@work(thread=True, exclusive=True)
|
||||
def on_mount(self):
|
||||
files: DataTable = self.query_one("#files")
|
||||
loading = self.query_one(LoadingIndicator)
|
||||
|
||||
@@ -123,18 +125,31 @@ class RepoViewScreen(Screen):
|
||||
|
||||
|
||||
rows = []
|
||||
commit_page_number = 1
|
||||
page_size = 50
|
||||
commit_data = {}
|
||||
|
||||
while True:
|
||||
commits = requests.get(
|
||||
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
|
||||
params={
|
||||
"path": "."
|
||||
#"path": ".",
|
||||
"verification": False,
|
||||
"files": False,
|
||||
"page": commit_page_number,
|
||||
"limit": page_size
|
||||
}
|
||||
).json()
|
||||
commit_data = {}
|
||||
for commit in commits:
|
||||
commit_data[commit["sha"]] = commit
|
||||
|
||||
|
||||
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():
|
||||
|
||||
commit = commit_data[file["last_commit_sha"]]
|
||||
|
||||
commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None)
|
||||
@@ -142,7 +157,7 @@ class RepoViewScreen(Screen):
|
||||
rows.append((
|
||||
f"[cyan]{self.get_icon_from_name_and_type(file["name"], file["type"] != "file")}[/] {file["name"]}",
|
||||
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)
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from widgets import Navbar
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Input, Select, LoadingIndicator, Static
|
||||
from textual.containers import HorizontalGroup, ScrollableContainer
|
||||
from textual.app import ComposeResult
|
||||
from textual import work
|
||||
|
||||
from widgets import Navbar
|
||||
from screens.repo_view_screen import RepoViewScreen
|
||||
|
||||
from human_readable import time_delta
|
||||
@@ -66,7 +67,8 @@ class SearchScreen(Screen):
|
||||
def action_view_repo(self, author: str, repo_name: str):
|
||||
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")
|
||||
loading = self.query_one(LoadingIndicator)
|
||||
results = self.query_one(ScrollableContainer)
|
||||
@@ -92,7 +94,6 @@ class SearchScreen(Screen):
|
||||
# display results
|
||||
results.remove_children(SearchResult)
|
||||
to_mount = []
|
||||
print(response.json())
|
||||
for result in response.json()["data"]:
|
||||
to_mount.append(SearchResult(result))
|
||||
results.mount_all(to_mount)
|
||||
|
||||
Reference in New Issue
Block a user