added appMinVerReq to check the extension latest version

This commit is contained in:
kodjomoustapha 2023-08-07 19:58:34 +01:00
parent 01061fe64f
commit 2d0beb6b04
8 changed files with 474 additions and 254 deletions

View file

@ -48,30 +48,32 @@ class Source {
bool? isManga;
Source({
this.id = 0,
this.name = '',
this.baseUrl = '',
this.lang = '',
this.typeSource = '',
this.iconUrl = '',
this.dateFormat = '',
this.dateFormatLocale = '',
this.isActive = true,
this.isAdded = false,
this.isNsfw = false,
this.isFullData = false,
this.hasCloudflare = false,
this.isPinned = false,
this.lastUsed = false,
this.apiUrl = "",
this.sourceCodeUrl = "",
this.version = "",
this.versionLast = "",
this.sourceCode = '',
this.headers = '',
this.isManga = true,
});
String? appMinVerReq;
Source(
{this.id = 0,
this.name = '',
this.baseUrl = '',
this.lang = '',
this.typeSource = '',
this.iconUrl = '',
this.dateFormat = '',
this.dateFormatLocale = '',
this.isActive = true,
this.isAdded = false,
this.isNsfw = false,
this.isFullData = false,
this.hasCloudflare = false,
this.isPinned = false,
this.lastUsed = false,
this.apiUrl = "",
this.sourceCodeUrl = "",
this.version = "",
this.versionLast = "",
this.sourceCode = '',
this.headers = '',
this.isManga = true,
this.appMinVerReq = ""});
Source.fromJson(Map<String, dynamic> json) {
name = json['name'];
id = json['id'];
@ -88,5 +90,6 @@ class Source {
version = json['version'];
isManga = json['isManga'] ?? true;
isFullData = json['isFullData'] ?? false;
appMinVerReq = json['appMinVerReq'];
}
}

View file

@ -22,103 +22,108 @@ const SourceSchema = CollectionSchema(
name: r'apiUrl',
type: IsarType.string,
),
r'baseUrl': PropertySchema(
r'appMinVerReq': PropertySchema(
id: 1,
name: r'appMinVerReq',
type: IsarType.string,
),
r'baseUrl': PropertySchema(
id: 2,
name: r'baseUrl',
type: IsarType.string,
),
r'dateFormat': PropertySchema(
id: 2,
id: 3,
name: r'dateFormat',
type: IsarType.string,
),
r'dateFormatLocale': PropertySchema(
id: 3,
id: 4,
name: r'dateFormatLocale',
type: IsarType.string,
),
r'hasCloudflare': PropertySchema(
id: 4,
id: 5,
name: r'hasCloudflare',
type: IsarType.bool,
),
r'headers': PropertySchema(
id: 5,
id: 6,
name: r'headers',
type: IsarType.string,
),
r'iconUrl': PropertySchema(
id: 6,
id: 7,
name: r'iconUrl',
type: IsarType.string,
),
r'isActive': PropertySchema(
id: 7,
id: 8,
name: r'isActive',
type: IsarType.bool,
),
r'isAdded': PropertySchema(
id: 8,
id: 9,
name: r'isAdded',
type: IsarType.bool,
),
r'isFullData': PropertySchema(
id: 9,
id: 10,
name: r'isFullData',
type: IsarType.bool,
),
r'isManga': PropertySchema(
id: 10,
id: 11,
name: r'isManga',
type: IsarType.bool,
),
r'isNsfw': PropertySchema(
id: 11,
id: 12,
name: r'isNsfw',
type: IsarType.bool,
),
r'isPinned': PropertySchema(
id: 12,
id: 13,
name: r'isPinned',
type: IsarType.bool,
),
r'lang': PropertySchema(
id: 13,
id: 14,
name: r'lang',
type: IsarType.string,
),
r'lastUsed': PropertySchema(
id: 14,
id: 15,
name: r'lastUsed',
type: IsarType.bool,
),
r'name': PropertySchema(
id: 15,
id: 16,
name: r'name',
type: IsarType.string,
),
r'sourceCode': PropertySchema(
id: 16,
id: 17,
name: r'sourceCode',
type: IsarType.string,
),
r'sourceCodeUrl': PropertySchema(
id: 17,
id: 18,
name: r'sourceCodeUrl',
type: IsarType.string,
),
r'typeSource': PropertySchema(
id: 18,
id: 19,
name: r'typeSource',
type: IsarType.string,
),
r'version': PropertySchema(
id: 19,
id: 20,
name: r'version',
type: IsarType.string,
),
r'versionLast': PropertySchema(
id: 20,
id: 21,
name: r'versionLast',
type: IsarType.string,
)
@ -149,6 +154,12 @@ int _sourceEstimateSize(
bytesCount += 3 + value.length * 3;
}
}
{
final value = object.appMinVerReq;
if (value != null) {
bytesCount += 3 + value.length * 3;
}
}
{
final value = object.baseUrl;
if (value != null) {
@ -231,26 +242,27 @@ void _sourceSerialize(
Map<Type, List<int>> allOffsets,
) {
writer.writeString(offsets[0], object.apiUrl);
writer.writeString(offsets[1], object.baseUrl);
writer.writeString(offsets[2], object.dateFormat);
writer.writeString(offsets[3], object.dateFormatLocale);
writer.writeBool(offsets[4], object.hasCloudflare);
writer.writeString(offsets[5], object.headers);
writer.writeString(offsets[6], object.iconUrl);
writer.writeBool(offsets[7], object.isActive);
writer.writeBool(offsets[8], object.isAdded);
writer.writeBool(offsets[9], object.isFullData);
writer.writeBool(offsets[10], object.isManga);
writer.writeBool(offsets[11], object.isNsfw);
writer.writeBool(offsets[12], object.isPinned);
writer.writeString(offsets[13], object.lang);
writer.writeBool(offsets[14], object.lastUsed);
writer.writeString(offsets[15], object.name);
writer.writeString(offsets[16], object.sourceCode);
writer.writeString(offsets[17], object.sourceCodeUrl);
writer.writeString(offsets[18], object.typeSource);
writer.writeString(offsets[19], object.version);
writer.writeString(offsets[20], object.versionLast);
writer.writeString(offsets[1], object.appMinVerReq);
writer.writeString(offsets[2], object.baseUrl);
writer.writeString(offsets[3], object.dateFormat);
writer.writeString(offsets[4], object.dateFormatLocale);
writer.writeBool(offsets[5], object.hasCloudflare);
writer.writeString(offsets[6], object.headers);
writer.writeString(offsets[7], object.iconUrl);
writer.writeBool(offsets[8], object.isActive);
writer.writeBool(offsets[9], object.isAdded);
writer.writeBool(offsets[10], object.isFullData);
writer.writeBool(offsets[11], object.isManga);
writer.writeBool(offsets[12], object.isNsfw);
writer.writeBool(offsets[13], object.isPinned);
writer.writeString(offsets[14], object.lang);
writer.writeBool(offsets[15], object.lastUsed);
writer.writeString(offsets[16], object.name);
writer.writeString(offsets[17], object.sourceCode);
writer.writeString(offsets[18], object.sourceCodeUrl);
writer.writeString(offsets[19], object.typeSource);
writer.writeString(offsets[20], object.version);
writer.writeString(offsets[21], object.versionLast);
}
Source _sourceDeserialize(
@ -261,27 +273,28 @@ Source _sourceDeserialize(
) {
final object = Source(
apiUrl: reader.readStringOrNull(offsets[0]),
baseUrl: reader.readStringOrNull(offsets[1]),
dateFormat: reader.readStringOrNull(offsets[2]),
dateFormatLocale: reader.readStringOrNull(offsets[3]),
hasCloudflare: reader.readBoolOrNull(offsets[4]),
headers: reader.readStringOrNull(offsets[5]),
iconUrl: reader.readStringOrNull(offsets[6]),
appMinVerReq: reader.readStringOrNull(offsets[1]),
baseUrl: reader.readStringOrNull(offsets[2]),
dateFormat: reader.readStringOrNull(offsets[3]),
dateFormatLocale: reader.readStringOrNull(offsets[4]),
hasCloudflare: reader.readBoolOrNull(offsets[5]),
headers: reader.readStringOrNull(offsets[6]),
iconUrl: reader.readStringOrNull(offsets[7]),
id: id,
isActive: reader.readBoolOrNull(offsets[7]),
isAdded: reader.readBoolOrNull(offsets[8]),
isFullData: reader.readBoolOrNull(offsets[9]),
isManga: reader.readBoolOrNull(offsets[10]),
isNsfw: reader.readBoolOrNull(offsets[11]),
isPinned: reader.readBoolOrNull(offsets[12]),
lang: reader.readStringOrNull(offsets[13]),
lastUsed: reader.readBoolOrNull(offsets[14]),
name: reader.readStringOrNull(offsets[15]),
sourceCode: reader.readStringOrNull(offsets[16]),
sourceCodeUrl: reader.readStringOrNull(offsets[17]),
typeSource: reader.readStringOrNull(offsets[18]),
version: reader.readStringOrNull(offsets[19]),
versionLast: reader.readStringOrNull(offsets[20]),
isActive: reader.readBoolOrNull(offsets[8]),
isAdded: reader.readBoolOrNull(offsets[9]),
isFullData: reader.readBoolOrNull(offsets[10]),
isManga: reader.readBoolOrNull(offsets[11]),
isNsfw: reader.readBoolOrNull(offsets[12]),
isPinned: reader.readBoolOrNull(offsets[13]),
lang: reader.readStringOrNull(offsets[14]),
lastUsed: reader.readBoolOrNull(offsets[15]),
name: reader.readStringOrNull(offsets[16]),
sourceCode: reader.readStringOrNull(offsets[17]),
sourceCodeUrl: reader.readStringOrNull(offsets[18]),
typeSource: reader.readStringOrNull(offsets[19]),
version: reader.readStringOrNull(offsets[20]),
versionLast: reader.readStringOrNull(offsets[21]),
);
return object;
}
@ -302,13 +315,13 @@ P _sourceDeserializeProp<P>(
case 3:
return (reader.readStringOrNull(offset)) as P;
case 4:
return (reader.readBoolOrNull(offset)) as P;
case 5:
return (reader.readStringOrNull(offset)) as P;
case 5:
return (reader.readBoolOrNull(offset)) as P;
case 6:
return (reader.readStringOrNull(offset)) as P;
case 7:
return (reader.readBoolOrNull(offset)) as P;
return (reader.readStringOrNull(offset)) as P;
case 8:
return (reader.readBoolOrNull(offset)) as P;
case 9:
@ -320,11 +333,11 @@ P _sourceDeserializeProp<P>(
case 12:
return (reader.readBoolOrNull(offset)) as P;
case 13:
return (reader.readStringOrNull(offset)) as P;
case 14:
return (reader.readBoolOrNull(offset)) as P;
case 15:
case 14:
return (reader.readStringOrNull(offset)) as P;
case 15:
return (reader.readBoolOrNull(offset)) as P;
case 16:
return (reader.readStringOrNull(offset)) as P;
case 17:
@ -335,6 +348,8 @@ P _sourceDeserializeProp<P>(
return (reader.readStringOrNull(offset)) as P;
case 20:
return (reader.readStringOrNull(offset)) as P;
case 21:
return (reader.readStringOrNull(offset)) as P;
default:
throw IsarError('Unknown property with id $propertyId');
}
@ -574,6 +589,152 @@ extension SourceQueryFilter on QueryBuilder<Source, Source, QFilterCondition> {
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'appMinVerReq',
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'appMinVerReq',
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqEqualTo(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'appMinVerReq',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqGreaterThan(
String? value, {
bool include = false,
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
include: include,
property: r'appMinVerReq',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqLessThan(
String? value, {
bool include = false,
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.lessThan(
include: include,
property: r'appMinVerReq',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqBetween(
String? lower,
String? upper, {
bool includeLower = true,
bool includeUpper = true,
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.between(
property: r'appMinVerReq',
lower: lower,
includeLower: includeLower,
upper: upper,
includeUpper: includeUpper,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqStartsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.startsWith(
property: r'appMinVerReq',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqEndsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.endsWith(
property: r'appMinVerReq',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqContains(
String value,
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.contains(
property: r'appMinVerReq',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqMatches(
String pattern,
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.matches(
property: r'appMinVerReq',
wildcard: pattern,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqIsEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'appMinVerReq',
value: '',
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> appMinVerReqIsNotEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
property: r'appMinVerReq',
value: '',
));
});
}
QueryBuilder<Source, Source, QAfterFilterCondition> baseUrlIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
@ -2624,6 +2785,18 @@ extension SourceQuerySortBy on QueryBuilder<Source, Source, QSortBy> {
});
}
QueryBuilder<Source, Source, QAfterSortBy> sortByAppMinVerReq() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'appMinVerReq', Sort.asc);
});
}
QueryBuilder<Source, Source, QAfterSortBy> sortByAppMinVerReqDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'appMinVerReq', Sort.desc);
});
}
QueryBuilder<Source, Source, QAfterSortBy> sortByBaseUrl() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'baseUrl', Sort.asc);
@ -2878,6 +3051,18 @@ extension SourceQuerySortThenBy on QueryBuilder<Source, Source, QSortThenBy> {
});
}
QueryBuilder<Source, Source, QAfterSortBy> thenByAppMinVerReq() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'appMinVerReq', Sort.asc);
});
}
QueryBuilder<Source, Source, QAfterSortBy> thenByAppMinVerReqDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'appMinVerReq', Sort.desc);
});
}
QueryBuilder<Source, Source, QAfterSortBy> thenByBaseUrl() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'baseUrl', Sort.asc);
@ -3139,6 +3324,13 @@ extension SourceQueryWhereDistinct on QueryBuilder<Source, Source, QDistinct> {
});
}
QueryBuilder<Source, Source, QDistinct> distinctByAppMinVerReq(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'appMinVerReq', caseSensitive: caseSensitive);
});
}
QueryBuilder<Source, Source, QDistinct> distinctByBaseUrl(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
@ -3287,6 +3479,12 @@ extension SourceQueryProperty on QueryBuilder<Source, Source, QQueryProperty> {
});
}
QueryBuilder<Source, String?, QQueryOperations> appMinVerReqProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'appMinVerReq');
});
}
QueryBuilder<Source, String?, QQueryOperations> baseUrlProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'baseUrl');

View file

@ -3,12 +3,14 @@ import 'package:mangayomi/main.dart';
import 'package:mangayomi/models/settings.dart';
import 'package:mangayomi/models/source.dart';
import 'package:mangayomi/modules/browse/extension/providers/fetch_manga_sources.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:http/http.dart' as http;
part 'fetch_anime_sources.g.dart';
@riverpod
Future fetchAnimeSourcesList(FetchAnimeSourcesListRef ref, {int? id}) async {
final info = await PackageInfo.fromPlatform();
final req = await http.get(Uri.parse(
"https://kodjodevf.github.io/mangayomi-extensions/anime_index.json"));
final res = jsonDecode(req.body) as List;
@ -17,19 +19,80 @@ Future fetchAnimeSourcesList(FetchAnimeSourcesListRef ref, {int? id}) async {
isar.writeTxnSync(() async {
for (var source in sourceList) {
if (!source.isManga!) {
if (id != null) {
if (id == source.id) {
final sourc = isar.sources.getSync(id)!;
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers ?? ""
..isAdded = true
..sourceCode = req.body
if (source.appMinVerReq != null) {
if (compareVersions(info.version, source.appMinVerReq!) > -1) {
if (!source.isManga!) {
if (id != null) {
if (id == source.id) {
final sourc = isar.sources.getSync(id)!;
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers ?? ""
..isAdded = true
..sourceCode = req.body
..sourceCodeUrl = source.sourceCodeUrl
..id = id
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData ?? false
..appMinVerReq = source.appMinVerReq);
});
// log("successfully installed");
}
} else if (isar.sources.getSync(source.id!) != null) {
// log("exist");
final sourc = isar.sources.getSync(source.id!)!;
if (compareVersions(sourc.version!, source.version!) < 0) {
// log("update aivalable auto update");
if (isar.settings.getSync(227)!.autoUpdateExtensions ?? false) {
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers
..sourceCode = req.body
..sourceCodeUrl = source.sourceCodeUrl
..id = source.id
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..isFullData = source.isFullData ?? false
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData
..appMinVerReq = source.appMinVerReq);
});
} else {
// log("update aivalable");
isar.sources.putSync(sourc..versionLast = source.version);
}
}
} else {
isar.sources.putSync(Source()
..sourceCodeUrl = source.sourceCodeUrl
..id = id
..id = source.id
..sourceCode = source.sourceCode
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
@ -43,64 +106,11 @@ Future fetchAnimeSourcesList(FetchAnimeSourcesListRef ref, {int? id}) async {
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData ?? false);
});
// log("successfully installed");
}
} else if (isar.sources.getSync(source.id!) != null) {
// log("exist");
final sourc = isar.sources.getSync(source.id!)!;
if (compareVersions(sourc.version!, source.version!) < 0) {
// log("update aivalable auto update");
if (isar.settings.getSync(227)!.autoUpdateExtensions ?? false) {
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers
..sourceCode = req.body
..sourceCodeUrl = source.sourceCodeUrl
..id = source.id
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..isFullData = source.isFullData ?? false
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga);
});
} else {
// log("update aivalable");
isar.sources.putSync(sourc..versionLast = source.version);
..isFullData = source.isFullData ?? false
..appMinVerReq = source.appMinVerReq);
// log("new source");
}
}
} else {
isar.sources.putSync(Source()
..sourceCodeUrl = source.sourceCodeUrl
..id = source.id
..sourceCode = source.sourceCode
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData ?? false);
// log("new source");
}
}
}

View file

@ -5,12 +5,14 @@ import 'package:mangayomi/eval/runtime/runtime.dart';
import 'package:mangayomi/main.dart';
import 'package:mangayomi/models/settings.dart';
import 'package:mangayomi/models/source.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:http/http.dart' as http;
part 'fetch_manga_sources.g.dart';
@riverpod
Future fetchMangaSourcesList(FetchMangaSourcesListRef ref, {int? id}) async {
final info = await PackageInfo.fromPlatform();
final req = await http.get(
Uri.parse("https://kodjodevf.github.io/mangayomi-extensions/index.json"));
final res = jsonDecode(req.body) as List;
@ -19,19 +21,80 @@ Future fetchMangaSourcesList(FetchMangaSourcesListRef ref, {int? id}) async {
isar.writeTxnSync(() async {
for (var source in sourceList) {
if (source.isManga!) {
if (id != null) {
if (id == source.id) {
final sourc = isar.sources.getSync(id)!;
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers ?? ""
..isAdded = true
..sourceCode = req.body
if (source.appMinVerReq != null) {
if (compareVersions(info.version, source.appMinVerReq!) > -1) {
if (source.isManga!) {
if (id != null) {
if (id == source.id) {
final sourc = isar.sources.getSync(id)!;
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers ?? ""
..isAdded = true
..sourceCode = req.body
..sourceCodeUrl = source.sourceCodeUrl
..id = id
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData ?? false
..appMinVerReq = source.appMinVerReq);
});
// log("successfully installed");
}
} else if (isar.sources.getSync(source.id!) != null) {
// log("exist");
final sourc = isar.sources.getSync(source.id!)!;
if (compareVersions(sourc.version!, source.version!) < 0) {
// log("update aivalable auto update");
if (isar.settings.getSync(227)!.autoUpdateExtensions ?? false) {
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers
..sourceCode = req.body
..sourceCodeUrl = source.sourceCodeUrl
..id = source.id
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..isFullData = source.isFullData ?? false
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData
..appMinVerReq = source.appMinVerReq);
});
} else {
// log("update aivalable");
isar.sources.putSync(sourc..versionLast = source.version);
}
}
} else {
isar.sources.putSync(Source()
..sourceCodeUrl = source.sourceCodeUrl
..id = id
..id = source.id
..sourceCode = source.sourceCode
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
@ -45,64 +108,11 @@ Future fetchMangaSourcesList(FetchMangaSourcesListRef ref, {int? id}) async {
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData ?? false);
});
// log("successfully installed");
}
} else if (isar.sources.getSync(source.id!) != null) {
// log("exist");
final sourc = isar.sources.getSync(source.id!)!;
if (compareVersions(sourc.version!, source.version!) < 0) {
// log("update aivalable auto update");
if (isar.settings.getSync(227)!.autoUpdateExtensions ?? false) {
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
final headers = await getHeaders(req.body, source.baseUrl!);
isar.writeTxnSync(() {
isar.sources.putSync(sourc
..headers = headers
..sourceCode = req.body
..sourceCodeUrl = source.sourceCodeUrl
..id = source.id
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..isFullData = source.isFullData ?? false
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga);
});
} else {
// log("update aivalable");
isar.sources.putSync(sourc..versionLast = source.version);
..isFullData = source.isFullData ?? false
..appMinVerReq = source.appMinVerReq);
// log("new source");
}
}
} else {
isar.sources.putSync(Source()
..sourceCodeUrl = source.sourceCodeUrl
..id = source.id
..sourceCode = source.sourceCode
..apiUrl = source.apiUrl
..baseUrl = source.baseUrl
..dateFormat = source.dateFormat
..dateFormatLocale = source.dateFormatLocale
..hasCloudflare = source.hasCloudflare
..iconUrl = source.iconUrl
..typeSource = source.typeSource
..lang = source.lang
..isNsfw = source.isNsfw
..name = source.name
..version = source.version
..versionLast = source.version
..isManga = source.isManga
..isFullData = source.isFullData ?? false);
// log("new source");
}
}
}

