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