mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
feat: specify branch of commits screen
This commit is contained in:
parent
89786c307e
commit
8bc2024e41
@ -21,11 +21,11 @@ class CommitsScreen extends StatelessWidget {
|
||||
if (cursor != null) {
|
||||
params += ', after: "$cursor"';
|
||||
}
|
||||
// TODO: Specify branch
|
||||
var key = getBranchQueryKey(branch, withParams: true);
|
||||
var data = await Provider.of<SettingsModel>(context).query('''
|
||||
{
|
||||
repository(owner: "$owner", name: "$name") {
|
||||
ref(qualifiedName: "master") {
|
||||
$key {
|
||||
target {
|
||||
... on Commit {
|
||||
history($params) {
|
||||
@ -58,7 +58,8 @@ class CommitsScreen extends StatelessWidget {
|
||||
}
|
||||
''');
|
||||
|
||||
var history = data["repository"]['ref']['target']['history'];
|
||||
var history =
|
||||
data["repository"][getBranchQueryKey(branch)]['target']['history'];
|
||||
|
||||
return ListPayload(
|
||||
cursor: history["pageInfo"]["endCursor"],
|
||||
|
@ -35,11 +35,10 @@ class RepositoryScreen extends StatelessWidget {
|
||||
: owner = fullName.split('/')[0],
|
||||
name = fullName.split('/')[1];
|
||||
|
||||
get _branchQueryChunk =>
|
||||
branch == null ? 'defaultBranchRef' : 'ref(qualifiedName: "$branch")';
|
||||
get branchInfoKey => branch == null ? 'defaultBranchRef' : 'ref';
|
||||
get branchInfoKey => getBranchQueryKey(branch);
|
||||
|
||||
Future queryRepo(BuildContext context) async {
|
||||
var branchKey = getBranchQueryKey(branch, withParams: true);
|
||||
var data = await Provider.of<SettingsModel>(context).query('''
|
||||
{
|
||||
repository(owner: "$owner", name: "$name") {
|
||||
@ -87,7 +86,7 @@ class RepositoryScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
}
|
||||
$_branchQueryChunk {
|
||||
$branchKey {
|
||||
name
|
||||
target {
|
||||
... on Commit {
|
||||
@ -110,7 +109,6 @@ class RepositoryScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
''');
|
||||
// FIXME: 1. Default branch 2. Other readme file names
|
||||
return data['repository'];
|
||||
}
|
||||
|
||||
@ -131,6 +129,10 @@ class RepositoryScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshScaffold(
|
||||
title: AppBarTitle('Repository'),
|
||||
onRefresh: () => Future.wait([
|
||||
queryRepo(context),
|
||||
fetchReadme(context),
|
||||
]),
|
||||
trailingBuilder: (data) {
|
||||
var payload = data[0];
|
||||
return ActionButton(title: 'Repository Actions', actions: [
|
||||
@ -180,10 +182,6 @@ class RepositoryScreen extends StatelessWidget {
|
||||
),
|
||||
]);
|
||||
},
|
||||
onRefresh: () => Future.wait([
|
||||
queryRepo(context),
|
||||
fetchReadme(context),
|
||||
]),
|
||||
bodyBuilder: (data) {
|
||||
var payload = data[0];
|
||||
var readme = data[1] as String;
|
||||
@ -256,9 +254,10 @@ class RepositoryScreen extends StatelessWidget {
|
||||
rightWidget:
|
||||
Text(filesize((payload['diskUsage'] as int) * 1000)),
|
||||
screenBuilder: (_) => ObjectScreen(
|
||||
owner: owner,
|
||||
name: name,
|
||||
branch: payload[branchInfoKey]['name']),
|
||||
owner: owner,
|
||||
name: name,
|
||||
branch: payload[branchInfoKey]['name'],
|
||||
),
|
||||
),
|
||||
if (payload['hasIssuesEnabled'] as bool)
|
||||
TableViewItem(
|
||||
|
@ -157,3 +157,8 @@ class BorderView extends StatelessWidget {
|
||||
|
||||
const borderView = BorderView();
|
||||
const borderView1 = BorderView(height: 20, color: PrimerColors.gray100);
|
||||
|
||||
String getBranchQueryKey(String branch, {bool withParams = false}) {
|
||||
if (branch == null) return 'defaultBranchRef';
|
||||
return 'ref' + (withParams ? '(qualifiedName: "$branch")' : '');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user