View file

@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mangayomi/models/source.dart';
@ -36,31 +37,29 @@ class _ExtensionListTileWidgetState
// onChanged(!value);
},
leading: Container(
height: 37,
width: 37,
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor.withOpacity(0.5),
borderRadius: BorderRadius.circular(5)),
child:
// iconUrl.isEmpty
// ?
const Icon(Icons.source_outlined)
// : CachedNetworkImage(
// imageUrl: iconUrl,
// fit: BoxFit.contain,
// width: 37,
// height: 37,
// errorWidget: (context, url, error) {
// return const SizedBox(
// width: 37,
// height: 37,
// child: Center(
// child: Icon(Icons.source_outlined),
// ),
// );
// },
// ),
),
height: 37,
width: 37,
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor.withOpacity(0.5),
borderRadius: BorderRadius.circular(5)),
child: widget.source.iconUrl!.isEmpty
? const Icon(Icons.source_outlined)
: CachedNetworkImage(
imageUrl: widget.source.iconUrl!,
fit: BoxFit.contain,
width: 37,
height: 37,
errorWidget: (context, url, error) {
return const SizedBox(
width: 37,
height: 37,
child: Center(
child: Icon(Icons.source_outlined),
),
);
},
),
),
title: Text(widget.source.name!),
subtitle: Row(
crossAxisAlignment: CrossAxisAlignment.end,

View file

@ -6,7 +6,7 @@ part of 'download_provider.dart';
// RiverpodGenerator
// **************************************************************************
String _$downloadChapterHash() => r'f60e8bbbd4b1bd05f7cb52c08be0f2462d465e8e';
String _$downloadChapterHash() => r'5e55ae9ab9e6a6738f61ee744dd6c8baf4be0fd3';
/// Copied from Dart SDK
class _SystemHash {

View file

@ -6,7 +6,7 @@ part of 'check_for_update.dart';
// RiverpodGenerator
// **************************************************************************
String _$checkForUpdateHash() => r'15446e5da6f28a873be47b541a9c4f0f144520c5';
String _$checkForUpdateHash() => r'2b857a33efbdf16c0d3ccdd8217b9ce472de605f';
/// Copied from Dart SDK
class _SystemHash {

View file

@ -1,7 +1,7 @@
name: mangayomi
description: Free and open source manga reader multi plateform app inspired by Tachiyomi.
version: 0.0.2+5
version: 0.0.25+6
environment:
sdk: '>=3.0.6 <4.0.0'