fix(gitlab): issue and user
This commit is contained in:
parent
5d2745cd00
commit
92a33e8fb8
|
@ -63,7 +63,7 @@ class GitlabTodoTarget {
|
||||||
String title;
|
String title;
|
||||||
GitlabUser author;
|
GitlabUser author;
|
||||||
String description;
|
String description;
|
||||||
String createdAt;
|
DateTime createdAt;
|
||||||
|
|
||||||
GitlabTodoTarget();
|
GitlabTodoTarget();
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@ class GitlabTodoTarget {
|
||||||
class GitlabIssueNote {
|
class GitlabIssueNote {
|
||||||
GitlabUser author;
|
GitlabUser author;
|
||||||
String body;
|
String body;
|
||||||
|
bool system;
|
||||||
|
DateTime createdAt;
|
||||||
GitlabIssueNote();
|
GitlabIssueNote();
|
||||||
|
|
||||||
factory GitlabIssueNote.fromJson(Map<String, dynamic> json) =>
|
factory GitlabIssueNote.fromJson(Map<String, dynamic> json) =>
|
||||||
_$GitlabIssueNoteFromJson(json);
|
_$GitlabIssueNoteFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,9 @@ GitlabTodoTarget _$GitlabTodoTargetFromJson(Map<String, dynamic> json) {
|
||||||
? null
|
? null
|
||||||
: GitlabUser.fromJson(json['author'] as Map<String, dynamic>)
|
: GitlabUser.fromJson(json['author'] as Map<String, dynamic>)
|
||||||
..description = json['description'] as String
|
..description = json['description'] as String
|
||||||
..createdAt = json['created_at'] as String;
|
..createdAt = json['created_at'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['created_at'] as String);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> _$GitlabTodoTargetToJson(GitlabTodoTarget instance) =>
|
Map<String, dynamic> _$GitlabTodoTargetToJson(GitlabTodoTarget instance) =>
|
||||||
|
@ -109,7 +111,7 @@ Map<String, dynamic> _$GitlabTodoTargetToJson(GitlabTodoTarget instance) =>
|
||||||
'title': instance.title,
|
'title': instance.title,
|
||||||
'author': instance.author,
|
'author': instance.author,
|
||||||
'description': instance.description,
|
'description': instance.description,
|
||||||
'created_at': instance.createdAt,
|
'created_at': instance.createdAt?.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|
||||||
GitlabIssueNote _$GitlabIssueNoteFromJson(Map<String, dynamic> json) {
|
GitlabIssueNote _$GitlabIssueNoteFromJson(Map<String, dynamic> json) {
|
||||||
|
@ -117,13 +119,19 @@ GitlabIssueNote _$GitlabIssueNoteFromJson(Map<String, dynamic> json) {
|
||||||
..author = json['author'] == null
|
..author = json['author'] == null
|
||||||
? null
|
? null
|
||||||
: GitlabUser.fromJson(json['author'] as Map<String, dynamic>)
|
: GitlabUser.fromJson(json['author'] as Map<String, dynamic>)
|
||||||
..body = json['body'] as String;
|
..body = json['body'] as String
|
||||||
|
..system = json['system'] as bool
|
||||||
|
..createdAt = json['created_at'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['created_at'] as String);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> _$GitlabIssueNoteToJson(GitlabIssueNote instance) =>
|
Map<String, dynamic> _$GitlabIssueNoteToJson(GitlabIssueNote instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'author': instance.author,
|
'author': instance.author,
|
||||||
'body': instance.body,
|
'body': instance.body,
|
||||||
|
'system': instance.system,
|
||||||
|
'created_at': instance.createdAt?.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|
||||||
GitlabProject _$GitlabProjectFromJson(Map<String, dynamic> json) {
|
GitlabProject _$GitlabProjectFromJson(Map<String, dynamic> json) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:git_touch/models/gitlab.dart';
|
||||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||||
import 'package:git_touch/utils/utils.dart';
|
import 'package:git_touch/utils/utils.dart';
|
||||||
import 'package:git_touch/widgets/avatar.dart';
|
import 'package:git_touch/widgets/avatar.dart';
|
||||||
|
import 'package:git_touch/widgets/comment_item.dart';
|
||||||
import 'package:git_touch/widgets/markdown_view.dart';
|
import 'package:git_touch/widgets/markdown_view.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
|
@ -37,7 +38,7 @@ class GitlabIssueScreen extends StatelessWidget {
|
||||||
Provider.of<AuthModel>(context)
|
Provider.of<AuthModel>(context)
|
||||||
.fetchGitlab('/projects/$projectId/$type/$iid'),
|
.fetchGitlab('/projects/$projectId/$type/$iid'),
|
||||||
Provider.of<AuthModel>(context)
|
Provider.of<AuthModel>(context)
|
||||||
.fetchGitlab('/projects/$projectId/$type/$iid/notes'),
|
.fetchGitlab('/projects/$projectId/$type/$iid/notes?sort=asc'),
|
||||||
Provider.of<AuthModel>(context)
|
Provider.of<AuthModel>(context)
|
||||||
.fetchGitlab('/projects/$projectId/$type/$iid/award_emoji'),
|
.fetchGitlab('/projects/$projectId/$type/$iid/award_emoji'),
|
||||||
]);
|
]);
|
||||||
|
@ -56,46 +57,45 @@ class GitlabIssueScreen extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
padding: CommonStyle.padding,
|
padding: CommonStyle.padding,
|
||||||
child: Column(
|
child: CommentItem(
|
||||||
children: <Widget>[
|
avatar: Avatar(
|
||||||
Text(issue.title),
|
url: issue.author.avatarUrl,
|
||||||
Row(
|
linkUrl: '/gitlab/user/${issue.author.id}',
|
||||||
children: <Widget>[
|
),
|
||||||
Avatar(
|
createdAt: issue.createdAt,
|
||||||
url: issue.author.avatarUrl,
|
body: issue.description,
|
||||||
linkUrl: '/user/${issue.author}',
|
login: issue.author.username,
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Text(issue.description),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Text(timeago.format(DateTime.parse(issue.createdAt)))
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
CommonStyle.border,
|
CommonStyle.border,
|
||||||
Column(
|
Column(
|
||||||
children: notes.map((note) {
|
children: <Widget>[
|
||||||
return Container(
|
for (var note in notes)
|
||||||
padding: CommonStyle.padding,
|
if (note.system)
|
||||||
child: Column(
|
Container(
|
||||||
children: <Widget>[
|
padding: CommonStyle.padding,
|
||||||
Row(
|
child: Text.rich(
|
||||||
children: <Widget>[
|
TextSpan(children: [
|
||||||
Avatar(url: note.author.avatarUrl),
|
WidgetSpan(child: Avatar(url: note.author.avatarUrl)),
|
||||||
Expanded(
|
TextSpan(text: note.author.name),
|
||||||
child: Column(
|
TextSpan(text: note.body),
|
||||||
children: <Widget>[Text(note.author.name)],
|
]),
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
MarkdownView(note.body),
|
)
|
||||||
],
|
else
|
||||||
),
|
Container(
|
||||||
);
|
padding: CommonStyle.padding,
|
||||||
}).toList(),
|
child: CommentItem(
|
||||||
|
avatar: Avatar(
|
||||||
|
url: note.author.avatarUrl,
|
||||||
|
linkUrl: '/gitlab/user/${note.author.id}',
|
||||||
|
),
|
||||||
|
createdAt: note.createdAt,
|
||||||
|
body: note.body,
|
||||||
|
login: note.author.username,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -30,13 +30,14 @@ class GitlabUserScreen extends StatelessWidget {
|
||||||
fetchData: () async {
|
fetchData: () async {
|
||||||
final auth = Provider.of<AuthModel>(context);
|
final auth = Provider.of<AuthModel>(context);
|
||||||
final _id = id ?? auth.activeAccount.gitlabId;
|
final _id = id ?? auth.activeAccount.gitlabId;
|
||||||
final v0 = await auth.fetchGitlab('/users/$_id');
|
final res = await Future.wait([
|
||||||
final user = GitlabUser.fromJson(v0);
|
auth.fetchGitlab('/users/$_id'),
|
||||||
final v1 = await auth.fetchGitlab('/users/$_id/projects');
|
auth.fetchGitlab('/users/$_id/projects'),
|
||||||
final projects =
|
]);
|
||||||
(v1 as List).map((v) => GitlabUserProject.fromJson(v)).toList();
|
return Tuple2(
|
||||||
|
GitlabUser.fromJson(res[0]),
|
||||||
return Tuple2(user, projects);
|
[for (var v in res[1]) GitlabUserProject.fromJson(v)],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
action: isViewer
|
action: isViewer
|
||||||
? ActionEntry(
|
? ActionEntry(
|
||||||
|
|
Loading…
Reference in New Issue