From 42c733fe4c7ae2fa6e98f89d8be6095a0e57e2ac Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Mon, 20 Jan 2020 14:18:45 +0800 Subject: [PATCH] feat: repo watch --- lib/graphql/gh.dart | 319 +++++++++++++++++++++++++++++++++++ lib/graphql/gh.g.dart | 245 ++++++++++++++++++++++----- lib/graphql/gh_repo.graphql | 2 +- lib/graphql/gh_watch.graphql | 9 + lib/screens/repository.dart | 105 ++++++++---- 5 files changed, 600 insertions(+), 80 deletions(-) create mode 100644 lib/graphql/gh_watch.graphql diff --git a/lib/graphql/gh.dart b/lib/graphql/gh.dart index 16cf358..998c681 100644 --- a/lib/graphql/gh.dart +++ b/lib/graphql/gh.dart @@ -75,6 +75,9 @@ class GhRepoRepository extends GhRepoPinnableItem @override bool viewerHasStarred; + @override + GhRepoSubscriptionState viewerSubscription; + @override String projectsUrl; @@ -122,6 +125,7 @@ class GhRepoRepository extends GhRepoPinnableItem hasIssuesEnabled, url, viewerHasStarred, + viewerSubscription, projectsUrl, watchers, issues, @@ -669,6 +673,12 @@ class GhRepoRepositoryInfo with EquatableMixin { Map toJson() => _$GhRepoRepositoryInfoToJson(this); } +enum GhRepoSubscriptionState { + UNSUBSCRIBED, + SUBSCRIBED, + IGNORED, +} + @JsonSerializable(explicitToJson: true) class GhRepoArguments extends JsonSerializable with EquatableMixin { GhRepoArguments({this.owner, this.name, this.branchSpecified, this.branch}); @@ -868,6 +878,12 @@ class GhRepoQuery extends GraphQLQuery { arguments: [], directives: [], selectionSet: null), + FieldNode( + name: NameNode(value: 'viewerSubscription'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), FieldNode( name: NameNode(value: 'projectsUrl'), alias: null, @@ -8092,3 +8108,306 @@ class GhRepoIdQuery extends GraphQLQuery { @override GhRepoId parse(Map json) => GhRepoId.fromJson(json); } + +@JsonSerializable(explicitToJson: true) +class GhWatch with EquatableMixin { + GhWatch(); + + factory GhWatch.fromJson(Map json) => + _$GhWatchFromJson(json); + + GhWatchUpdateSubscriptionPayload updateSubscription; + + @override + List get props => [updateSubscription]; + Map toJson() => _$GhWatchToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchUpdateSubscriptionPayload with EquatableMixin { + GhWatchUpdateSubscriptionPayload(); + + factory GhWatchUpdateSubscriptionPayload.fromJson( + Map json) => + _$GhWatchUpdateSubscriptionPayloadFromJson(json); + + GhWatchSubscribable subscribable; + + @override + List get props => [subscribable]; + Map toJson() => + _$GhWatchUpdateSubscriptionPayloadToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchSubscribable with EquatableMixin { + GhWatchSubscribable(); + + factory GhWatchSubscribable.fromJson(Map json) { + switch (json['__typename'].toString()) { + case 'Repository': + return GhWatchRepository.fromJson(json); + default: + } + return _$GhWatchSubscribableFromJson(json); + } + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() { + switch (resolveType) { + case 'Repository': + return (this as GhWatchRepository).toJson(); + default: + } + return _$GhWatchSubscribableToJson(this); + } +} + +@JsonSerializable(explicitToJson: true) +class GhWatchRepository extends GhWatchPinnableItem + with EquatableMixin + implements + GhWatchNode, + GhWatchProjectOwner, + GhWatchRegistryPackageOwner, + GhWatchRegistryPackageSearch, + GhWatchSubscribable, + GhWatchStarrable, + GhWatchUniformResourceLocatable, + GhWatchRepositoryInfo { + GhWatchRepository(); + + factory GhWatchRepository.fromJson(Map json) => + _$GhWatchRepositoryFromJson(json); + + GhWatchSubscriptionState viewerSubscription; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [viewerSubscription, resolveType]; + Map toJson() => _$GhWatchRepositoryToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchPinnableItem with EquatableMixin { + GhWatchPinnableItem(); + + factory GhWatchPinnableItem.fromJson(Map json) => + _$GhWatchPinnableItemFromJson(json); + + @override + List get props => []; + Map toJson() => _$GhWatchPinnableItemToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchNode with EquatableMixin { + GhWatchNode(); + + factory GhWatchNode.fromJson(Map json) => + _$GhWatchNodeFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhWatchNodeToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchProjectOwner with EquatableMixin { + GhWatchProjectOwner(); + + factory GhWatchProjectOwner.fromJson(Map json) => + _$GhWatchProjectOwnerFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhWatchProjectOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchRegistryPackageOwner with EquatableMixin { + GhWatchRegistryPackageOwner(); + + factory GhWatchRegistryPackageOwner.fromJson(Map json) => + _$GhWatchRegistryPackageOwnerFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhWatchRegistryPackageOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchRegistryPackageSearch with EquatableMixin { + GhWatchRegistryPackageSearch(); + + factory GhWatchRegistryPackageSearch.fromJson(Map json) => + _$GhWatchRegistryPackageSearchFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhWatchRegistryPackageSearchToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchStarrable with EquatableMixin { + GhWatchStarrable(); + + factory GhWatchStarrable.fromJson(Map json) => + _$GhWatchStarrableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhWatchStarrableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchUniformResourceLocatable with EquatableMixin { + GhWatchUniformResourceLocatable(); + + factory GhWatchUniformResourceLocatable.fromJson(Map json) => + _$GhWatchUniformResourceLocatableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => + _$GhWatchUniformResourceLocatableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhWatchRepositoryInfo with EquatableMixin { + GhWatchRepositoryInfo(); + + factory GhWatchRepositoryInfo.fromJson(Map json) => + _$GhWatchRepositoryInfoFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhWatchRepositoryInfoToJson(this); +} + +enum GhWatchSubscriptionState { + UNSUBSCRIBED, + SUBSCRIBED, + IGNORED, +} + +@JsonSerializable(explicitToJson: true) +class GhWatchArguments extends JsonSerializable with EquatableMixin { + GhWatchArguments({this.id, this.state}); + + factory GhWatchArguments.fromJson(Map json) => + _$GhWatchArgumentsFromJson(json); + + final String id; + + final GhWatchSubscriptionState state; + + @override + List get props => [id, state]; + Map toJson() => _$GhWatchArgumentsToJson(this); +} + +class GhWatchQuery extends GraphQLQuery { + GhWatchQuery({this.variables}); + + @override + final DocumentNode document = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.mutation, + name: NameNode(value: 'GhWatch'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'id')), + type: NamedTypeNode(name: NameNode(value: 'ID'), isNonNull: true), + defaultValue: DefaultValueNode(value: null), + directives: []), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'state')), + type: NamedTypeNode( + name: NameNode(value: 'SubscriptionState'), isNonNull: true), + defaultValue: DefaultValueNode(value: null), + directives: []) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'updateSubscription'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'input'), + value: ObjectValueNode(fields: [ + ObjectFieldNode( + name: NameNode(value: 'subscribableId'), + value: VariableNode(name: NameNode(value: 'id'))), + ObjectFieldNode( + name: NameNode(value: 'state'), + value: VariableNode(name: NameNode(value: 'state'))) + ])) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'subscribable'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + InlineFragmentNode( + typeCondition: TypeConditionNode( + on: NamedTypeNode( + name: NameNode(value: 'Repository'), + isNonNull: false)), + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'viewerSubscription'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])) + ])) + ])) + ])) + ]); + + @override + final String operationName = 'GhWatch'; + + @override + final GhWatchArguments variables; + + @override + List get props => [document, operationName, variables]; + @override + GhWatch parse(Map json) => GhWatch.fromJson(json); +} diff --git a/lib/graphql/gh.g.dart b/lib/graphql/gh.g.dart index 2b401eb..6acae7a 100644 --- a/lib/graphql/gh.g.dart +++ b/lib/graphql/gh.g.dart @@ -44,6 +44,8 @@ GhRepoRepository _$GhRepoRepositoryFromJson(Map json) { ..hasIssuesEnabled = json['hasIssuesEnabled'] as bool ..url = json['url'] as String ..viewerHasStarred = json['viewerHasStarred'] as bool + ..viewerSubscription = _$enumDecodeNullable( + _$GhRepoSubscriptionStateEnumMap, json['viewerSubscription']) ..projectsUrl = json['projectsUrl'] as String ..watchers = json['watchers'] == null ? null @@ -71,18 +73,11 @@ GhRepoRepository _$GhRepoRepositoryFromJson(Map json) { ..defaultBranchRef = json['defaultBranchRef'] == null ? null : GhRepoRef.fromJson(json['defaultBranchRef'] as Map) - ..ref = json['ref'] == null - ? null - : GhRepoRef.fromJson(json['ref'] as Map) - ..refs = json['refs'] == null - ? null - : GhRepoRefConnection.fromJson(json['refs'] as Map) - ..licenseInfo = json['licenseInfo'] == null - ? null - : GhRepoLicense.fromJson(json['licenseInfo'] as Map) - ..repositoryTopics = json['repositoryTopics'] == null - ? null - : GhRepoRepositoryTopicConnection.fromJson(json['repositoryTopics'] as Map) + ..ref = + json['ref'] == null ? null : GhRepoRef.fromJson(json['ref'] as Map) + ..refs = json['refs'] == null ? null : GhRepoRefConnection.fromJson(json['refs'] as Map) + ..licenseInfo = json['licenseInfo'] == null ? null : GhRepoLicense.fromJson(json['licenseInfo'] as Map) + ..repositoryTopics = json['repositoryTopics'] == null ? null : GhRepoRepositoryTopicConnection.fromJson(json['repositoryTopics'] as Map) ..resolveType = json['__typename'] as String; } @@ -102,6 +97,8 @@ Map _$GhRepoRepositoryToJson(GhRepoRepository instance) => 'hasIssuesEnabled': instance.hasIssuesEnabled, 'url': instance.url, 'viewerHasStarred': instance.viewerHasStarred, + 'viewerSubscription': + _$GhRepoSubscriptionStateEnumMap[instance.viewerSubscription], 'projectsUrl': instance.projectsUrl, 'watchers': instance.watchers?.toJson(), 'issues': instance.issues?.toJson(), @@ -117,6 +114,44 @@ Map _$GhRepoRepositoryToJson(GhRepoRepository instance) => '__typename': instance.resolveType, }; +T _$enumDecode( + Map enumValues, + dynamic source, { + T unknownValue, +}) { + if (source == null) { + throw ArgumentError('A value must be provided. Supported values: ' + '${enumValues.values.join(', ')}'); + } + + final value = enumValues.entries + .singleWhere((e) => e.value == source, orElse: () => null) + ?.key; + + if (value == null && unknownValue == null) { + throw ArgumentError('`$source` is not one of the supported values: ' + '${enumValues.values.join(', ')}'); + } + return value ?? unknownValue; +} + +T _$enumDecodeNullable( + Map enumValues, + dynamic source, { + T unknownValue, +}) { + if (source == null) { + return null; + } + return _$enumDecode(enumValues, source, unknownValue: unknownValue); +} + +const _$GhRepoSubscriptionStateEnumMap = { + GhRepoSubscriptionState.UNSUBSCRIBED: 'UNSUBSCRIBED', + GhRepoSubscriptionState.SUBSCRIBED: 'SUBSCRIBED', + GhRepoSubscriptionState.IGNORED: 'IGNORED', +}; + GhRepoRepositoryOwner _$GhRepoRepositoryOwnerFromJson( Map json) { return GhRepoRepositoryOwner() @@ -3062,38 +3097,6 @@ Map _$GhCommitsStatusToJson(GhCommitsStatus instance) => '__typename': instance.resolveType, }; -T _$enumDecode( - Map enumValues, - dynamic source, { - T unknownValue, -}) { - if (source == null) { - throw ArgumentError('A value must be provided. Supported values: ' - '${enumValues.values.join(', ')}'); - } - - final value = enumValues.entries - .singleWhere((e) => e.value == source, orElse: () => null) - ?.key; - - if (value == null && unknownValue == null) { - throw ArgumentError('`$source` is not one of the supported values: ' - '${enumValues.values.join(', ')}'); - } - return value ?? unknownValue; -} - -T _$enumDecodeNullable( - Map enumValues, - dynamic source, { - T unknownValue, -}) { - if (source == null) { - return null; - } - return _$enumDecode(enumValues, source, unknownValue: unknownValue); -} - const _$GhCommitsStatusStateEnumMap = { GhCommitsStatusState.EXPECTED: 'EXPECTED', GhCommitsStatusState.ERROR: 'ERROR', @@ -3347,3 +3350,157 @@ Map _$GhRepoIdArgumentsToJson(GhRepoIdArguments instance) => 'owner': instance.owner, 'name': instance.name, }; + +GhWatch _$GhWatchFromJson(Map json) { + return GhWatch() + ..updateSubscription = json['updateSubscription'] == null + ? null + : GhWatchUpdateSubscriptionPayload.fromJson( + json['updateSubscription'] as Map); +} + +Map _$GhWatchToJson(GhWatch instance) => { + 'updateSubscription': instance.updateSubscription?.toJson(), + }; + +GhWatchUpdateSubscriptionPayload _$GhWatchUpdateSubscriptionPayloadFromJson( + Map json) { + return GhWatchUpdateSubscriptionPayload() + ..subscribable = json['subscribable'] == null + ? null + : GhWatchSubscribable.fromJson( + json['subscribable'] as Map); +} + +Map _$GhWatchUpdateSubscriptionPayloadToJson( + GhWatchUpdateSubscriptionPayload instance) => + { + 'subscribable': instance.subscribable?.toJson(), + }; + +GhWatchSubscribable _$GhWatchSubscribableFromJson(Map json) { + return GhWatchSubscribable()..resolveType = json['__typename'] as String; +} + +Map _$GhWatchSubscribableToJson( + GhWatchSubscribable instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchRepository _$GhWatchRepositoryFromJson(Map json) { + return GhWatchRepository() + ..viewerSubscription = _$enumDecodeNullable( + _$GhWatchSubscriptionStateEnumMap, json['viewerSubscription']) + ..resolveType = json['__typename'] as String; +} + +Map _$GhWatchRepositoryToJson(GhWatchRepository instance) => + { + 'viewerSubscription': + _$GhWatchSubscriptionStateEnumMap[instance.viewerSubscription], + '__typename': instance.resolveType, + }; + +const _$GhWatchSubscriptionStateEnumMap = { + GhWatchSubscriptionState.UNSUBSCRIBED: 'UNSUBSCRIBED', + GhWatchSubscriptionState.SUBSCRIBED: 'SUBSCRIBED', + GhWatchSubscriptionState.IGNORED: 'IGNORED', +}; + +GhWatchPinnableItem _$GhWatchPinnableItemFromJson(Map json) { + return GhWatchPinnableItem(); +} + +Map _$GhWatchPinnableItemToJson( + GhWatchPinnableItem instance) => + {}; + +GhWatchNode _$GhWatchNodeFromJson(Map json) { + return GhWatchNode()..resolveType = json['__typename'] as String; +} + +Map _$GhWatchNodeToJson(GhWatchNode instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchProjectOwner _$GhWatchProjectOwnerFromJson(Map json) { + return GhWatchProjectOwner()..resolveType = json['__typename'] as String; +} + +Map _$GhWatchProjectOwnerToJson( + GhWatchProjectOwner instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchRegistryPackageOwner _$GhWatchRegistryPackageOwnerFromJson( + Map json) { + return GhWatchRegistryPackageOwner() + ..resolveType = json['__typename'] as String; +} + +Map _$GhWatchRegistryPackageOwnerToJson( + GhWatchRegistryPackageOwner instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchRegistryPackageSearch _$GhWatchRegistryPackageSearchFromJson( + Map json) { + return GhWatchRegistryPackageSearch() + ..resolveType = json['__typename'] as String; +} + +Map _$GhWatchRegistryPackageSearchToJson( + GhWatchRegistryPackageSearch instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchStarrable _$GhWatchStarrableFromJson(Map json) { + return GhWatchStarrable()..resolveType = json['__typename'] as String; +} + +Map _$GhWatchStarrableToJson(GhWatchStarrable instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchUniformResourceLocatable _$GhWatchUniformResourceLocatableFromJson( + Map json) { + return GhWatchUniformResourceLocatable() + ..resolveType = json['__typename'] as String; +} + +Map _$GhWatchUniformResourceLocatableToJson( + GhWatchUniformResourceLocatable instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchRepositoryInfo _$GhWatchRepositoryInfoFromJson( + Map json) { + return GhWatchRepositoryInfo()..resolveType = json['__typename'] as String; +} + +Map _$GhWatchRepositoryInfoToJson( + GhWatchRepositoryInfo instance) => + { + '__typename': instance.resolveType, + }; + +GhWatchArguments _$GhWatchArgumentsFromJson(Map json) { + return GhWatchArguments( + id: json['id'] as String, + state: + _$enumDecodeNullable(_$GhWatchSubscriptionStateEnumMap, json['state']), + ); +} + +Map _$GhWatchArgumentsToJson(GhWatchArguments instance) => + { + 'id': instance.id, + 'state': _$GhWatchSubscriptionStateEnumMap[instance.state], + }; diff --git a/lib/graphql/gh_repo.graphql b/lib/graphql/gh_repo.graphql index f66522c..3cae781 100644 --- a/lib/graphql/gh_repo.graphql +++ b/lib/graphql/gh_repo.graphql @@ -30,7 +30,7 @@ query GhRepo( hasIssuesEnabled url viewerHasStarred - # viewerSubscription # TODO + viewerSubscription projectsUrl watchers { totalCount diff --git a/lib/graphql/gh_watch.graphql b/lib/graphql/gh_watch.graphql new file mode 100644 index 0000000..7b2e89d --- /dev/null +++ b/lib/graphql/gh_watch.graphql @@ -0,0 +1,9 @@ +mutation GhWatch($id: ID!, $state: SubscriptionState!) { + updateSubscription(input: { subscribableId: $id, state: $state }) { + subscribable { + ... on Repository { + viewerSubscription + } + } + } +} diff --git a/lib/screens/repository.dart b/lib/screens/repository.dart index 481b6e2..3595d23 100644 --- a/lib/screens/repository.dart +++ b/lib/screens/repository.dart @@ -8,6 +8,7 @@ import 'package:git_touch/scaffolds/refresh_stateful.dart'; import 'package:git_touch/utils/utils.dart'; import 'package:git_touch/widgets/app_bar_title.dart'; import 'package:git_touch/widgets/avatar.dart'; +import 'package:git_touch/widgets/entry_item.dart'; import 'package:git_touch/widgets/label.dart'; import 'package:git_touch/widgets/mutation_button.dart'; import 'package:git_touch/widgets/link.dart'; @@ -16,7 +17,6 @@ import 'package:git_touch/widgets/table_view.dart'; import 'package:provider/provider.dart'; import 'package:git_touch/models/theme.dart'; import 'package:tuple/tuple.dart'; -import '../widgets/entry_item.dart'; import 'package:git_touch/widgets/action_button.dart'; import 'package:charts_flutter/flutter.dart' as charts; @@ -76,24 +76,6 @@ class RepositoryScreen extends StatelessWidget { return ActionButton( title: 'Repository Actions', items: [ - // TODO: - // ActionItem( - // text: data[0]['viewerSubscription'] == 'SUBSCRIBED' - // ? 'Unwatch' - // : 'Watch', - // onPress: (_) async { - // if (data[0]['viewerSubscription'] == 'SUBSCRIBED') { - // await Provider.of(context).deleteWithCredentials( - // '/repos/$owner/$name/subscription'); - // data[0]['viewerSubscription'] = 'UNSUBSCRIBED'; - // } else { - // await Provider.of(context) - // .putWithCredentials('/repos/$owner/$name/subscription'); - // data[0]['viewerSubscription'] = 'SUBSCRIBED'; - // } - // setState(() {}); - // }, - // ), ActionItem( text: 'Projects(${repo.projects.totalCount})', url: repo.projectsUrl, @@ -148,23 +130,76 @@ class RepositoryScreen extends StatelessWidget { ), ], ), - MutationButton( - text: repo.viewerHasStarred ? 'Unstar' : 'Star', - onPressed: () async { - final res = await auth.gqlClient.execute( - GhStarQuery( - variables: GhStarArguments( - id: repo.id, - flag: !repo.viewerHasStarred, - ), - ), - ); - setState(() { - repo.viewerHasStarred = - res.data.removeStar?.starrable?.viewerHasStarred ?? + Row( + children: [ + MutationButton( + text: repo.viewerHasStarred ? 'Unstar' : 'Star', + onPressed: () async { + final res = await auth.gqlClient.execute( + GhStarQuery( + variables: GhStarArguments( + id: repo.id, + flag: !repo.viewerHasStarred, + ), + ), + ); + setState(() { + repo.viewerHasStarred = res.data.removeStar + ?.starrable?.viewerHasStarred ?? res.data.addStar.starrable.viewerHasStarred; - }); - }, + }); + }, + ), + // TODO: + // SizedBox(width: 4), + // MutationButton( + // text: repo.viewerSubscription == + // GhRepoSubscriptionState.SUBSCRIBED + // ? 'Unwatch' + // : 'Watch', + // onPressed: () async { + // theme.showActions( + // context, + // GhWatchSubscriptionState.values.map((v) { + // return ActionItem( + // text: v.toString(), + // onTap: (_) async { + // final res = await auth.gqlClient.execute( + // GhWatchQuery( + // variables: GhWatchArguments( + // id: repo.id, + // state: + // GhWatchSubscriptionState.SUBSCRIBED, + // ), + // ), + // ); + // setState(() { + // final r = res.data.updateSubscription + // .subscribable as GhWatchRepository; + // switch (r.viewerSubscription) { + // case GhWatchSubscriptionState.IGNORED: + // repo.viewerSubscription = + // GhRepoSubscriptionState.IGNORED; + // break; + // case GhWatchSubscriptionState.SUBSCRIBED: + // repo.viewerSubscription = + // GhRepoSubscriptionState.SUBSCRIBED; + // break; + // case GhWatchSubscriptionState + // .UNSUBSCRIBED: + // repo.viewerSubscription = + // GhRepoSubscriptionState + // .UNSUBSCRIBED; + // break; + // } + // }); + // }, + // ); + // }).toList(), + // ); + // }, + // ), + ], ), if (repo.description != null && repo.description.isNotEmpty) Text(