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

refactor: #845 RepositoryFileContentFetcher and RepositoryTreeDataFetcher remove destinationHost

上级 13e79e2c
分支
未找到相关标签
无相关合并请求
......@@ -22,8 +22,8 @@ class ProjectRepositoryModel {
void init(String fullPath, String projectName) {
_fullPath = fullPath;
_projectName = projectName;
_treeDataFetcher = RepositoryTreeDataFetcher(_fullPath, ProjectProvider().specifiedHost);
_fileContentFetcher = RepositoryFileContentFetcher(_fullPath, ProjectProvider().specifiedHost);
_treeDataFetcher = RepositoryTreeDataFetcher(_fullPath);
_fileContentFetcher = RepositoryFileContentFetcher(_fullPath);
}
Future<void> getFirst5TreeItems() async {
......
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 FileContent {
String name;
......@@ -16,9 +17,8 @@ class FileContent {
class RepositoryFileContentFetcher {
final String fullPath;
final String? destinationHost;
RepositoryFileContentFetcher(this.fullPath, this.destinationHost);
RepositoryFileContentFetcher(this.fullPath);
Future<FileContent?> fetch({required String path, String? ref}) async {
var body = (await HttpClient.instance().post(_graphql, buildRequestBodyOfFetchFileContent(fullPath, path, ref))).body();
......@@ -39,7 +39,7 @@ class RepositoryFileContentFetcher {
return FileContent(name, rawTextBlob, rawPath, language, fileType, tooLarge);
}
String get _graphql => destinationHost == null ? Api.graphql() : "$destinationHost${Api.graphql()}";
String get _graphql => ProjectProvider().specifiedHost == null ? Api.graphql() : "$ProjectProvider().specifiedHost${Api.graphql()}";
}
Map<String, dynamic> buildRequestBodyOfFetchFileContent(String fullPath, String path, String? ref) {
......
......@@ -21,7 +21,7 @@ class RepositoryFileContentModel {
_name = name;
_ref = ref;
_webUrl = webUrl;
_fileContentFetcher = RepositoryFileContentFetcher(fullPath, destinationHost);
_fileContentFetcher = RepositoryFileContentFetcher(fullPath);
_notifier = ValueNotifier(_loadState);
getFileContent();
}
......
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/projects/repository/repository_tree_item.dart';
class PageInfo {
......@@ -46,9 +47,8 @@ class RepositoryPaginatedTree {
class RepositoryTreeDataFetcher {
final String fullPath;
final String? destinationHost;
RepositoryTreeDataFetcher(this.fullPath, this.destinationHost);
RepositoryTreeDataFetcher(this.fullPath);
Future<RepositoryPaginatedTree> fetch({String nextPageCursor = '', String? flatPath, String? ref}) async {
var body = (await HttpClient.instance().post(_graphql, buildRequestBodyOfRepositoryTree(fullPath, nextPageCursor, path: flatPath, ref: ref))).body();
......@@ -56,7 +56,7 @@ class RepositoryTreeDataFetcher {
return RepositoryPaginatedTree.fromJson(body);
}
String get _graphql => destinationHost == null ? Api.graphql() : "$destinationHost${Api.graphql()}";
String get _graphql => ProjectProvider().specifiedHost == null ? Api.graphql() : "$ProjectProvider().specifiedHost${Api.graphql()}";
}
Map<String, dynamic> buildRequestBodyOfRepositoryTree(String fullPath, String nextPageCursor, {String? path, String? ref}) {
......
......@@ -25,7 +25,7 @@ class RepositoryTreeModel {
_destinationHost = destinationHost;
_pageTitle = pageTitle;
_notifier = ValueNotifier(_repositoryTreeItems);
_dataFetcher = RepositoryTreeDataFetcher(_fullPath, _destinationHost);
_dataFetcher = RepositoryTreeDataFetcher(_fullPath);
refresh();
}
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
想要评论请 注册