diff --git a/lib/graphql/github.graphql b/lib/graphql/github.graphql index e73b310..a23083b 100644 --- a/lib/graphql/github.graphql +++ b/lib/graphql/github.graphql @@ -61,11 +61,11 @@ query Gists($login: String!, $after: String) { # single gist query Gist($login: String!, $name: String!) { - user(login:$login) { + user(login: $login) { gist(name: $name) { name files { - name + name language { name } @@ -148,7 +148,7 @@ fragment ReposRepoItem on Repository { updatedAt } query Repos($login: String!, $after: String) { - user(login: $login) { + repositoryOwner(login: $login) { repositories( first: 30 after: $after @@ -1061,8 +1061,12 @@ query Issue($owner: String!, $name: String!, $number: Int!, $cursor: String) { # Releases query Releases($name: String!, $owner: String!, $cursor: String) { - repository(name: $name, owner: $owner) { - releases(first: 30, after: $cursor, orderBy: { field: CREATED_AT, direction:DESC }) { + repository(name: $name, owner: $owner) { + releases( + first: 30 + after: $cursor + orderBy: { field: CREATED_AT, direction: DESC } + ) { pageInfo { ...PageInfoParts } @@ -1086,4 +1090,4 @@ query Releases($name: String!, $owner: String!, $cursor: String) { } } } -} \ No newline at end of file +} diff --git a/lib/router.dart b/lib/router.dart index 636d627..fa5ee67 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -37,7 +37,6 @@ import 'package:git_touch/screens/gh_issue.dart'; import 'package:git_touch/screens/gh_issue_form.dart'; import 'package:git_touch/screens/gh_issues.dart'; import 'package:git_touch/screens/gh_object.dart'; -import 'package:git_touch/screens/gh_org_repos.dart'; import 'package:git_touch/screens/gh_orgs.dart'; import 'package:git_touch/screens/gh_pulls.dart'; import 'package:git_touch/screens/gh_releases.dart'; @@ -122,9 +121,8 @@ final router = GoRouter( case 'stars': return GhStars(login); case 'repositories': - return GhRepos(login); case 'orgrepo': - return GhOrgReposScreen(login); + return GhRepos(login); case 'organizations': return GhUserOrganizationScreen(login); case 'gists': diff --git a/lib/screens/gh_org_repos.dart b/lib/screens/gh_org_repos.dart deleted file mode 100644 index 662ccf1..0000000 --- a/lib/screens/gh_org_repos.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:flutter/widgets.dart'; -import 'package:flutter_gen/gen_l10n/S.dart'; -import 'package:git_touch/models/auth.dart'; -import 'package:git_touch/scaffolds/list_stateful.dart'; -import 'package:git_touch/widgets/app_bar_title.dart'; -import 'package:git_touch/widgets/repository_item.dart'; -import 'package:github/github.dart'; -import 'package:provider/provider.dart'; -import 'package:timeago/timeago.dart' as timeago; - -/// There are some restrictions of organization repos with OAuth -/// -/// https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/restricting-access-to-your-organizations-data -/// -/// So we use RESTful API here for repos of org -class GhOrgReposScreen extends StatelessWidget { - final String owner; - const GhOrgReposScreen(this.owner); - - @override - Widget build(BuildContext context) { - return ListStatefulScaffold( - title: AppBarTitle(AppLocalizations.of(context)!.repositories), - fetch: (page) async { - page = page ?? 1; - final rs = await context - .read() - .ghClient - .getJSON>( - '/orgs/$owner/repos?sort=updated&page=$page', - convert: (vs) => [for (var v in vs) Repository.fromJson(v)], - ); - return ListPayload( - cursor: page + 1, - items: rs, - hasMore: rs.isNotEmpty, // TODO: - ); - }, - itemBuilder: (v) { - return RepositoryItem.gh( - owner: v.owner!.login, - avatarUrl: v.owner!.avatarUrl, - name: v.name, - description: v.description, - starCount: v.stargazersCount, - forkCount: v.forksCount, - primaryLanguageName: v.language, - primaryLanguageColor: null, - note: 'Updated ${timeago.format(v.updatedAt!)}', - isPrivate: v.isPrivate, - isFork: v.isFork, - ); - }, - ); - } -} diff --git a/lib/screens/gh_repos.dart b/lib/screens/gh_repos.dart index f73e606..80060d9 100644 --- a/lib/screens/gh_repos.dart +++ b/lib/screens/gh_repos.dart @@ -26,7 +26,7 @@ class GhRepos extends StatelessWidget { }); final OperationResponse res = await auth.gqlClient.request(req).first; - final p = res.data!.user!.repositories; + final p = res.data!.repositoryOwner!.repositories; return ListPayload( cursor: p.pageInfo.endCursor, hasMore: p.pageInfo.hasNextPage,