Commit c500a212 authored by Erfan Jazeb Nikoo's avatar Erfan Jazeb Nikoo
Browse files

Merge branch 'bugfix/importers_bug_fix' into 'dev'

bugfix/importers_bug_fix

See merge request !380
parents 3615a807 8d59e624
Pipeline #9607 passed with stages
in 6 minutes and 20 seconds
Showing with 30 additions and 33 deletions
+30 -33
import 'dart:convert';
import 'package:memri/constants/app_logger.dart';
import 'package:memri/core/apis/gitlab_api.dart';
import 'package:memri/core/models/pipeline_job.dart';
import 'package:memri/core/services/api_service.dart';
......@@ -63,7 +60,8 @@ class GitlabService extends ApiService<GitlabAPI> {
var userProjects = await getUserProjects();
for (var project in userProjects) {
if ((project['name']) == projectName) {
AppLogger.debug('PROJECT ${_jsonPrettyString(project)}');
// AppLogger.debug(
// 'PROJECT ${JsonEncoder.withIndent(' ').convert(project)}');
return project;
}
}
......@@ -97,6 +95,4 @@ class GitlabService extends ApiService<GitlabAPI> {
}
return jobs;
}
String _jsonPrettyString(dynamic j) => JsonEncoder.withIndent(' ').convert(j);
}
......@@ -205,11 +205,11 @@ class OAuthProvider with ChangeNotifier {
bool get gitlabOAuthExist => _gitlabOAuthItem != null && _gitlabUserExist;
Future<void> initGitlabOAuth() async {
await setGitlabTokens();
if (_gitlabOAuthItem == null) {
_gitlabOAuthStream = _gitlabItemStream();
_gitlabOAuthStreamSubscription = _gitlabOAuthStream!.listen((item) {
_gitlabOAuthItem = item;
setGitlabTokens();
resetGitlabStream();
notifyListeners();
});
......@@ -414,7 +414,7 @@ class OAuthProvider with ChangeNotifier {
Stream<Item> _whatsappItemStream(String id) async* {
while (true) {
await Future.delayed(Duration(milliseconds: 1000));
await Future.delayed(Duration(seconds: 1));
Item? res;
Item? pluginRunItem = await _podService.getItem(id: id);
if (pluginRunItem != null) {
......@@ -423,7 +423,9 @@ class OAuthProvider with ChangeNotifier {
if (res != null) {
yield res;
if (res.get('status') == 'daemon' || res.get('status') == 'done') {
if (res.get('status') == 'daemon' ||
res.get('status') == 'done' ||
res.get('status') == 'aborted') {
cancelWhatsappStreamSubs();
}
}
......
......@@ -685,16 +685,7 @@ class ProjectProvider with ChangeNotifier {
}
void setupProjectPackageStream() {
Stream<bool> checkProjectPackageStream() async* {
while (true) {
await Future.delayed(Duration(seconds: 3));
if (_gitlabService.accessToken != null && gitlabProjectId != null) {
yield await _gitlabService.projectHasModelPackage(gitlabProjectId!);
}
}
}
projectPackageStream = checkProjectPackageStream();
projectPackageStream = _checkProjectPackageStream();
projectPackageSubscription = projectPackageStream!.listen((hasPackage) {
AppLogger.debug('checking model package: $hasPackage');
if (hasPackage != projectHasPackage) {
......@@ -710,22 +701,16 @@ class ProjectProvider with ChangeNotifier {
});
}
void setupProjectPipelineStream() {
Stream<List<PipelineJob>> _projectPipelineStream() async* {
while (true) {
await Future.delayed(Duration(seconds: 3));
if (_gitlabService.accessToken == null ||
gitlabProjectId == null ||
!projectHasPackage) {
continue;
} else {
var pipelines =
await _gitlabService.getPipelineJobs(gitlabProjectId!);
yield pipelines;
}
Stream<bool> _checkProjectPackageStream() async* {
while (true) {
await Future.delayed(Duration(seconds: 3));
if (_gitlabService.accessToken != null && gitlabProjectId != null) {
yield await _gitlabService.projectHasModelPackage(gitlabProjectId!);
}
}
}
void setupProjectPipelineStream() {
projectPipelineStream = _projectPipelineStream();
projectPipelineSubscription = projectPipelineStream!.listen((pipelines) {
AppLogger.debug('found project pipelines: ${pipelines.length}');
......@@ -746,6 +731,20 @@ class ProjectProvider with ChangeNotifier {
});
}
Stream<List<PipelineJob>> _projectPipelineStream() async* {
while (true) {
await Future.delayed(Duration(seconds: 3));
if (_gitlabService.accessToken == null ||
gitlabProjectId == null ||
!projectHasPackage) {
continue;
} else {
var pipelines = await _gitlabService.getPipelineJobs(gitlabProjectId!);
yield pipelines;
}
}
}
// Future<Item?> testGetOauthItem() async {
// var query = '''
// query {
......
......@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.1.8+1
version: 2.1.9+0
environment:
sdk: ">=2.12.0 <3.0.0"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment