Skip to content
代码片段 群组 项目
提交 57fbb7a4 编辑于 作者: Neil Wang's avatar Neil Wang
浏览文件

refactor: #845 remove destinationHost in IssuesPage

上级 3b4e535d
No related branches found
No related tags found
无相关合并请求
...@@ -2,17 +2,17 @@ import 'package:jihu_gitlab_app/core/domain/issue.dart'; ...@@ -2,17 +2,17 @@ import 'package:jihu_gitlab_app/core/domain/issue.dart';
import 'package:jihu_gitlab_app/core/domain/project.dart'; import 'package:jihu_gitlab_app/core/domain/project.dart';
import 'package:jihu_gitlab_app/core/net/api.dart'; import 'package:jihu_gitlab_app/core/net/api.dart';
import 'package:jihu_gitlab_app/core/net/http_client.dart'; import 'package:jihu_gitlab_app/core/net/http_client.dart';
import 'package:jihu_gitlab_app/core/project_provider.dart';
import 'package:jihu_gitlab_app/modules/issues/list/group_projects_gq_request_body.dart'; import 'package:jihu_gitlab_app/modules/issues/list/group_projects_gq_request_body.dart';
class GroupIssuesFetcher { class GroupIssuesFetcher {
final List<Project> _groupProjects = []; final List<Project> _groupProjects = [];
final String? destinationHost;
final String fullPath; final String fullPath;
GroupIssuesFetcher(this.destinationHost, this.fullPath); GroupIssuesFetcher(this.fullPath);
Future<List<Issue>> fetchIssues(Map Function() bodyProvider) async { Future<List<Issue>> fetchIssues(Map Function() bodyProvider) async {
var res = await HttpClient.instance().post(destinationHost == null ? Api.graphql() : destinationHost! + Api.graphql(), bodyProvider()); var res = await HttpClient.instance().post(ProjectProvider().specifiedHost == null ? Api.graphql() : ProjectProvider().specifiedHost! + Api.graphql(), bodyProvider());
var issues = res.body()?['data']?['group']?['issues']; var issues = res.body()?['data']?['group']?['issues'];
if (issues == null) return []; if (issues == null) return [];
await _syncGroupProjects(issues['nodes']); await _syncGroupProjects(issues['nodes']);
......
...@@ -40,7 +40,6 @@ class IssuesModel { ...@@ -40,7 +40,6 @@ class IssuesModel {
List<Issue> _issues = []; List<Issue> _issues = [];
IssueMenuStateOptions _state = IssueMenuStateOptions.open; IssueMenuStateOptions _state = IssueMenuStateOptions.open;
String? _afterCursor; String? _afterCursor;
String? destinationHost;
bool _hasNextPage = true; bool _hasNextPage = true;
final TextEditingController _searchController = TextEditingController(); final TextEditingController _searchController = TextEditingController();
int? _projectId; int? _projectId;
...@@ -58,7 +57,7 @@ class IssuesModel { ...@@ -58,7 +57,7 @@ class IssuesModel {
assert(_projectId != null); assert(_projectId != null);
} }
_fullPath = fullPath; _fullPath = fullPath;
_groupIssuesFetcher = GroupIssuesFetcher(destinationHost, fullPath ?? ''); _groupIssuesFetcher = GroupIssuesFetcher(fullPath ?? '');
_projectIssuesFetcher = ProjectIssuesFetcher(); _projectIssuesFetcher = ProjectIssuesFetcher();
} }
...@@ -101,8 +100,7 @@ class IssuesModel { ...@@ -101,8 +100,7 @@ class IssuesModel {
} }
Future<List<Issue>> _getProjectIssues(String text, {int? size}) async { Future<List<Issue>> _getProjectIssues(String text, {int? size}) async {
return _projectIssuesFetcher.fetchIssues( return _projectIssuesFetcher.fetchIssues(() => getProjectIssuesGraphQLRequestBody(_fullPath ?? '', text, size ?? _size, afterCursor: _afterCursor, labelName: _labelName, state: _state.name));
destinationHost, () => getProjectIssuesGraphQLRequestBody(_fullPath ?? '', text, size ?? _size, afterCursor: _afterCursor, labelName: _labelName, state: _state.name));
} }
Future<List<Issue>> _getGroupIssues(String text, int? size) async { Future<List<Issue>> _getGroupIssues(String text, int? size) async {
......
...@@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; ...@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:jihu_gitlab_app/core/connection_provider/connection_provider.dart'; import 'package:jihu_gitlab_app/core/connection_provider/connection_provider.dart';
import 'package:jihu_gitlab_app/core/load_state.dart'; import 'package:jihu_gitlab_app/core/load_state.dart';
import 'package:jihu_gitlab_app/core/paged_state.dart'; import 'package:jihu_gitlab_app/core/paged_state.dart';
import 'package:jihu_gitlab_app/core/project_provider.dart';
import 'package:jihu_gitlab_app/core/widgets/http_fail_view.dart'; import 'package:jihu_gitlab_app/core/widgets/http_fail_view.dart';
import 'package:jihu_gitlab_app/core/widgets/popup_string_menu_button.dart'; import 'package:jihu_gitlab_app/core/widgets/popup_string_menu_button.dart';
import 'package:jihu_gitlab_app/core/widgets/search_box.dart'; import 'package:jihu_gitlab_app/core/widgets/search_box.dart';
...@@ -25,8 +26,7 @@ class IssuesPage extends StatefulWidget { ...@@ -25,8 +26,7 @@ class IssuesPage extends StatefulWidget {
this.projectId, this.projectId,
this.selectedColor = Colors.white, this.selectedColor = Colors.white,
this.labelName, this.labelName,
this.indexSource, this.indexSource});
this.destinationHost});
final bool isProject; final bool isProject;
final int? projectId; final int? projectId;
...@@ -35,7 +35,6 @@ class IssuesPage extends StatefulWidget { ...@@ -35,7 +35,6 @@ class IssuesPage extends StatefulWidget {
final Color selectedColor; final Color selectedColor;
final String? labelName; final String? labelName;
final OnSelectedIssueChange? onSelectedIssueChange; final OnSelectedIssueChange? onSelectedIssueChange;
final String? destinationHost;
final IndexSource? indexSource; final IndexSource? indexSource;
@override @override
...@@ -59,7 +58,6 @@ class IssuesPageState extends PagedState<IssuesPage> { ...@@ -59,7 +58,6 @@ class IssuesPageState extends PagedState<IssuesPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
_relativePath ??= widget.relativePath; _relativePath ??= widget.relativePath;
_projectId ??= widget.projectId; _projectId ??= widget.projectId;
_model.destinationHost = widget.destinationHost;
if (_relativePath != widget.relativePath || _projectId != widget.projectId) { if (_relativePath != widget.relativePath || _projectId != widget.projectId) {
_relativePath = widget.relativePath; _relativePath = widget.relativePath;
_projectId = widget.projectId; _projectId = widget.projectId;
...@@ -103,7 +101,7 @@ class IssuesPageState extends PagedState<IssuesPage> { ...@@ -103,7 +101,7 @@ class IssuesPageState extends PagedState<IssuesPage> {
'targetIid': issue.target.iid, 'targetIid': issue.target.iid,
'pathWithNamespace': issue.project.pathWithNamespace, 'pathWithNamespace': issue.project.pathWithNamespace,
'issue': issue, 'issue': issue,
'destinationHost': widget.destinationHost, 'destinationHost': ProjectProvider().specifiedHost,
}; };
setState(() { setState(() {
indexSource.index = index; indexSource.index = index;
......
import 'package:jihu_gitlab_app/core/domain/issue.dart'; import 'package:jihu_gitlab_app/core/domain/issue.dart';
import 'package:jihu_gitlab_app/core/net/api.dart'; import 'package:jihu_gitlab_app/core/net/api.dart';
import 'package:jihu_gitlab_app/core/net/http_client.dart'; import 'package:jihu_gitlab_app/core/net/http_client.dart';
import 'package:jihu_gitlab_app/core/project_provider.dart';
class ProjectIssuesFetcher { class ProjectIssuesFetcher {
Future<List<Issue>> fetchIssues(String? destinationHost, Map Function() bodyProvider) async { Future<List<Issue>> fetchIssues(Map Function() bodyProvider) async {
var res = await HttpClient.instance().post(destinationHost == null ? Api.graphql() : destinationHost + Api.graphql(), bodyProvider()); var res = await HttpClient.instance().post(ProjectProvider().specifiedHost == null ? Api.graphql() : ProjectProvider().specifiedHost! + Api.graphql(), bodyProvider());
var issues = res.body()?['data']?['project']?['issues']; var issues = res.body()?['data']?['project']?['issues'];
var project = res.body()?['data']?['project']; var project = res.body()?['data']?['project'];
if (issues == null) return []; if (issues == null) return [];
......
import 'package:jihu_gitlab_app/core/domain/issue.dart'; import 'package:jihu_gitlab_app/core/domain/issue.dart';
import 'package:jihu_gitlab_app/core/load_state.dart'; import 'package:jihu_gitlab_app/core/load_state.dart';
import 'package:jihu_gitlab_app/core/log_helper.dart'; import 'package:jihu_gitlab_app/core/log_helper.dart';
import 'package:jihu_gitlab_app/core/project_provider.dart';
import 'package:jihu_gitlab_app/modules/issues/list/project_issues_fetcher.dart'; import 'package:jihu_gitlab_app/modules/issues/list/project_issues_fetcher.dart';
class IterationIssuesModel { class IterationIssuesModel {
...@@ -52,7 +51,7 @@ class IterationIssuesModel { ...@@ -52,7 +51,7 @@ class IterationIssuesModel {
} }
Future<List<Issue>> getIterationIssues() async { Future<List<Issue>> getIterationIssues() async {
return _projectIssuesFetcher.fetchIssues(ProjectProvider().specifiedHost, () => iterationIssuesRequestBody("", groupFullPath, id, 100)); return _projectIssuesFetcher.fetchIssues(() => iterationIssuesRequestBody("", groupFullPath, id, 100));
} }
} }
......
import 'package:jihu_gitlab_app/core/domain/issue.dart'; import 'package:jihu_gitlab_app/core/domain/issue.dart';
import 'package:jihu_gitlab_app/core/project_provider.dart';
import 'package:jihu_gitlab_app/modules/issues/list/group_issues_fetcher.dart'; import 'package:jihu_gitlab_app/modules/issues/list/group_issues_fetcher.dart';
import 'package:jihu_gitlab_app/modules/iteration/details/iteration_model.dart'; import 'package:jihu_gitlab_app/modules/iteration/details/iteration_model.dart';
...@@ -9,7 +8,7 @@ class SubgroupIterationIssuesModel extends IterationIssuesModel { ...@@ -9,7 +8,7 @@ class SubgroupIterationIssuesModel extends IterationIssuesModel {
@override @override
void init(Map arguments) { void init(Map arguments) {
super.init(arguments); super.init(arguments);
groupIssuesFetcher = GroupIssuesFetcher(ProjectProvider().specifiedHost, groupFullPath); groupIssuesFetcher = GroupIssuesFetcher(groupFullPath);
} }
@override @override
......
...@@ -8,14 +8,12 @@ class ProjectIssuesPage extends StatefulWidget { ...@@ -8,14 +8,12 @@ class ProjectIssuesPage extends StatefulWidget {
super.key, super.key,
required this.projectId, required this.projectId,
required this.relativePath, required this.relativePath,
this.destinationHost,
this.onSelectedIssueChange, this.onSelectedIssueChange,
this.refreshKey, this.refreshKey,
}); });
final int? projectId; final int? projectId;
final String relativePath; final String relativePath;
final String? destinationHost;
final OnSelectedIssueChange? onSelectedIssueChange; final OnSelectedIssueChange? onSelectedIssueChange;
final GlobalKey<IssuesPageState>? refreshKey; final GlobalKey<IssuesPageState>? refreshKey;
...@@ -34,7 +32,6 @@ class _ProjectIssuesPageState extends State<ProjectIssuesPage> { ...@@ -34,7 +32,6 @@ class _ProjectIssuesPageState extends State<ProjectIssuesPage> {
relativePath: widget.relativePath, relativePath: widget.relativePath,
isProject: true, isProject: true,
projectId: widget.projectId, projectId: widget.projectId,
destinationHost: widget.destinationHost,
indexSource: _selectedItemIndex, indexSource: _selectedItemIndex,
selectedColor: isDesktopLayout(context) ? Theme.of(context).colorScheme.primary : Colors.white, selectedColor: isDesktopLayout(context) ? Theme.of(context).colorScheme.primary : Colors.white,
onSelectedIssueChange: (index, params) { onSelectedIssueChange: (index, params) {
......
...@@ -71,7 +71,6 @@ class _ProjectPageState extends State<ProjectPage> with TickerProviderStateMixin ...@@ -71,7 +71,6 @@ class _ProjectPageState extends State<ProjectPage> with TickerProviderStateMixin
refreshKey: _refreshKey, refreshKey: _refreshKey,
projectId: _projectId, projectId: _projectId,
relativePath: widget.arguments['relativePath'], relativePath: widget.arguments['relativePath'],
destinationHost: ProjectProvider().specifiedHost,
onSelectedIssueChange: isDesktopLayout(context) ? (index, params) => setState(() => _selectedItemParams = params) : null, onSelectedIssueChange: isDesktopLayout(context) ? (index, params) => setState(() => _selectedItemParams = params) : null,
), ),
ProjectMergeRequestPage(arguments: {'relativePath': widget.arguments['relativePath']}), ProjectMergeRequestPage(arguments: {'relativePath': widget.arguments['relativePath']}),
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册