Skip to content

Commit

Permalink
feat: watch repository
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Sep 25, 2019
1 parent 0fe8fc5 commit 488f5fc
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/screens/repository.dart
Expand Up @@ -157,7 +157,7 @@ class RepositoryScreen extends StatelessWidget {
Provider.of<ThemeModel>(context).pushRoute(context, builder);
},
),
if (data != null)
if (data != null) ...[
MyAction(
text: data[0]['viewerHasStarred'] ? 'Unstar' : 'Star',
onPress: () async {
Expand All @@ -172,7 +172,24 @@ class RepositoryScreen extends StatelessWidget {
}
},
),
// TODO: watch
MyAction(
text: data[0]['viewerSubscription'] == 'SUBSCRIBED'
? 'Unwatch'
: 'Watch',
onPress: () async {
if (data[0]['viewerSubscription'] == 'SUBSCRIBED') {
await Provider.of<SettingsModel>(context)
.deleteWithCredentials(
'/repos/$owner/$name/subscription');
data[0]['viewerSubscription'] = 'UNSUBSCRIBED';
} else {
Provider.of<SettingsModel>(context)
.putWithCredentials('/repos/$owner/$name/subscription');
data[0]['viewerSubscription'] = 'SUBSCRIBED';
}
},
),
],
MyAction(
text: 'Share',
onPress: () {
Expand Down

0 comments on commit 488f5fc

Please sign in to comment.