Compare commits
3 Commits
dev
...
discord-bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5395c7f64f | ||
|
|
23c5d9c1f0 | ||
|
|
75959f0672 |
2
.gitignore
vendored
@@ -100,8 +100,6 @@ firka/debug-info/
|
|||||||
**/.env*
|
**/.env*
|
||||||
**/*.dart.js
|
**/*.dart.js
|
||||||
**/*.info.json
|
**/*.info.json
|
||||||
**/*.g.dart
|
|
||||||
**/.codegen-cache.yaml
|
|
||||||
|
|
||||||
# tools.py logs
|
# tools.py logs
|
||||||
tool_logs/build/*.log
|
tool_logs/build/*.log
|
||||||
|
|||||||
@@ -111,40 +111,27 @@ steps:
|
|||||||
- name: build-release
|
- name: build-release
|
||||||
image: git.firka.app/firka/firka-builder:latest
|
image: git.firka.app/firka/firka-builder:latest
|
||||||
when:
|
when:
|
||||||
- branch: [main, staging]
|
- branch: main
|
||||||
commands:
|
commands:
|
||||||
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
||||||
- cd firka
|
- cd firka
|
||||||
- '[ -f "$(git rev-parse --git-dir)/shallow" ] && git fetch --unshallow 2>/dev/null || true'
|
- flutter build appbundle --release
|
||||||
- SHA=$(git rev-parse --short HEAD)
|
|
||||||
- COMMIT_COUNT=$(git rev-list --count HEAD)
|
|
||||||
- 'BASE_VERSION=$(grep "^version:" pubspec.yaml | cut -d: -f2 | cut -d+ -f1 | tr -d " ")'
|
|
||||||
- BUILD_NAME="$BASE_VERSION-$SHA"
|
|
||||||
- VERSION_CODE=$((2000 + COMMIT_COUNT))
|
|
||||||
- flutter build appbundle --release --build-name="$BUILD_NAME" --build-number="$VERSION_CODE"
|
|
||||||
|
|
||||||
- name: build-debug
|
- name: build-debug
|
||||||
image: git.firka.app/firka/firka-builder:latest
|
image: git.firka.app/firka/firka-builder:latest
|
||||||
when:
|
when:
|
||||||
- branch:
|
- branch:
|
||||||
exclude: [main, staging]
|
exclude: main
|
||||||
commands:
|
commands:
|
||||||
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
||||||
- cd firka
|
- cd firka
|
||||||
- '[ -f "$(git rev-parse --git-dir)/shallow" ] && git fetch --unshallow 2>/dev/null || true'
|
- flutter build apk --debug --split-per-abi
|
||||||
- SHA=$(git rev-parse --short HEAD)
|
|
||||||
- COMMIT_COUNT=$(git rev-list --count HEAD)
|
|
||||||
- 'BASE_VERSION=$(grep "^version:" pubspec.yaml | cut -d: -f2 | cut -d+ -f1 | tr -d " ")'
|
|
||||||
- BUILD_NAME="$BASE_VERSION-$SHA"
|
|
||||||
- VERSION_CODE=$((2000 + COMMIT_COUNT))
|
|
||||||
- flutter build apk --debug --split-per-abi --build-name="$BUILD_NAME" --build-number="$VERSION_CODE"
|
|
||||||
|
|
||||||
|
|
||||||
- name: publish-release
|
- name: publish-release
|
||||||
image: woodpeckercommunity/plugin-gitea-package:latest
|
image: woodpeckercommunity/plugin-gitea-package:latest
|
||||||
pull: true
|
pull: true
|
||||||
when:
|
when:
|
||||||
- branch: [main, staging]
|
- branch: main
|
||||||
settings:
|
settings:
|
||||||
user:
|
user:
|
||||||
from_secret: gitea_username
|
from_secret: gitea_username
|
||||||
@@ -162,7 +149,7 @@ steps:
|
|||||||
pull: true
|
pull: true
|
||||||
when:
|
when:
|
||||||
- branch:
|
- branch:
|
||||||
exclude: [main, staging]
|
exclude: main
|
||||||
settings:
|
settings:
|
||||||
user:
|
user:
|
||||||
from_secret: gitea_username
|
from_secret: gitea_username
|
||||||
@@ -180,7 +167,7 @@ steps:
|
|||||||
pull: true
|
pull: true
|
||||||
when:
|
when:
|
||||||
- branch:
|
- branch:
|
||||||
exclude: [main, staging]
|
exclude: main
|
||||||
settings:
|
settings:
|
||||||
user:
|
user:
|
||||||
from_secret: gitea_username
|
from_secret: gitea_username
|
||||||
@@ -198,7 +185,7 @@ steps:
|
|||||||
pull: true
|
pull: true
|
||||||
when:
|
when:
|
||||||
- branch:
|
- branch:
|
||||||
exclude: [main, staging]
|
exclude: main
|
||||||
settings:
|
settings:
|
||||||
user:
|
user:
|
||||||
from_secret: gitea_username
|
from_secret: gitea_username
|
||||||
@@ -210,4 +197,3 @@ steps:
|
|||||||
file_source: ./firka/build/app/outputs/flutter-apk/app-x86_64-debug.apk
|
file_source: ./firka/build/app/outputs/flutter-apk/app-x86_64-debug.apk
|
||||||
file_name: app-x86_64-debug.apk
|
file_name: app-x86_64-debug.apk
|
||||||
update: 'true'
|
update: 'true'
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ android {
|
|||||||
if (config != null) {
|
if (config != null) {
|
||||||
signingConfig = config
|
signingConfig = config
|
||||||
}
|
}
|
||||||
proguardFiles("proguard-rules.pro")
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,26 +94,6 @@ tasks.register("ensureEnv") {
|
|||||||
tasks.matching { it.name.startsWith("compileFlutterBuild") }.configureEach {
|
tasks.matching { it.name.startsWith("compileFlutterBuild") }.configureEach {
|
||||||
dependsOn("ensureEnv")
|
dependsOn("ensureEnv")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure default ProGuard files exist at the projectDir location expected by AGP/R8 when build directory is relocated
|
|
||||||
val defaultProguardDir = file("${project.projectDir}/build/intermediates/default_proguard_files/global")
|
|
||||||
defaultProguardDir.mkdirs()
|
|
||||||
val defaultProguardOptimize = File(defaultProguardDir, "proguard-android-optimize.txt-9.2.0")
|
|
||||||
if (!defaultProguardOptimize.exists()) {
|
|
||||||
defaultProguardOptimize.writeText("-allowaccessmodification\n")
|
|
||||||
}
|
|
||||||
tasks.register("ensureProguardFiles") {
|
|
||||||
doLast {
|
|
||||||
defaultProguardDir.mkdirs()
|
|
||||||
if (!defaultProguardOptimize.exists()) {
|
|
||||||
defaultProguardOptimize.writeText("-allowaccessmodification\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tasks.matching { it.name.startsWith("compile") || it.name.contains("minify", ignoreCase = true) || it.name.contains("r8", ignoreCase = true) }.configureEach {
|
|
||||||
dependsOn("ensureProguardFiles")
|
|
||||||
}
|
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
source = "../.."
|
source = "../.."
|
||||||
}
|
}
|
||||||
74
firka/android/app/proguard-rules.pro
vendored
@@ -1,75 +1 @@
|
|||||||
# Firka custom keep rules
|
|
||||||
-keep class app.firka.naplo.glance.** { *; }
|
-keep class app.firka.naplo.glance.** { *; }
|
||||||
|
|
||||||
# Android optimize rules (-allowaccessmodification)
|
|
||||||
-allowaccessmodification
|
|
||||||
|
|
||||||
# Android common keep rules
|
|
||||||
-keepattributes AnnotationDefault,
|
|
||||||
EnclosingMethod,
|
|
||||||
InnerClasses,
|
|
||||||
RuntimeVisibleAnnotations,
|
|
||||||
RuntimeVisibleParameterAnnotations,
|
|
||||||
RuntimeVisibleTypeAnnotations,
|
|
||||||
Signature
|
|
||||||
|
|
||||||
-keep public class com.google.vending.licensing.ILicensingService
|
|
||||||
-keep public class com.android.vending.licensing.ILicensingService
|
|
||||||
-keep public class com.google.android.vending.licensing.ILicensingService
|
|
||||||
-dontnote com.android.vending.licensing.ILicensingService
|
|
||||||
-dontnote com.google.vending.licensing.ILicensingService
|
|
||||||
-dontnote com.google.android.vending.licensing.ILicensingService
|
|
||||||
|
|
||||||
# Native methods
|
|
||||||
-keepclasseswithmembernames,includedescriptorclasses class * {
|
|
||||||
native <methods>;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Keep setters in Views so that animations can still work.
|
|
||||||
-keepclassmembers public class * extends android.view.View {
|
|
||||||
void set*(***);
|
|
||||||
*** get*();
|
|
||||||
}
|
|
||||||
|
|
||||||
# We want to keep methods in Activity that could be used in the XML attribute onClick.
|
|
||||||
-keepclassmembers class * extends android.app.Activity {
|
|
||||||
public void *(android.view.View);
|
|
||||||
}
|
|
||||||
|
|
||||||
# For enumeration classes
|
|
||||||
-keepclassmembers enum * {
|
|
||||||
public static **[] values();
|
|
||||||
public static ** valueOf(java.lang.String);
|
|
||||||
}
|
|
||||||
|
|
||||||
-keepclassmembers class * implements android.os.Parcelable {
|
|
||||||
public static final ** CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Preserve annotated Javascript interface methods.
|
|
||||||
-keepclassmembers class * {
|
|
||||||
@android.webkit.JavascriptInterface <methods>;
|
|
||||||
}
|
|
||||||
|
|
||||||
# The support libraries contains references to newer platform versions.
|
|
||||||
-dontnote android.support.**
|
|
||||||
-dontnote androidx.**
|
|
||||||
-dontwarn android.support.**
|
|
||||||
-dontwarn androidx.**
|
|
||||||
|
|
||||||
# Understand the @Keep support annotation.
|
|
||||||
-keep class android.support.annotation.Keep
|
|
||||||
-keep @android.support.annotation.Keep class * {*;}
|
|
||||||
-keepclasseswithmembers class * {
|
|
||||||
@android.support.annotation.Keep <methods>;
|
|
||||||
}
|
|
||||||
-keepclasseswithmembers class * {
|
|
||||||
@android.support.annotation.Keep <fields>;
|
|
||||||
}
|
|
||||||
-keepclasseswithmembers class * {
|
|
||||||
@android.support.annotation.Keep <init>(...);
|
|
||||||
}
|
|
||||||
|
|
||||||
-dontnote org.apache.http.**
|
|
||||||
-dontnote android.net.http.**
|
|
||||||
-dontnote java.lang.invoke.**
|
|
||||||
@@ -15,6 +15,3 @@ kotlin.incremental.useClasspathSnapshot=true
|
|||||||
android.builtInKotlin=false
|
android.builtInKotlin=false
|
||||||
|
|
||||||
android.newDsl=false
|
android.newDsl=false
|
||||||
|
|
||||||
# Prevent AGP 9.0+ build failures due to relocated build directory ProGuard path mismatches
|
|
||||||
android.proguard.failOnMissingFiles=false
|
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
icons:
|
icons:
|
||||||
"flutter_launcher_icons.yaml": "993c1cd3a99db70747299601e556d19ec959b0a16fd9ff2dbf2386cb6f2a640d"
|
"flutter_launcher_icons.yaml": "5686b5de26010925e393210c241415c6b04ef1ac6737255dc62d97da891fe39e"
|
||||||
"pubspec.yaml": "198608775541fab3b6ff8cc21545e12a3413455f6ed87355cfdb576a97efab2d"
|
"pubspec.yaml": "198608775541fab3b6ff8cc21545e12a3413455f6ed87355cfdb576a97efab2d"
|
||||||
"assets/images/logos/colored_logo.webp": "4b4fa99d144fe6694aa4487ba1b26aeecafae41e3c877836cd7da28d61a77983"
|
"assets/images/logos/colored_logo.webp": "4b4fa99d144fe6694aa4487ba1b26aeecafae41e3c877836cd7da28d61a77983"
|
||||||
"assets/images/logos/monochrome_logo.png": "c269a5e689622484d800a4fda5927591a0bf99d34790a4f146b93cf6edabd455"
|
"assets/images/logos/monochrome_logo.png": "c269a5e689622484d800a4fda5927591a0bf99d34790a4f146b93cf6edabd455"
|
||||||
"assets/images/logos/colored_logo_without_mustache.png": "d11cff9f38985885873bfdd2d84e61f8fab03803eada94d4caac1545ef3685f3"
|
"assets/images/logos/colored_logo_without_mustache.png": "d11cff9f38985885873bfdd2d84e61f8fab03803eada94d4caac1545ef3685f3"
|
||||||
"assets/images/logos/colored_logo_only_mustache.png": "bad6220c11bdfb1dfe04e5173bd2ebedd3999689d4b3a68fc63dc520c96dd33b"
|
"assets/images/logos/colored_logo_only_mustache.png": "bad6220c11bdfb1dfe04e5173bd2ebedd3999689d4b3a68fc63dc520c96dd33b"
|
||||||
|
l10n:
|
||||||
|
"l10n.yml": "a57bc304cac4a2b0235593586f17f400a5165d67fc9aadeaa11893cfa36ee082"
|
||||||
|
"lib/l10n/app_pl.arb": "a8426455757e587c7635c3a62c650a4aae2a0cac1de1175e8ab7fb0d3b387537"
|
||||||
|
"lib/l10n/app_de.arb": "c498950bbc917e35b1910451ad9fbd4e625db89151f07558e846a7c119a583af"
|
||||||
|
"lib/l10n/app_en.arb": "159405752b5e73eedbe546a59567550091926a37cf9cf6ce78dd58f1a0dd1d4b"
|
||||||
|
"lib/l10n/app_hu.arb": "c7fba2a8f91217433698d766e9451d8fad86ae71021adf714639fc3907a34891"
|
||||||
|
isar:
|
||||||
|
"lib/data/models/app_settings_model.dart": "5eb5af345f1347f104257f0999763650fe2673f9da1754bd12d3f756fe5c9723"
|
||||||
|
"lib/data/models/token_model.dart": "8c957cd07e473827d78fd8fd4fb6c1336b636a69c25c93618e1e7f94b7cf0683"
|
||||||
|
"lib/data/models/homework_cache_model.dart": "45789970b27d5790cdc54c292ef2f5feaa5f4e293b8a8862fd676d5eb3e25d29"
|
||||||
|
"lib/data/models/generic_cache_model.dart": "62003ec1fd73a0fa6786d337acdef42b9a6eb9efaa78d17eaf4fe091504b8490"
|
||||||
|
"lib/data/models/timetable_cache_model.dart": "b972bf51e399f8d20d4f9ad660082d4cc4a9798df9ac9d6ec9ef6ac640205572"
|
||||||
splash:
|
splash:
|
||||||
"flutter_native_splash.yaml": "f1bddb74798b1539c4e9213ca9ae305d625ebb0ac5bcbe079b523437e0abc2c4"
|
"flutter_native_splash.yaml": "0fd4a85d6f950d97298e99916927649940ffcfdadfc136ceee126fed0dbaa9f2"
|
||||||
"assets/images/logos/splash.png": "88fbebc3d686cb9095bcce362029b69978b1b14270e465e91d962b1425db1152"
|
"assets/images/logos/splash.png": "88fbebc3d686cb9095bcce362029b69978b1b14270e465e91d962b1425db1152"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
generate: true
|
generate: true
|
||||||
android: "launcher_icon"
|
android: "launcher_icon"
|
||||||
ios: false
|
|
||||||
image_path: "assets/images/logos/colored_logo.webp"
|
image_path: "assets/images/logos/colored_logo.webp"
|
||||||
adaptive_icon_monochrome: "assets/images/logos/monochrome_logo.png"
|
adaptive_icon_monochrome: "assets/images/logos/monochrome_logo.png"
|
||||||
adaptive_icon_background: "assets/images/logos/colored_logo_without_mustache.png"
|
adaptive_icon_background: "assets/images/logos/colored_logo_without_mustache.png"
|
||||||
|
|||||||
@@ -17,6 +17,4 @@ flutter_native_splash:
|
|||||||
icon_background_color: "#7ca120"
|
icon_background_color: "#7ca120"
|
||||||
icon_background_color_dark: "#7ca120"
|
icon_background_color_dark: "#7ca120"
|
||||||
|
|
||||||
android: true
|
|
||||||
ios: false
|
|
||||||
web: false
|
web: false
|
||||||
|
|||||||
22
firka/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "background.png",
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filename" : "darkbackground.png",
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
firka/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png
vendored
Normal file
|
After Width: | Height: | Size: 69 B |
BIN
firka/ios/Runner/Assets.xcassets/LaunchBackground.imageset/darkbackground.png
vendored
Normal file
|
After Width: | Height: | Size: 69 B |
56
firka/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "LaunchImage.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filename" : "LaunchImageDark.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "LaunchImage@2x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filename" : "LaunchImageDark@2x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "LaunchImage@3x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filename" : "LaunchImageDark@3x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
firka/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
vendored
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
firka/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
firka/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
firka/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImageDark.png
vendored
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
firka/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImageDark@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
firka/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImageDark@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 24 KiB |
44
firka/ios/Runner/Base.lproj/LaunchScreen.storyboard
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<layoutGuides>
|
||||||
|
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
|
||||||
|
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
|
||||||
|
</layoutGuides>
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI"/>
|
||||||
|
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"></imageView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
|
||||||
|
<constraint firstItem="tWc-Dq-wcI" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="RPx-PI-7Xg"/>
|
||||||
|
<constraint firstItem="tWc-Dq-wcI" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="SdS-ul-q2q"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="tWc-Dq-wcI" secondAttribute="trailing" id="Swv-Gf-Rwn"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="YRO-k0-Ey4" secondAttribute="trailing" id="TQA-XW-tRk"/>
|
||||||
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="duK-uY-Gun"/>
|
||||||
|
<constraint firstItem="tWc-Dq-wcI" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="kV7-tw-vXt"/>
|
||||||
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xPn-NY-SIU"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<image name="LaunchImage" width="600" height="600"/>
|
||||||
|
<image name="LaunchBackground" width="1" height="1"/>
|
||||||
|
</resources>
|
||||||
|
</document>
|
||||||
@@ -456,21 +456,10 @@ class KretaClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Upserts [caches]. Deletes stale rows in [staleScope].
|
|
||||||
Future<List<C>> _save<C extends GenericCacheModel<I>, I extends Identifiable>(
|
Future<List<C>> _save<C extends GenericCacheModel<I>, I extends Identifiable>(
|
||||||
List<C> caches, [
|
List<C> caches,
|
||||||
QueryBuilder<C, C, QAfterFilterCondition>? staleScope,
|
) async {
|
||||||
]) async {
|
|
||||||
isarInit.writeTxnSync(() {
|
isarInit.writeTxnSync(() {
|
||||||
if (staleScope != null) {
|
|
||||||
final freshKeys = caches.map((c) => c.cacheKey).toSet();
|
|
||||||
final staleIds = staleScope
|
|
||||||
.findAllSync()
|
|
||||||
.map((c) => c.cacheKey)
|
|
||||||
.where((key) => !freshKeys.contains(key))
|
|
||||||
.toList();
|
|
||||||
isarInit.collection<C>().deleteAllSync(staleIds);
|
|
||||||
}
|
|
||||||
isarInit.collection<C>().putAllSync(caches);
|
isarInit.collection<C>().putAllSync(caches);
|
||||||
});
|
});
|
||||||
initData.homeRefreshCubit.requestRefresh();
|
initData.homeRefreshCubit.requestRefresh();
|
||||||
@@ -531,7 +520,7 @@ class KretaClient {
|
|||||||
KretaEndpoints.getGrades(cache.token.iss),
|
KretaEndpoints.getGrades(cache.token.iss),
|
||||||
GradeCacheModel.new,
|
GradeCacheModel.new,
|
||||||
(json) => Grade.fromJson(json),
|
(json) => Grade.fromJson(json),
|
||||||
).then((caches) => _save(caches, cache.getGrades()));
|
).then(_save);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<HomeworkCacheModel>> getHomework({
|
Future<List<HomeworkCacheModel>> getHomework({
|
||||||
@@ -545,22 +534,17 @@ class KretaClient {
|
|||||||
KretaEndpoints.getHomework(cache.token.iss, from, to),
|
KretaEndpoints.getHomework(cache.token.iss, from, to),
|
||||||
HomeworkCacheModel.new,
|
HomeworkCacheModel.new,
|
||||||
(item) => Homework.fromJson(item),
|
(item) => Homework.fromJson(item),
|
||||||
).then((caches) => _save(caches, cache.getHomeworks()));
|
).then(_save);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Automatically aligns requests to start at Monday and end at Sunday
|
/// Automatically aligns requests to start at Monday and end at Sunday
|
||||||
Future<List<LessonCacheModel>> getLessons(DateTime from, DateTime to) async {
|
Future<List<LessonCacheModel>> getLessons(DateTime from, DateTime to) async {
|
||||||
assert(from.difference(to).inDays < 30);
|
assert(from.difference(to).inDays < 30);
|
||||||
return (await _renewCache(
|
return (await _renewCache(
|
||||||
KretaEndpoints.getTimeTable(cache.token.iss, from, to),
|
KretaEndpoints.getTimeTable(cache.token.iss, from, to),
|
||||||
LessonCacheModel.new,
|
LessonCacheModel.new,
|
||||||
(json) => Lesson.fromJson(json),
|
(json) => Lesson.fromJson(json),
|
||||||
)
|
).then(resolveDailyNth).then(_save))
|
||||||
.then(resolveDailyNth)
|
|
||||||
.then(
|
|
||||||
(caches) =>
|
|
||||||
_save(caches, cache.getTimeTable().and().between(from, to)),
|
|
||||||
))
|
|
||||||
..sort((a, b) => a.start.compareTo(b.start));
|
..sort((a, b) => a.start.compareTo(b.start));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,28 +553,15 @@ class KretaClient {
|
|||||||
KretaEndpoints.getTests(cache.token.iss, from, to),
|
KretaEndpoints.getTests(cache.token.iss, from, to),
|
||||||
TestCacheModel.new,
|
TestCacheModel.new,
|
||||||
(item) => Test.fromJson(item),
|
(item) => Test.fromJson(item),
|
||||||
).then(
|
).then(_save);
|
||||||
(caches) => _save(
|
|
||||||
caches,
|
|
||||||
isarInit.testCacheModels.filter().classGroup(cache.isCurrentClassGroup),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<OmissionCacheModel>> getOmissions() async {
|
Future<List<OmissionCacheModel>> getOmissions() async {
|
||||||
return (await _renewCache(
|
return (await _renewCache(
|
||||||
KretaEndpoints.getOmissions(cache.token.iss),
|
KretaEndpoints.getOmissions(cache.token.iss),
|
||||||
OmissionCacheModel.new,
|
OmissionCacheModel.new,
|
||||||
(item) => Omission.fromJson(item),
|
(item) => Omission.fromJson(item),
|
||||||
).then(
|
).then(_save))..sort((a, b) => a.createdAt.compareTo(b.createdAt));
|
||||||
(caches) => _save(
|
|
||||||
caches,
|
|
||||||
isarInit.omissionCacheModels.filter().classGroup(
|
|
||||||
cache.isCurrentClassGroup,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
..sort((a, b) => a.createdAt.compareTo(b.createdAt));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<SubjectCacheModel>> getSubjects() async {
|
Future<List<SubjectCacheModel>> getSubjects() async {
|
||||||
|
|||||||
@@ -290,6 +290,12 @@ extension StringExtension on String {
|
|||||||
return regex.hasMatch(trim());
|
return regex.hasMatch(trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String firstUpper() {
|
||||||
|
if (isEmpty) return this;
|
||||||
|
if (length == 1) this[0].toUpperCase();
|
||||||
|
return this[0].toUpperCase() + substring(1, length);
|
||||||
|
}
|
||||||
|
|
||||||
String shortenName([int start = 0]) {
|
String shortenName([int start = 0]) {
|
||||||
if (length <= 16 || start >= length) {
|
if (length <= 16 || start >= length) {
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ Future<void> showLessonBottomSheet(
|
|||||||
color: appStyle.colors.buttonSecondaryFill,
|
color: appStyle.colors.buttonSecondaryFill,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.go('/timetable/subject', extra: lesson.subject.loadAndGet()!);
|
context.go('/timetable/subject', extra: lesson.subject);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
final todayLesson = widget.data.client!.cache
|
final todayLesson = widget.data.client!.cache
|
||||||
.getClassLessons()
|
.getClassLessons()
|
||||||
.on(now)
|
.on(now)
|
||||||
.sortByStart()
|
|
||||||
.findAllSync();
|
.findAllSync();
|
||||||
|
|
||||||
for (final item in infoItems) {
|
for (final item in infoItems) {
|
||||||
|
|||||||
@@ -62,10 +62,6 @@ class OmissionBar extends StatelessWidget {
|
|||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segmentColors.isEmpty) {
|
|
||||||
segmentColors.add(stateColor(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
final bar = ClipRRect(
|
final bar = ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: firka
|
|||||||
description: "Firka, Alternatív e-Kréta kliens."
|
description: "Firka, Alternatív e-Kréta kliens."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 1.2.0+2001
|
version: 1.1.2+2001
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.11.0
|
sdk: ^3.11.0
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import 'package:path/path.dart' as p;
|
|||||||
import 'package:yaml/yaml.dart' as yaml;
|
import 'package:yaml/yaml.dart' as yaml;
|
||||||
|
|
||||||
const _lockFileName = 'codegen-lock.yaml';
|
const _lockFileName = 'codegen-lock.yaml';
|
||||||
const _cacheFileName = '.codegen-cache.yaml';
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
final root = _projectRoot();
|
final root = _projectRoot();
|
||||||
stdout.writeln(root);
|
stdout.writeln(root);
|
||||||
_cleanIos(root);
|
|
||||||
var ran = false;
|
var ran = false;
|
||||||
|
|
||||||
if (_iconsOutOfDate(root)) {
|
if (_iconsOutOfDate(root)) {
|
||||||
@@ -33,7 +31,6 @@ void main() async {
|
|||||||
runInShell: true,
|
runInShell: true,
|
||||||
);
|
);
|
||||||
if (iconResult.exitCode == 0) {
|
if (iconResult.exitCode == 0) {
|
||||||
_cleanIos(root);
|
|
||||||
_updateLockWithHashes(root, 'icons', _computeHashes(root, inputs));
|
_updateLockWithHashes(root, 'icons', _computeHashes(root, inputs));
|
||||||
ran = true;
|
ran = true;
|
||||||
}
|
}
|
||||||
@@ -56,23 +53,19 @@ void main() async {
|
|||||||
'--template-arb-file',
|
'--template-arb-file',
|
||||||
'app_hu.arb',
|
'app_hu.arb',
|
||||||
], root);
|
], root);
|
||||||
_updateCacheWithHashes(root, 'l10n', _computeHashes(root, inputs));
|
_updateLockWithHashes(root, 'l10n', _computeHashes(root, inputs));
|
||||||
ran = true;
|
ran = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final common = p.join(p.dirname(root), 'firka_common');
|
var common = p.join(p.dirname(root), "firka_common");
|
||||||
if (_isarOutOfDate(common)) {
|
if (_isarOutOfDate(common) || _isarGeneratedFilesMissing(common)) {
|
||||||
final inputs = _isarInputs(common);
|
final inputs = _isarInputs(common);
|
||||||
final hashes = _computeHashes(common, inputs);
|
final hashes = _computeHashes(common, inputs);
|
||||||
stdout.writeln(
|
stdout.writeln(
|
||||||
'Isar generated dart files out of date or missing, running build_runner...',
|
'Isar generated dart files out of date or missing, running build_runner...',
|
||||||
);
|
);
|
||||||
await _run(
|
await _run('dart', ['run', 'build_runner', 'build'], common);
|
||||||
'dart',
|
_updateLockWithHashes(common, 'isar', hashes);
|
||||||
['run', 'build_runner', 'build', '--delete-conflicting-outputs'],
|
|
||||||
common,
|
|
||||||
);
|
|
||||||
_updateCacheWithHashes(common, 'isar', hashes);
|
|
||||||
ran = true;
|
ran = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,13 +76,10 @@ void main() async {
|
|||||||
'Splash out of date, running flutter_native_splash:create...',
|
'Splash out of date, running flutter_native_splash:create...',
|
||||||
);
|
);
|
||||||
await _run('dart', ['run', 'flutter_native_splash:create'], root);
|
await _run('dart', ['run', 'flutter_native_splash:create'], root);
|
||||||
_cleanIos(root);
|
|
||||||
_updateLockWithHashes(root, 'splash', _computeHashes(root, inputs));
|
_updateLockWithHashes(root, 'splash', _computeHashes(root, inputs));
|
||||||
ran = true;
|
ran = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_cleanIos(root);
|
|
||||||
|
|
||||||
if (!ran) {
|
if (!ran) {
|
||||||
stdout.writeln('All generated files are up to date.');
|
stdout.writeln('All generated files are up to date.');
|
||||||
}
|
}
|
||||||
@@ -101,10 +91,9 @@ String _projectRoot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _lockPath(String root) => p.join(root, _lockFileName);
|
String _lockPath(String root) => p.join(root, _lockFileName);
|
||||||
String _cachePath(String root) => p.join(root, _cacheFileName);
|
|
||||||
|
|
||||||
Map<String, Map<String, String>>? _readYamlFile(String filePath) {
|
Map<String, Map<String, String>>? _readLock(String root) {
|
||||||
final file = File(filePath);
|
final file = File(_lockPath(root));
|
||||||
if (!file.existsSync()) return null;
|
if (!file.existsSync()) return null;
|
||||||
try {
|
try {
|
||||||
final content = file.readAsStringSync();
|
final content = file.readAsStringSync();
|
||||||
@@ -127,9 +116,9 @@ Map<String, Map<String, String>>? _readYamlFile(String filePath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _writeYamlFile(String filePath, Map<String, Map<String, String>> data) {
|
void _writeLock(String root, Map<String, Map<String, String>> lock) {
|
||||||
final buf = StringBuffer();
|
final buf = StringBuffer();
|
||||||
for (final stepEntry in data.entries) {
|
for (final stepEntry in lock.entries) {
|
||||||
buf.writeln('${stepEntry.key}:');
|
buf.writeln('${stepEntry.key}:');
|
||||||
for (final fileEntry in stepEntry.value.entries) {
|
for (final fileEntry in stepEntry.value.entries) {
|
||||||
buf.writeln(
|
buf.writeln(
|
||||||
@@ -137,15 +126,9 @@ void _writeYamlFile(String filePath, Map<String, Map<String, String>> data) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File(filePath).writeAsStringSync(buf.toString());
|
File(_lockPath(root)).writeAsStringSync(buf.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Map<String, String>>? _readLock(String root) =>
|
|
||||||
_readYamlFile(_lockPath(root));
|
|
||||||
|
|
||||||
Map<String, Map<String, String>>? _readCache(String root) =>
|
|
||||||
_readYamlFile(_cachePath(root));
|
|
||||||
|
|
||||||
String _escapeYaml(String s) =>
|
String _escapeYaml(String s) =>
|
||||||
s.replaceAll('\\', '\\\\').replaceAll('"', '\\"');
|
s.replaceAll('\\', '\\\\').replaceAll('"', '\\"');
|
||||||
|
|
||||||
@@ -165,10 +148,10 @@ bool _hashesMatch(
|
|||||||
String root,
|
String root,
|
||||||
String stepName,
|
String stepName,
|
||||||
List<File> inputs,
|
List<File> inputs,
|
||||||
Map<String, Map<String, String>>? lockOrCache,
|
Map<String, Map<String, String>>? lock,
|
||||||
) {
|
) {
|
||||||
if (lockOrCache == null || !lockOrCache.containsKey(stepName)) return false;
|
if (lock == null || !lock.containsKey(stepName)) return false;
|
||||||
final stepHashes = lockOrCache[stepName]!;
|
final stepHashes = lock[stepName]!;
|
||||||
for (final f in inputs) {
|
for (final f in inputs) {
|
||||||
final rel = _relativePath(root, f);
|
final rel = _relativePath(root, f);
|
||||||
final stored = stepHashes[rel];
|
final stored = stepHashes[rel];
|
||||||
@@ -189,24 +172,22 @@ void _updateLockWithHashes(
|
|||||||
) {
|
) {
|
||||||
final lock = _readLock(root) ?? <String, Map<String, String>>{};
|
final lock = _readLock(root) ?? <String, Map<String, String>>{};
|
||||||
lock[stepName] = Map.from(hashes);
|
lock[stepName] = Map.from(hashes);
|
||||||
_writeYamlFile(_lockPath(root), lock);
|
_writeLock(root, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateCacheWithHashes(
|
DateTime? _modified(File file) {
|
||||||
String root,
|
if (!file.existsSync()) return null;
|
||||||
String stepName,
|
return file.lastModifiedSync();
|
||||||
Map<String, String> hashes,
|
|
||||||
) {
|
|
||||||
final cache = _readCache(root) ?? <String, Map<String, String>>{};
|
|
||||||
cache[stepName] = Map.from(hashes);
|
|
||||||
_writeYamlFile(_cachePath(root), cache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _cleanIos(String root) {
|
bool _anyNewerThan(Iterable<File> inputs, File output) {
|
||||||
final iosDir = Directory(p.join(root, 'ios'));
|
final outTime = _modified(output);
|
||||||
if (iosDir.existsSync()) {
|
if (outTime == null) return true;
|
||||||
iosDir.deleteSync(recursive: true);
|
for (final f in inputs) {
|
||||||
|
final t = _modified(f);
|
||||||
|
if (t != null && t.isAfter(outTime)) return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> _iconsInputs(String root) {
|
List<File> _iconsInputs(String root) {
|
||||||
@@ -236,7 +217,7 @@ bool _iconsOutOfDate(String root) {
|
|||||||
'android/app/src/main/res/mipmap-anydpi-v26/launcher_icon.xml',
|
'android/app/src/main/res/mipmap-anydpi-v26/launcher_icon.xml',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (!output.existsSync()) return true;
|
if (!_anyNewerThan(inputs, output)) return false;
|
||||||
return !_hashesMatch(root, 'icons', inputs, _readLock(root));
|
return !_hashesMatch(root, 'icons', inputs, _readLock(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,28 +233,11 @@ List<File> _l10nInputs(String root) {
|
|||||||
return [l10nYml, ...arbs].where((f) => f.existsSync()).cast<File>().toList();
|
return [l10nYml, ...arbs].where((f) => f.existsSync()).cast<File>().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _l10nGeneratedFilesMissing(String root) {
|
|
||||||
final l10nDir = p.join(root, 'lib/l10n');
|
|
||||||
final mainOutput = File(p.join(l10nDir, 'app_localizations.dart'));
|
|
||||||
if (!mainOutput.existsSync()) return true;
|
|
||||||
final dir = Directory(l10nDir);
|
|
||||||
if (!dir.existsSync()) return true;
|
|
||||||
for (final file in dir.listSync().whereType<File>()) {
|
|
||||||
if (file.path.endsWith('.arb')) {
|
|
||||||
final base = p.basenameWithoutExtension(file.path);
|
|
||||||
final genFile = File(
|
|
||||||
p.join(l10nDir, '${base.replaceFirst("app_", "app_localizations_")}.dart'),
|
|
||||||
);
|
|
||||||
if (!genFile.existsSync()) return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _l10nOutOfDate(String root) {
|
bool _l10nOutOfDate(String root) {
|
||||||
final inputs = _l10nInputs(root);
|
final inputs = _l10nInputs(root);
|
||||||
if (_l10nGeneratedFilesMissing(root)) return true;
|
final output = File(p.join(root, 'lib/l10n/app_localizations.dart'));
|
||||||
return !_hashesMatch(root, 'l10n', inputs, _readCache(root));
|
if (!_anyNewerThan(inputs, output)) return false;
|
||||||
|
return !_hashesMatch(root, 'l10n', inputs, _readLock(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> _isarInputs(String root) {
|
List<File> _isarInputs(String root) {
|
||||||
@@ -289,6 +253,20 @@ List<File> _isarInputs(String root) {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isarOutOfDate(String root) {
|
||||||
|
final inputs = _isarInputs(root);
|
||||||
|
if (inputs.isEmpty) return false;
|
||||||
|
final modelsDir = p.join(root, 'lib/data/models');
|
||||||
|
for (final dartFile in inputs) {
|
||||||
|
final baseName = p.basenameWithoutExtension(dartFile.path);
|
||||||
|
final gFile = File(p.join(modelsDir, '$baseName.g.dart'));
|
||||||
|
if (_anyNewerThan([dartFile], gFile)) {
|
||||||
|
return !_hashesMatch(root, 'isar', inputs, _readLock(root));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool _isarGeneratedFilesMissing(String root) {
|
bool _isarGeneratedFilesMissing(String root) {
|
||||||
final inputs = _isarInputs(root);
|
final inputs = _isarInputs(root);
|
||||||
if (inputs.isEmpty) return false;
|
if (inputs.isEmpty) return false;
|
||||||
@@ -301,13 +279,6 @@ bool _isarGeneratedFilesMissing(String root) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isarOutOfDate(String root) {
|
|
||||||
final inputs = _isarInputs(root);
|
|
||||||
if (inputs.isEmpty) return false;
|
|
||||||
if (_isarGeneratedFilesMissing(root)) return true;
|
|
||||||
return !_hashesMatch(root, 'isar', inputs, _readCache(root));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<File> _splashInputs(String root) {
|
List<File> _splashInputs(String root) {
|
||||||
final config = File(p.join(root, 'flutter_native_splash.yaml'));
|
final config = File(p.join(root, 'flutter_native_splash.yaml'));
|
||||||
final splashImage = File(p.join(root, 'assets/images/logos/splash.png'));
|
final splashImage = File(p.join(root, 'assets/images/logos/splash.png'));
|
||||||
@@ -323,11 +294,7 @@ bool _splashOutOfDate(String root) {
|
|||||||
final output = File(
|
final output = File(
|
||||||
p.join(root, 'android/app/src/main/res/drawable/launch_background.xml'),
|
p.join(root, 'android/app/src/main/res/drawable/launch_background.xml'),
|
||||||
);
|
);
|
||||||
if (!output.existsSync()) return true;
|
if (!_anyNewerThan(inputs, output)) return false;
|
||||||
final splash12 = File(
|
|
||||||
p.join(root, 'assets/images/logos/splash_android12.png'),
|
|
||||||
);
|
|
||||||
if (!splash12.existsSync()) return true;
|
|
||||||
return !_hashesMatch(root, 'splash', inputs, _readLock(root));
|
return !_hashesMatch(root, 'splash', inputs, _readLock(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,348 +0,0 @@
|
|||||||
// ignore_for_file: depend_on_referenced_packages
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:firka/app/app_state.dart';
|
|
||||||
import 'package:firka/app/initialization.dart';
|
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
|
||||||
import 'package:firka/core/settings/settings_schema.dart';
|
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/homework_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/omission_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/test_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:isar_community/isar.dart';
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:logging/logging.dart';
|
|
||||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
||||||
import 'package:flutter_local_notifications_platform_interface/flutter_local_notifications_platform_interface.dart';
|
|
||||||
|
|
||||||
const _mockServerUrl = 'http://127.0.0.1:8090';
|
|
||||||
|
|
||||||
class _RealHttpOverrides extends HttpOverrides {}
|
|
||||||
|
|
||||||
class MockNotificationsPlatform extends FlutterLocalNotificationsPlatform
|
|
||||||
with MockPlatformInterfaceMixin {
|
|
||||||
Future<bool?> initialize(
|
|
||||||
InitializationSettings initializationSettings, {
|
|
||||||
void Function(NotificationResponse)? onDidReceiveNotificationResponse,
|
|
||||||
void Function(NotificationResponse)?
|
|
||||||
onDidReceiveBackgroundNotificationResponse,
|
|
||||||
}) async => true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ActiveNotification>> getActiveNotifications() async => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<TokenGrantResponse> _authenticateMockServer(
|
|
||||||
HttpClient httpClient,
|
|
||||||
) async {
|
|
||||||
final loginReq = await httpClient.getUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/Account/Login'),
|
|
||||||
);
|
|
||||||
final loginResp = await loginReq.close();
|
|
||||||
final loginBody = await loginResp.transform(utf8.decoder).join();
|
|
||||||
|
|
||||||
final match = RegExp(r'name="code" value="([^"]+)"').firstMatch(loginBody);
|
|
||||||
if (match == null) {
|
|
||||||
throw Exception(
|
|
||||||
'Failed to extract code from mock server login: $loginBody',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final code = match.group(1)!;
|
|
||||||
|
|
||||||
final tokenReq = await httpClient.postUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/connect/token'),
|
|
||||||
);
|
|
||||||
tokenReq.headers.contentType = ContentType(
|
|
||||||
'application',
|
|
||||||
'x-www-form-urlencoded',
|
|
||||||
);
|
|
||||||
tokenReq.write(
|
|
||||||
'grant_type=authorization_code&code=${Uri.encodeQueryComponent(code)}',
|
|
||||||
);
|
|
||||||
final tokenResp = await tokenReq.close();
|
|
||||||
final tokenBody = await tokenResp.transform(utf8.decoder).join();
|
|
||||||
if (tokenResp.statusCode != 200) {
|
|
||||||
throw Exception(
|
|
||||||
'Token request failed (${tokenResp.statusCode}): $tokenBody',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return TokenGrantResponse.fromJson(
|
|
||||||
jsonDecode(tokenBody) as Map<String, dynamic>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _resetMockServer(HttpClient httpClient) async {
|
|
||||||
final req = await httpClient.postUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/admin/api/reset'),
|
|
||||||
);
|
|
||||||
final resp = await req.close();
|
|
||||||
await resp.drain();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _putCollection(
|
|
||||||
HttpClient httpClient,
|
|
||||||
String endpoint,
|
|
||||||
List<Map<String, dynamic>> items,
|
|
||||||
) async {
|
|
||||||
final req = await httpClient.putUrl(Uri.parse('$_mockServerUrl$endpoint'));
|
|
||||||
req.headers.contentType = ContentType.json;
|
|
||||||
req.write(jsonEncode(items));
|
|
||||||
final resp = await req.close();
|
|
||||||
if (resp.statusCode != 204 && resp.statusCode != 200) {
|
|
||||||
final body = await resp.transform(utf8.decoder).join();
|
|
||||||
throw Exception('Failed to PUT $endpoint (${resp.statusCode}): $body');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const _subject = {
|
|
||||||
'Uid': '1,MATEK',
|
|
||||||
'Nev': 'Matematika',
|
|
||||||
'Kategoria': {'Uid': '1', 'Nev': 'Kötelező', 'Leiras': 'Kötelező tantárgy'},
|
|
||||||
'SortIndex': 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<String, dynamic> _grade(String uid) => {
|
|
||||||
'Uid': uid,
|
|
||||||
'RogzitesDatuma': '2026-09-08T00:00:00',
|
|
||||||
'KeszitesDatuma': '2026-09-08T00:00:00',
|
|
||||||
'Tantargy': _subject,
|
|
||||||
'Tema': 'Teszt téma',
|
|
||||||
'Tipus': {'Uid': '1', 'Nev': 'Írásbeli', 'Leiras': 'Írásbeli felelet'},
|
|
||||||
'ErtekFajta': {'Uid': '1', 'Nev': 'Osztályzat', 'Leiras': 'Osztályzat'},
|
|
||||||
'ErtekeloTanarNeve': 'Teszt Tanár',
|
|
||||||
'Jelleg': 'Ertekeles',
|
|
||||||
'SzamErtek': 5,
|
|
||||||
'SzovegesErtek': 'Jeles',
|
|
||||||
'SulySzazalekErteke': 100,
|
|
||||||
'OsztalyCsoport': {'Uid': '10,11.A'},
|
|
||||||
'SortIndex': 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<String, dynamic> _homework(String uid) => {
|
|
||||||
'Uid': uid,
|
|
||||||
'Tantargy': _subject,
|
|
||||||
'TantargyNeve': 'Matematika',
|
|
||||||
'RogzitoTanarNeve': 'Teszt Tanár',
|
|
||||||
'Szoveg': 'Teszt házi feladat',
|
|
||||||
'FeladasDatuma': '2026-09-09T00:00:00',
|
|
||||||
'HataridoDatuma': '2026-09-16T00:00:00',
|
|
||||||
'RogzitesIdopontja': '2026-09-09T00:00:00',
|
|
||||||
'IsTanarRogzitette': true,
|
|
||||||
'IsMegoldva': false,
|
|
||||||
'IsBeadhato': false,
|
|
||||||
'OsztalyCsoport': {'Uid': '10,11.A'},
|
|
||||||
'IsCsatolasEngedelyezes': false,
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<String, dynamic> _test(String uid) => {
|
|
||||||
'Uid': uid,
|
|
||||||
'Datum': '2026-09-14T00:00:00',
|
|
||||||
'BejelentesDatuma': '2026-09-09T00:00:00',
|
|
||||||
'RogzitoTanarNeve': 'Teszt Tanár',
|
|
||||||
'OrarendiOraOraszama': 2,
|
|
||||||
'Tantargy': _subject,
|
|
||||||
'TantargyNeve': 'Matematika',
|
|
||||||
'Temaja': 'Teszt dolgozat téma',
|
|
||||||
'Modja': {'Uid': '1', 'Nev': 'Írásbeli', 'Leiras': 'Írásbeli dolgozat'},
|
|
||||||
'OsztalyCsoport': {'Uid': '10,11.A'},
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<String, dynamic> _omission(String uid) => {
|
|
||||||
'Uid': uid,
|
|
||||||
'Tantargy': _subject,
|
|
||||||
'Ora': {
|
|
||||||
'KezdoDatum': '2026-09-07T00:00:00',
|
|
||||||
'VegDatum': '2026-09-07T00:45:00',
|
|
||||||
'Oraszam': 1,
|
|
||||||
},
|
|
||||||
'Datum': '2026-09-07T00:00:00',
|
|
||||||
'RogzitoTanarNeve': 'Teszt Tanár',
|
|
||||||
'Tipus': {'Uid': '1', 'Nev': 'Hiányzás', 'Leiras': 'Hiányzás'},
|
|
||||||
'Mod': {'Uid': '', 'Nev': '', 'Leiras': ''},
|
|
||||||
'KeszitesDatuma': '2026-09-07T00:00:00',
|
|
||||||
'IgazolasAllapota': 'Igazolt',
|
|
||||||
'IgazolasTipusa': {'Uid': '', 'Nev': '', 'Leiras': ''},
|
|
||||||
'OsztalyCsoport': {'Uid': '10,11.A'},
|
|
||||||
};
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
FlutterLocalNotificationsPlatform.instance = MockNotificationsPlatform();
|
|
||||||
logger = Logger('CollectionCacheReconciliationTest');
|
|
||||||
|
|
||||||
group('Collection cache reconciliation against mock Kreta server', () {
|
|
||||||
late HttpClient httpClient;
|
|
||||||
|
|
||||||
setUp(() async {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
httpClient = HttpClient()..connectionTimeout = const Duration(seconds: 5);
|
|
||||||
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('plugins.flutter.io/path_provider'),
|
|
||||||
(MethodCall methodCall) async => Directory.systemTemp.path,
|
|
||||||
);
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('dev.fluttercommunity.plus/package_info'),
|
|
||||||
(MethodCall methodCall) async => {
|
|
||||||
'appName': 'firka',
|
|
||||||
'packageName': 'app.firka.naplo',
|
|
||||||
'version': '1.0.0',
|
|
||||||
'buildNumber': '1',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('firka.app/main'),
|
|
||||||
(MethodCall methodCall) async => 'SM-A705FN;11;30',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
tearDown(() {
|
|
||||||
httpClient.close(force: true);
|
|
||||||
});
|
|
||||||
|
|
||||||
Future<void> initAndSync() async {
|
|
||||||
final isar = await initDB();
|
|
||||||
await isar.writeTxn(() async {
|
|
||||||
await isar.clear();
|
|
||||||
});
|
|
||||||
Settings = SettingsRepository(isar);
|
|
||||||
await Settings.loadAll();
|
|
||||||
|
|
||||||
await Settings.mockBackendEnabled.set(true);
|
|
||||||
await Settings.mockBackendUrl.set(_mockServerUrl);
|
|
||||||
|
|
||||||
final tokenResp = await _authenticateMockServer(httpClient);
|
|
||||||
final tokenModel = TokenModel.fromResp(tokenResp);
|
|
||||||
|
|
||||||
await isar.writeTxn(() async {
|
|
||||||
await isar.tokenModels.clear();
|
|
||||||
await isar.tokenModels.put(tokenModel);
|
|
||||||
});
|
|
||||||
|
|
||||||
await initializeApp();
|
|
||||||
expect(initDone, isTrue);
|
|
||||||
|
|
||||||
await initData.client!.init();
|
|
||||||
await initData.client!.renewCache(reInit: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
testWidgets('stale grade rows are removed after a server-side correction', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
await tester.runAsync(() async {
|
|
||||||
await _resetMockServer(httpClient);
|
|
||||||
await _putCollection(httpClient, '/admin/api/grades', [
|
|
||||||
_grade('g-1'),
|
|
||||||
_grade('g-2'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await initAndSync();
|
|
||||||
expect(isarInit.gradeCacheModels.where().findAllSync().length, 2);
|
|
||||||
|
|
||||||
// teacher deletes an erroneously entered grade server-side
|
|
||||||
await _putCollection(httpClient, '/admin/api/grades', [_grade('g-1')]);
|
|
||||||
await initData.client!.renewCache(reInit: false);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
isarInit.gradeCacheModels.where().findAllSync().length,
|
|
||||||
1,
|
|
||||||
reason: 'deleted grade should no longer be cached locally',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'stale homework rows are removed after a server-side deletion',
|
|
||||||
(tester) async {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
await tester.runAsync(() async {
|
|
||||||
await _resetMockServer(httpClient);
|
|
||||||
await _putCollection(httpClient, '/admin/api/homework', [
|
|
||||||
_homework('h-1'),
|
|
||||||
_homework('h-2'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await initAndSync();
|
|
||||||
expect(isarInit.homeworkCacheModels.where().findAllSync().length, 2);
|
|
||||||
|
|
||||||
await _putCollection(httpClient, '/admin/api/homework', [
|
|
||||||
_homework('h-1'),
|
|
||||||
]);
|
|
||||||
await initData.client!.renewCache(reInit: false);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
isarInit.homeworkCacheModels.where().findAllSync().length,
|
|
||||||
1,
|
|
||||||
reason: 'deleted homework should no longer be cached locally',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'stale test rows are removed after a server-side cancellation',
|
|
||||||
(tester) async {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
await tester.runAsync(() async {
|
|
||||||
await _resetMockServer(httpClient);
|
|
||||||
await _putCollection(httpClient, '/admin/api/tests', [
|
|
||||||
_test('t-1'),
|
|
||||||
_test('t-2'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await initAndSync();
|
|
||||||
expect(isarInit.testCacheModels.where().findAllSync().length, 2);
|
|
||||||
|
|
||||||
await _putCollection(httpClient, '/admin/api/tests', [_test('t-1')]);
|
|
||||||
await initData.client!.renewCache(reInit: false);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
isarInit.testCacheModels.where().findAllSync().length,
|
|
||||||
1,
|
|
||||||
reason: 'cancelled test should no longer be cached locally',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'stale omission rows are removed after a server-side justification',
|
|
||||||
(tester) async {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
await tester.runAsync(() async {
|
|
||||||
await _resetMockServer(httpClient);
|
|
||||||
await _putCollection(httpClient, '/admin/api/omissions', [
|
|
||||||
_omission('o-1'),
|
|
||||||
_omission('o-2'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await initAndSync();
|
|
||||||
expect(isarInit.omissionCacheModels.where().findAllSync().length, 2);
|
|
||||||
|
|
||||||
// a teacher retroactively removes an incorrectly recorded absence
|
|
||||||
await _putCollection(httpClient, '/admin/api/omissions', [
|
|
||||||
_omission('o-1'),
|
|
||||||
]);
|
|
||||||
await initData.client!.renewCache(reInit: false);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
isarInit.omissionCacheModels.where().findAllSync().length,
|
|
||||||
1,
|
|
||||||
reason: 'removed absence should no longer be cached locally',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,350 +0,0 @@
|
|||||||
// ignore_for_file: depend_on_referenced_packages
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:firka/api/client/kreta_client.dart';
|
|
||||||
import 'package:firka/app/app_state.dart';
|
|
||||||
import 'package:firka/app/initialization.dart';
|
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
|
||||||
import 'package:firka/core/settings/settings_schema.dart';
|
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:isar_community/isar.dart';
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:logging/logging.dart';
|
|
||||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
||||||
import 'package:flutter_local_notifications_platform_interface/flutter_local_notifications_platform_interface.dart';
|
|
||||||
|
|
||||||
const _mockServerUrl = 'http://127.0.0.1:8090';
|
|
||||||
|
|
||||||
class _RealHttpOverrides extends HttpOverrides {}
|
|
||||||
|
|
||||||
class MockNotificationsPlatform extends FlutterLocalNotificationsPlatform
|
|
||||||
with MockPlatformInterfaceMixin {
|
|
||||||
Future<bool?> initialize(
|
|
||||||
InitializationSettings initializationSettings, {
|
|
||||||
void Function(NotificationResponse)? onDidReceiveNotificationResponse,
|
|
||||||
void Function(NotificationResponse)?
|
|
||||||
onDidReceiveBackgroundNotificationResponse,
|
|
||||||
}) async => true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ActiveNotification>> getActiveNotifications() async => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<TokenGrantResponse> _authenticateMockServer(
|
|
||||||
HttpClient httpClient,
|
|
||||||
) async {
|
|
||||||
final loginReq = await httpClient.getUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/Account/Login'),
|
|
||||||
);
|
|
||||||
final loginResp = await loginReq.close();
|
|
||||||
final loginBody = await loginResp.transform(utf8.decoder).join();
|
|
||||||
|
|
||||||
final match = RegExp(r'name="code" value="([^"]+)"').firstMatch(loginBody);
|
|
||||||
if (match == null) {
|
|
||||||
throw Exception(
|
|
||||||
'Failed to extract code from mock server login: $loginBody',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final code = match.group(1)!;
|
|
||||||
|
|
||||||
final tokenReq = await httpClient.postUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/connect/token'),
|
|
||||||
);
|
|
||||||
tokenReq.headers.contentType = ContentType(
|
|
||||||
'application',
|
|
||||||
'x-www-form-urlencoded',
|
|
||||||
);
|
|
||||||
tokenReq.write(
|
|
||||||
'grant_type=authorization_code&code=${Uri.encodeQueryComponent(code)}',
|
|
||||||
);
|
|
||||||
final tokenResp = await tokenReq.close();
|
|
||||||
final tokenBody = await tokenResp.transform(utf8.decoder).join();
|
|
||||||
if (tokenResp.statusCode != 200) {
|
|
||||||
throw Exception(
|
|
||||||
'Token request failed (${tokenResp.statusCode}): $tokenBody',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return TokenGrantResponse.fromJson(
|
|
||||||
jsonDecode(tokenBody) as Map<String, dynamic>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _resetMockServer(HttpClient httpClient) async {
|
|
||||||
final req = await httpClient.postUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/admin/api/reset'),
|
|
||||||
);
|
|
||||||
final resp = await req.close();
|
|
||||||
await resp.drain();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _putCollection(
|
|
||||||
HttpClient httpClient,
|
|
||||||
String endpoint,
|
|
||||||
List<Map<String, dynamic>> items,
|
|
||||||
) async {
|
|
||||||
final req = await httpClient.putUrl(Uri.parse('$_mockServerUrl$endpoint'));
|
|
||||||
req.headers.contentType = ContentType.json;
|
|
||||||
req.write(jsonEncode(items));
|
|
||||||
final resp = await req.close();
|
|
||||||
if (resp.statusCode != 204 && resp.statusCode != 200) {
|
|
||||||
final body = await resp.transform(utf8.decoder).join();
|
|
||||||
throw Exception('Failed to PUT $endpoint (${resp.statusCode}): $body');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> _lesson({
|
|
||||||
required String uid,
|
|
||||||
required String start,
|
|
||||||
required String end,
|
|
||||||
required String name,
|
|
||||||
}) {
|
|
||||||
final today = DateTime.now();
|
|
||||||
final datePrefix =
|
|
||||||
'${today.year}-${today.month.toString().padLeft(2, '0')}-${today.day.toString().padLeft(2, '0')}';
|
|
||||||
return {
|
|
||||||
'Uid': uid,
|
|
||||||
'Datum': '${datePrefix}T00:00:00',
|
|
||||||
'KezdetIdopont': '${datePrefix}T$start:00',
|
|
||||||
'VegIdopont': '${datePrefix}T$end:00',
|
|
||||||
'Nev': name,
|
|
||||||
'OsztalyCsoport': {'Uid': '10,11.A', 'Nev': '11.A'},
|
|
||||||
'TanarNeve': 'Teszt Tanár',
|
|
||||||
'Tantargy': {
|
|
||||||
'Uid': '1,MATEK',
|
|
||||||
'Nev': name,
|
|
||||||
'Kategoria': {
|
|
||||||
'Uid': '1',
|
|
||||||
'Nev': 'Kötelező',
|
|
||||||
'Leiras': 'Kötelező tantárgy',
|
|
||||||
},
|
|
||||||
'SortIndex': 1,
|
|
||||||
},
|
|
||||||
'TeremNeve': '101',
|
|
||||||
'Tipus': {'Uid': '1', 'Nev': 'Tanóra', 'Leiras': 'Tanóra'},
|
|
||||||
'TanuloJelenlet': {'Uid': '', 'Nev': '', 'Leiras': ''},
|
|
||||||
'Allapot': {'Uid': '1', 'Nev': 'Megtartott', 'Leiras': 'Megtartott óra'},
|
|
||||||
'IsTanuloHaziFeladatEnabled': false,
|
|
||||||
'IsHaziFeladatMegoldva': false,
|
|
||||||
'Csatolmanyok': [],
|
|
||||||
'IsDigitalisOra': false,
|
|
||||||
'DigitalisTamogatoEszkozTipusList': [],
|
|
||||||
'Letrehozas': '${datePrefix}T00:00:00',
|
|
||||||
'UtolsoModositas': DateTime.now().toUtc().toIso8601String(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> _grade(String uid) => {
|
|
||||||
'Uid': uid,
|
|
||||||
'RogzitesDatuma': '2026-09-08T00:00:00',
|
|
||||||
'KeszitesDatuma': '2026-09-08T00:00:00',
|
|
||||||
'Tantargy': {
|
|
||||||
'Uid': '1,MATEK',
|
|
||||||
'Nev': 'Matematika',
|
|
||||||
'Kategoria': {'Uid': '1', 'Nev': 'Kötelező', 'Leiras': 'Kötelező tantárgy'},
|
|
||||||
'SortIndex': 1,
|
|
||||||
},
|
|
||||||
'Tema': 'Teszt téma',
|
|
||||||
'Tipus': {'Uid': '1', 'Nev': 'Írásbeli', 'Leiras': 'Írásbeli felelet'},
|
|
||||||
'ErtekFajta': {'Uid': '1', 'Nev': 'Osztályzat', 'Leiras': 'Osztályzat'},
|
|
||||||
'ErtekeloTanarNeve': 'Teszt Tanár',
|
|
||||||
'Jelleg': 'Ertekeles',
|
|
||||||
'SzamErtek': 5,
|
|
||||||
'SzovegesErtek': 'Jeles',
|
|
||||||
'SulySzazalekErteke': 100,
|
|
||||||
'OsztalyCsoport': {'Uid': '10,11.A'},
|
|
||||||
'SortIndex': 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
FlutterLocalNotificationsPlatform.instance = MockNotificationsPlatform();
|
|
||||||
logger = Logger('MultiAccountCacheIsolationTest');
|
|
||||||
|
|
||||||
group('Multi-account cache isolation', () {
|
|
||||||
late HttpClient httpClient;
|
|
||||||
|
|
||||||
setUp(() {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
httpClient = HttpClient()..connectionTimeout = const Duration(seconds: 5);
|
|
||||||
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('plugins.flutter.io/path_provider'),
|
|
||||||
(MethodCall methodCall) async => Directory.systemTemp.path,
|
|
||||||
);
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('dev.fluttercommunity.plus/package_info'),
|
|
||||||
(MethodCall methodCall) async => {
|
|
||||||
'appName': 'firka',
|
|
||||||
'packageName': 'app.firka.naplo',
|
|
||||||
'version': '1.0.0',
|
|
||||||
'buildNumber': '1',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('firka.app/main'),
|
|
||||||
(MethodCall methodCall) async => 'SM-A705FN;11;30',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
tearDown(() {
|
|
||||||
httpClient.close(force: true);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'resyncing one account does not delete another account\'s cached rows',
|
|
||||||
(tester) async {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
|
|
||||||
await tester.runAsync(() async {
|
|
||||||
await _resetMockServer(httpClient);
|
|
||||||
await _putCollection(httpClient, '/admin/api/timetable', [
|
|
||||||
_lesson(
|
|
||||||
uid: '9001',
|
|
||||||
start: '07:30',
|
|
||||||
end: '08:15',
|
|
||||||
name: 'Matematika',
|
|
||||||
),
|
|
||||||
_lesson(uid: '9002', start: '08:25', end: '09:10', name: 'Fizika'),
|
|
||||||
_lesson(uid: '9003', start: '09:20', end: '10:05', name: 'Kémia'),
|
|
||||||
]);
|
|
||||||
await _putCollection(httpClient, '/admin/api/grades', [
|
|
||||||
_grade('g-1'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
final isar = await initDB();
|
|
||||||
await isar.writeTxn(() async {
|
|
||||||
await isar.clear();
|
|
||||||
});
|
|
||||||
Settings = SettingsRepository(isar);
|
|
||||||
await Settings.loadAll();
|
|
||||||
await Settings.mockBackendEnabled.set(true);
|
|
||||||
await Settings.mockBackendUrl.set(_mockServerUrl);
|
|
||||||
|
|
||||||
// mock server is single-tenant. a cloned token with a different iss gets its own cache.
|
|
||||||
final tokenResp = await _authenticateMockServer(httpClient);
|
|
||||||
final tokenA = TokenModel.fromResp(tokenResp);
|
|
||||||
// studentId must match the server's real id. isCurrentStudent matches on it.
|
|
||||||
final tokenB = TokenModel()
|
|
||||||
..key = tokenA.key + 1
|
|
||||||
..studentId = tokenA.studentId
|
|
||||||
..username = '${tokenA.username}-b'
|
|
||||||
..iss = '${tokenA.iss}-b'
|
|
||||||
..idToken = tokenA.idToken
|
|
||||||
..accessToken = tokenA.accessToken
|
|
||||||
..refreshToken = tokenA.refreshToken
|
|
||||||
..expiryDate = tokenA.expiryDate
|
|
||||||
..tokenVersion = tokenA.tokenVersion
|
|
||||||
..updatedAtMs = tokenA.updatedAtMs;
|
|
||||||
|
|
||||||
await isar.writeTxn(() async {
|
|
||||||
await isar.tokenModels.clear();
|
|
||||||
await isar.tokenModels.put(tokenA);
|
|
||||||
await isar.tokenModels.put(tokenB);
|
|
||||||
});
|
|
||||||
|
|
||||||
await initializeApp();
|
|
||||||
expect(initDone, isTrue);
|
|
||||||
|
|
||||||
final clientA = KretaClient(tokenA);
|
|
||||||
final clientB = KretaClient(tokenB);
|
|
||||||
|
|
||||||
await clientA.init();
|
|
||||||
await clientA.renewCache(reInit: false);
|
|
||||||
await clientB.init();
|
|
||||||
await clientB.renewCache(reInit: false);
|
|
||||||
|
|
||||||
List<LessonCacheModel> lessonsFor(KretaClient client) {
|
|
||||||
final today = DateTime.now();
|
|
||||||
bool isToday(DateTime d) =>
|
|
||||||
d.year == today.year &&
|
|
||||||
d.month == today.month &&
|
|
||||||
d.day == today.day;
|
|
||||||
return client.cache
|
|
||||||
.getTimeTable()
|
|
||||||
.findAllSync()
|
|
||||||
.where((l) => isToday(l.start))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(lessonsFor(clientA).length, 3);
|
|
||||||
expect(lessonsFor(clientB).length, 3);
|
|
||||||
expect(clientB.cache.getGrades().findAllSync().length, 1);
|
|
||||||
|
|
||||||
// account A's timetable and grade get edited server-side
|
|
||||||
await _putCollection(httpClient, '/admin/api/timetable', [
|
|
||||||
_lesson(
|
|
||||||
uid: '9001',
|
|
||||||
start: '07:30',
|
|
||||||
end: '08:15',
|
|
||||||
name: 'Matematika',
|
|
||||||
),
|
|
||||||
_lesson(
|
|
||||||
uid: '9002-v2',
|
|
||||||
start: '08:20',
|
|
||||||
end: '09:00',
|
|
||||||
name: 'Fizika',
|
|
||||||
),
|
|
||||||
_lesson(uid: '9003', start: '09:05', end: '09:50', name: 'Kémia'),
|
|
||||||
]);
|
|
||||||
await _putCollection(httpClient, '/admin/api/grades', []);
|
|
||||||
await clientA.renewCache(reInit: false);
|
|
||||||
|
|
||||||
final aAfter = lessonsFor(clientA);
|
|
||||||
expect(
|
|
||||||
aAfter.length,
|
|
||||||
3,
|
|
||||||
reason: 'account A should still reconcile correctly',
|
|
||||||
);
|
|
||||||
final aFizika = aAfter.firstWhere((l) => l.name == 'Fizika');
|
|
||||||
expect(
|
|
||||||
aFizika.start.minute,
|
|
||||||
20,
|
|
||||||
reason: "account A should see its own edited copy",
|
|
||||||
);
|
|
||||||
expect(clientA.cache.getGrades().findAllSync(), isEmpty);
|
|
||||||
|
|
||||||
final bAfter = lessonsFor(clientB);
|
|
||||||
expect(
|
|
||||||
bAfter.length,
|
|
||||||
3,
|
|
||||||
reason: "account B's lessons must survive account A's resync",
|
|
||||||
);
|
|
||||||
expect(bAfter.map((l) => l.name).toSet(), {
|
|
||||||
'Matematika',
|
|
||||||
'Fizika',
|
|
||||||
'Kémia',
|
|
||||||
});
|
|
||||||
// lesson name is identical on both sides. start time reveals the account.
|
|
||||||
final bFizika = bAfter.firstWhere((l) => l.name == 'Fizika');
|
|
||||||
expect(bFizika.start.hour, 8);
|
|
||||||
expect(bFizika.start.minute, 25);
|
|
||||||
|
|
||||||
final bGrades = clientB.cache.getGrades().findAllSync();
|
|
||||||
expect(
|
|
||||||
bGrades.length,
|
|
||||||
1,
|
|
||||||
reason:
|
|
||||||
"account B's grade must survive account A's grade being cleared",
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
bGrades.single.cacheKey,
|
|
||||||
clientB.cache.genCacheKey(UidObj(uid: 'g-1')),
|
|
||||||
reason:
|
|
||||||
"the surviving row must be account B's own copy of g-1, not "
|
|
||||||
"some row aliased in from account A",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
// ignore_for_file: depend_on_referenced_packages
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:firka/app/app_state.dart';
|
|
||||||
import 'package:firka/app/initialization.dart';
|
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
|
||||||
import 'package:firka/core/settings/settings_schema.dart';
|
|
||||||
import 'package:firka_common/data/cache_manager.dart';
|
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:isar_community/isar.dart';
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:logging/logging.dart';
|
|
||||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
||||||
import 'package:flutter_local_notifications_platform_interface/flutter_local_notifications_platform_interface.dart';
|
|
||||||
|
|
||||||
const _mockServerUrl = 'http://127.0.0.1:8090';
|
|
||||||
|
|
||||||
class _RealHttpOverrides extends HttpOverrides {}
|
|
||||||
|
|
||||||
class MockNotificationsPlatform extends FlutterLocalNotificationsPlatform
|
|
||||||
with MockPlatformInterfaceMixin {
|
|
||||||
Future<bool?> initialize(
|
|
||||||
InitializationSettings initializationSettings, {
|
|
||||||
void Function(NotificationResponse)? onDidReceiveNotificationResponse,
|
|
||||||
void Function(NotificationResponse)?
|
|
||||||
onDidReceiveBackgroundNotificationResponse,
|
|
||||||
}) async => true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ActiveNotification>> getActiveNotifications() async => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<TokenGrantResponse> _authenticateMockServer(
|
|
||||||
HttpClient httpClient,
|
|
||||||
) async {
|
|
||||||
final loginReq = await httpClient.getUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/Account/Login'),
|
|
||||||
);
|
|
||||||
final loginResp = await loginReq.close();
|
|
||||||
final loginBody = await loginResp.transform(utf8.decoder).join();
|
|
||||||
|
|
||||||
final match = RegExp(r'name="code" value="([^"]+)"').firstMatch(loginBody);
|
|
||||||
if (match == null) {
|
|
||||||
throw Exception(
|
|
||||||
'Failed to extract code from mock server login: $loginBody',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final code = match.group(1)!;
|
|
||||||
|
|
||||||
final tokenReq = await httpClient.postUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/connect/token'),
|
|
||||||
);
|
|
||||||
tokenReq.headers.contentType = ContentType(
|
|
||||||
'application',
|
|
||||||
'x-www-form-urlencoded',
|
|
||||||
);
|
|
||||||
tokenReq.write(
|
|
||||||
'grant_type=authorization_code&code=${Uri.encodeQueryComponent(code)}',
|
|
||||||
);
|
|
||||||
final tokenResp = await tokenReq.close();
|
|
||||||
final tokenBody = await tokenResp.transform(utf8.decoder).join();
|
|
||||||
if (tokenResp.statusCode != 200) {
|
|
||||||
throw Exception(
|
|
||||||
'Token request failed (${tokenResp.statusCode}): $tokenBody',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return TokenGrantResponse.fromJson(
|
|
||||||
jsonDecode(tokenBody) as Map<String, dynamic>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _resetMockServer(HttpClient httpClient) async {
|
|
||||||
final req = await httpClient.postUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/admin/api/reset'),
|
|
||||||
);
|
|
||||||
final resp = await req.close();
|
|
||||||
await resp.drain();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _putTimetable(
|
|
||||||
HttpClient httpClient,
|
|
||||||
List<Map<String, dynamic>> lessons,
|
|
||||||
) async {
|
|
||||||
final req = await httpClient.putUrl(
|
|
||||||
Uri.parse('$_mockServerUrl/admin/api/timetable'),
|
|
||||||
);
|
|
||||||
req.headers.contentType = ContentType.json;
|
|
||||||
req.write(jsonEncode(lessons));
|
|
||||||
final resp = await req.close();
|
|
||||||
if (resp.statusCode != 204 && resp.statusCode != 200) {
|
|
||||||
final body = await resp.transform(utf8.decoder).join();
|
|
||||||
throw Exception('Failed to PUT timetable (${resp.statusCode}): $body');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> _lesson({
|
|
||||||
required String uid,
|
|
||||||
required String start,
|
|
||||||
required String end,
|
|
||||||
required String name,
|
|
||||||
}) {
|
|
||||||
final today = DateTime.now();
|
|
||||||
final datePrefix =
|
|
||||||
'${today.year}-${today.month.toString().padLeft(2, '0')}-${today.day.toString().padLeft(2, '0')}';
|
|
||||||
return {
|
|
||||||
'Uid': uid,
|
|
||||||
'Datum': '${datePrefix}T00:00:00',
|
|
||||||
'KezdetIdopont': '${datePrefix}T$start:00',
|
|
||||||
'VegIdopont': '${datePrefix}T$end:00',
|
|
||||||
'Nev': name,
|
|
||||||
'OsztalyCsoport': {'Uid': '10,11.A', 'Nev': '11.A'},
|
|
||||||
'TanarNeve': 'Teszt Tanár',
|
|
||||||
'Tantargy': {
|
|
||||||
'Uid': '1,MATEK',
|
|
||||||
'Nev': name,
|
|
||||||
'Kategoria': {
|
|
||||||
'Uid': '1',
|
|
||||||
'Nev': 'Kötelező',
|
|
||||||
'Leiras': 'Kötelező tantárgy',
|
|
||||||
},
|
|
||||||
'SortIndex': 1,
|
|
||||||
},
|
|
||||||
'TeremNeve': '101',
|
|
||||||
'Tipus': {'Uid': '1', 'Nev': 'Tanóra', 'Leiras': 'Tanóra'},
|
|
||||||
'TanuloJelenlet': {'Uid': '', 'Nev': '', 'Leiras': ''},
|
|
||||||
'Allapot': {'Uid': '1', 'Nev': 'Megtartott', 'Leiras': 'Megtartott óra'},
|
|
||||||
'IsTanuloHaziFeladatEnabled': false,
|
|
||||||
'IsHaziFeladatMegoldva': false,
|
|
||||||
'Csatolmanyok': [],
|
|
||||||
'IsDigitalisOra': false,
|
|
||||||
'DigitalisTamogatoEszkozTipusList': [],
|
|
||||||
'Letrehozas': '${datePrefix}T00:00:00',
|
|
||||||
'UtolsoModositas': DateTime.now().toUtc().toIso8601String(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
FlutterLocalNotificationsPlatform.instance = MockNotificationsPlatform();
|
|
||||||
logger = Logger('TimetableCacheReconciliationTest');
|
|
||||||
|
|
||||||
group('Timetable cache reconciliation against mock Kreta server', () {
|
|
||||||
late HttpClient httpClient;
|
|
||||||
|
|
||||||
setUp(() {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
httpClient = HttpClient()..connectionTimeout = const Duration(seconds: 5);
|
|
||||||
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('plugins.flutter.io/path_provider'),
|
|
||||||
(MethodCall methodCall) async => Directory.systemTemp.path,
|
|
||||||
);
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('dev.fluttercommunity.plus/package_info'),
|
|
||||||
(MethodCall methodCall) async => {
|
|
||||||
'appName': 'firka',
|
|
||||||
'packageName': 'app.firka.naplo',
|
|
||||||
'version': '1.0.0',
|
|
||||||
'buildNumber': '1',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
||||||
.setMockMethodCallHandler(
|
|
||||||
const MethodChannel('firka.app/main'),
|
|
||||||
(MethodCall methodCall) async => 'SM-A705FN;11;30',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
tearDown(() {
|
|
||||||
httpClient.close(force: true);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'stale lesson rows are removed when the school edits the timetable',
|
|
||||||
(tester) async {
|
|
||||||
HttpOverrides.global = _RealHttpOverrides();
|
|
||||||
|
|
||||||
await tester.runAsync(() async {
|
|
||||||
await _resetMockServer(httpClient);
|
|
||||||
await _putTimetable(httpClient, [
|
|
||||||
_lesson(
|
|
||||||
uid: '9001',
|
|
||||||
start: '07:30',
|
|
||||||
end: '08:15',
|
|
||||||
name: 'Matematika',
|
|
||||||
),
|
|
||||||
_lesson(uid: '9002', start: '08:25', end: '09:10', name: 'Fizika'),
|
|
||||||
_lesson(uid: '9003', start: '09:20', end: '10:05', name: 'Kémia'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
final isar = await initDB();
|
|
||||||
await isar.writeTxn(() async {
|
|
||||||
await isar.clear();
|
|
||||||
});
|
|
||||||
Settings = SettingsRepository(isar);
|
|
||||||
await Settings.loadAll();
|
|
||||||
|
|
||||||
await Settings.mockBackendEnabled.set(true);
|
|
||||||
await Settings.mockBackendUrl.set(_mockServerUrl);
|
|
||||||
|
|
||||||
final tokenResp = await _authenticateMockServer(httpClient);
|
|
||||||
final tokenModel = TokenModel.fromResp(tokenResp);
|
|
||||||
|
|
||||||
await isar.writeTxn(() async {
|
|
||||||
await isar.tokenModels.clear();
|
|
||||||
await isar.tokenModels.put(tokenModel);
|
|
||||||
});
|
|
||||||
|
|
||||||
await initializeApp();
|
|
||||||
expect(initDone, isTrue);
|
|
||||||
|
|
||||||
final client = initData.client!;
|
|
||||||
await client.init();
|
|
||||||
await client.renewCache(reInit: false);
|
|
||||||
|
|
||||||
final today = DateTime.now();
|
|
||||||
bool isToday(DateTime d) =>
|
|
||||||
d.year == today.year &&
|
|
||||||
d.month == today.month &&
|
|
||||||
d.day == today.day;
|
|
||||||
List<LessonCacheModel> lessonsFor(CacheManager cache) => cache
|
|
||||||
.getTimeTable()
|
|
||||||
.findAllSync()
|
|
||||||
.where((l) => isToday(l.start))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
final before = lessonsFor(client.cache);
|
|
||||||
expect(
|
|
||||||
before.length,
|
|
||||||
3,
|
|
||||||
reason: 'initial sync should cache exactly the 3 seeded lessons',
|
|
||||||
);
|
|
||||||
|
|
||||||
// simulates a school schedule edit
|
|
||||||
await _putTimetable(httpClient, [
|
|
||||||
_lesson(
|
|
||||||
uid: '9001',
|
|
||||||
start: '07:30',
|
|
||||||
end: '08:15',
|
|
||||||
name: 'Matematika',
|
|
||||||
),
|
|
||||||
_lesson(
|
|
||||||
uid: '9002-v2',
|
|
||||||
start: '08:20',
|
|
||||||
end: '09:00',
|
|
||||||
name: 'Fizika',
|
|
||||||
),
|
|
||||||
_lesson(uid: '9003', start: '09:05', end: '09:50', name: 'Kémia'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await client.renewCache(reInit: false);
|
|
||||||
|
|
||||||
final after = lessonsFor(client.cache);
|
|
||||||
expect(
|
|
||||||
after.length,
|
|
||||||
3,
|
|
||||||
reason:
|
|
||||||
'stale lesson row for the old timetable version should have been deleted',
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
after.map((l) => l.dailyNth).toSet().length,
|
|
||||||
after.length,
|
|
||||||
reason: 'no two lessons should occupy the same period number',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
14
firka_common/codegen-lock.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
isar:
|
||||||
|
"lib/data/models/class_average_cache_model.dart": "90a643e1f50930f411ababfa34bab18aaa12cd9e793005d677f2f8196a3173d4"
|
||||||
|
"lib/data/models/app_settings_model.dart": "5eb5af345f1347f104257f0999763650fe2673f9da1754bd12d3f756fe5c9723"
|
||||||
|
"lib/data/models/omission_cache_model.dart": "896c653235faebb943e294aa9d75b2c994f1acfe911c29b957b14c0c8ab3d85c"
|
||||||
|
"lib/data/models/message_cache_model.dart": "42c194a6025712d1ca2c303d6ef0955806019b483cecd7fa5147a9fa32431505"
|
||||||
|
"lib/data/models/teacher_model.dart": "ffab1ff798c675301d2315f0ac1d195a8a3c11a49da5bda4f9aff63fedf36d1e"
|
||||||
|
"lib/data/models/token_model.dart": "5db2b08a14fc36981e26d9a7e00086ce8931e2640a5b905c7eb86f63d7a15106"
|
||||||
|
"lib/data/models/lesson_cache_model.dart": "096a6fb43b0c5d99b7032e6eb11cc3e2b1cae356f8cf5160cc3ebda36beb22a4"
|
||||||
|
"lib/data/models/student_cache_model.dart": "404879e1ca8951e50dce84c4108e4ccd7276507004575667e0b5cade31d4a27a"
|
||||||
|
"lib/data/models/class_group_cache_model.dart": "15d16696500186987b3ab2bb5aa26111dedf01f1f6db92589e99deed15775453"
|
||||||
|
"lib/data/models/homework_cache_model.dart": "e65c5385dd6969e6bf1e8f8df6236858da8c884481b935064968d0716048c7c9"
|
||||||
|
"lib/data/models/test_cache_model.dart": "d41b6e094267c9c847f382a0ce8a5b1633609d10b2567af82f328aaaa14c4054"
|
||||||
|
"lib/data/models/grade_cache_model.dart": "192c65e52619dd44f8eac74cc3df39af69c414c9b087d31d50607ce9531aeecc"
|
||||||
|
"lib/data/models/subject_cache_model.dart": "dc9fcfb0241d683ad95944cde761c143849151c4ec1c6ba50c2708f103f6fe3d"
|
||||||
@@ -18,14 +18,6 @@ extension IterableExtension<T> on Iterable<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension FirstUpperExtension on String {
|
|
||||||
String firstUpper() {
|
|
||||||
if (isEmpty) return this;
|
|
||||||
if (length == 1) this[0].toUpperCase();
|
|
||||||
return this[0].toUpperCase() + substring(1, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension MidnightExtension on DateTime {
|
extension MidnightExtension on DateTime {
|
||||||
DateTime getMidnight() {
|
DateTime getMidnight() {
|
||||||
return subtract(
|
return subtract(
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
import 'package:firka_common/data/models/generic_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
@@ -16,7 +15,6 @@ class OmissionCacheModel extends GenericCacheModel<Omission> {
|
|||||||
String? proofType;
|
String? proofType;
|
||||||
|
|
||||||
final lesson = IsarLink<LessonCacheModel>();
|
final lesson = IsarLink<LessonCacheModel>();
|
||||||
final classGroup = IsarLink<ClassGroupCacheModel>();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void apply(CacheContext<Omission> ctx) {
|
void apply(CacheContext<Omission> ctx) {
|
||||||
@@ -25,8 +23,7 @@ class OmissionCacheModel extends GenericCacheModel<Omission> {
|
|||||||
..state = ctx.data.state
|
..state = ctx.data.state
|
||||||
..teacherName = ctx.data.teacher
|
..teacherName = ctx.data.teacher
|
||||||
..proofType = ctx.data.proofType?.description
|
..proofType = ctx.data.proofType?.description
|
||||||
..createdAt = ctx.data.createdAt
|
..createdAt = ctx.data.createdAt;
|
||||||
..classGroup.unsafeInit(ctx.cacheManager, ctx.data.classGroup);
|
|
||||||
lesson.value = ctx.cacheManager
|
lesson.value = ctx.cacheManager
|
||||||
.getTimeTable()
|
.getTimeTable()
|
||||||
.startEqualTo(ctx.data.lesson!.start)
|
.startEqualTo(ctx.data.lesson!.start)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
import 'package:firka_common/data/models/generic_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
@@ -15,7 +14,6 @@ class TestCacheModel extends GenericCacheModel<Test> {
|
|||||||
|
|
||||||
@Backlink(to: "test")
|
@Backlink(to: "test")
|
||||||
final lesson = IsarLink<LessonCacheModel>();
|
final lesson = IsarLink<LessonCacheModel>();
|
||||||
final classGroup = IsarLink<ClassGroupCacheModel>();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void apply(CacheContext<Test> ctx) {
|
void apply(CacheContext<Test> ctx) {
|
||||||
@@ -23,7 +21,6 @@ class TestCacheModel extends GenericCacheModel<Test> {
|
|||||||
..topic = ctx.data.theme
|
..topic = ctx.data.theme
|
||||||
..method = ctx.data.method.description
|
..method = ctx.data.method.description
|
||||||
..teacherName = ctx.data.teacherName
|
..teacherName = ctx.data.teacherName
|
||||||
..createdAt = ctx.data.reportDate
|
..createdAt = ctx.data.reportDate;
|
||||||
..classGroup.unsafeInit(ctx.cacheManager, ctx.data.classGroup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:firka_common/core/extensions.dart';
|
|
||||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ class GradeSmallCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
subject.name.firstUpper(),
|
subject.name,
|
||||||
style: appStyle.fonts.B_16SB.apply(
|
style: appStyle.fonts.B_16SB.apply(
|
||||||
color: appStyle.colors.textPrimary,
|
color: appStyle.colors.textPrimary,
|
||||||
),
|
),
|
||||||
|
|||||||