Compare commits

...
12 changed files with 44 additions and 29 deletions

View file

@ -19,7 +19,7 @@ jobs:
- name: Set up Flutter - name: Set up Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:
flutter-version: 3.47.4 flutter-version-file: pubspec.yaml
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6

View file

@ -19,7 +19,7 @@ jobs:
- name: Set up Flutter - name: Set up Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:
flutter-version: 3.47.4 flutter-version-file: pubspec.yaml
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6

View file

@ -19,7 +19,7 @@ jobs:
- name: Set up Flutter - name: Set up Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:
flutter-version: 3.47.4 flutter-version-file: pubspec.yaml
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6

View file

@ -14,13 +14,6 @@ if (keystorePropertiesFile.exists()) {
} }
} }
fun versionCodeOf(versionName: String): Int {
val parts = versionName.split("-", limit = 2)
val (major, minor, patch) = parts[0].split(".").map(String::toInt)
val preRelease = parts.getOrNull(1)?.let { Regex("\\d+").find(it)?.value?.toInt() ?: 0 } ?: 999
return major * 100_000_000 + minor * 1_000_000 + patch * 10_000 + preRelease
}
android { android {
namespace = "nexus.federated.nexus" namespace = "nexus.federated.nexus"
compileSdk = 37 compileSdk = 37
@ -38,7 +31,7 @@ android {
minSdk = 29 minSdk = 29
targetSdk = flutter.targetSdkVersion targetSdk = flutter.targetSdkVersion
versionCode = versionCodeOf(flutter.versionName!!) versionCode = flutter.versionCode
versionName = flutter.versionName versionName = flutter.versionName
multiDexEnabled = true multiDexEnabled = true

View file

@ -64,10 +64,14 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
final targetNdkApi = codeConfig.android.targetNdkApi; final targetNdkApi = codeConfig.android.targetNdkApi;
// Treats empty variables as unset, since e.g. F-Droid sets ANDROID_NDK_HOME to "" without an NDK
String? env(String name) => switch (Platform.environment[name]) {
"" => null,
final value => value,
};
Future<String?> findNdkFromSdk() async { Future<String?> findNdkFromSdk() async {
final androidHome = final androidHome = env("ANDROID_HOME") ?? env("ANDROID_SDK_ROOT");
Platform.environment["ANDROID_HOME"] ??
Platform.environment["ANDROID_SDK_ROOT"];
if (androidHome == null) return null; if (androidHome == null) return null;
final ndkDir = Directory(join(androidHome, "ndk")); final ndkDir = Directory(join(androidHome, "ndk"));
@ -78,9 +82,9 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
} }
final ndkHome = final ndkHome =
Platform.environment["ANDROID_NDK_HOME"] ?? env("ANDROID_NDK_HOME") ??
Platform.environment["ANDROID_NDK_ROOT"] ?? env("ANDROID_NDK_ROOT") ??
Platform.environment["NDK_HOME"] ?? env("NDK_HOME") ??
await findNdkFromSdk(); await findNdkFromSdk();
if (ndkHome == null) { if (ndkHome == null) {
@ -91,8 +95,7 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
// TODO: Someone please give me a way to detect host architecture so I can change this // TODO: Someone please give me a way to detect host architecture so I can change this
final hostTag = final hostTag =
Platform.environment["ANDROID_HOST_TAG"] ?? env("ANDROID_HOST_TAG") ?? "${Platform.operatingSystem}-x86_64";
"${Platform.operatingSystem}-x86_64";
final ccTriple = switch (targetArch) { final ccTriple = switch (targetArch) {
Architecture.arm64 => "aarch64-linux-android", Architecture.arm64 => "aarch64-linux-android",
Architecture.arm => "armv7a-linux-androideabi", Architecture.arm => "armv7a-linux-androideabi",

View file

@ -295,6 +295,7 @@ class RoomChatController(final ChatParams info)
: null, : null,
), ),
); );
if (!ref.mounted) return;
if (response.events.isEmpty) { if (response.events.isEmpty) {
state = .data(chat); state = .data(chat);
@ -333,6 +334,7 @@ class RoomChatController(final ChatParams info)
: chat!.historicalData!.start, : chat!.historicalData!.start,
), ),
); );
if (!ref.mounted) return;
ref ref
.read(RoomsController.provider.notifier) .read(RoomsController.provider.notifier)
@ -345,6 +347,7 @@ class RoomChatController(final ChatParams info)
final rootRowId = direction == .backward final rootRowId = direction == .backward
? await threadRootBefore(paginationResponse) ? await threadRootBefore(paginationResponse)
: null; : null;
if (!ref.mounted) return;
final eventRowIds = [ final eventRowIds = [
?rootRowId, ?rootRowId,
...(direction == .forward ...(direction == .forward
@ -383,6 +386,7 @@ class RoomChatController(final ChatParams info)
); );
} }
} catch (_) { } catch (_) {
if (!ref.mounted) return;
state = .data(chat); state = .data(chat);
rethrow; rethrow;
} }

View file

@ -5,6 +5,8 @@
with pkgs; with pkgs;
[ [
stdenv.cc stdenv.cc
# webcrypto's build hook runs CMake with the Unix Makefiles generator
gnumake
go go
git git
ffmpeg-headless ffmpeg-headless
@ -20,13 +22,22 @@
] ]
++ lib.optionals pkgs.stdenv.isLinux [ ++ lib.optionals pkgs.stdenv.isLinux [
wayland wayland
# nativeapi includes XInput2.h, which needs these, but xi.pc only lists them privately
libxext
libxfixes
(callPackage ./pkg/hook_pkg_config.nix { }) (callPackage ./pkg/hook_pkg_config.nix { })
]; ];
env = lib.optionalAttrs pkgs.stdenv.isLinux { env = lib.optionalAttrs pkgs.stdenv.isLinux {
# nativeapi includes XInput2.h and GTK's Wayland headers, which need these, but xi.pc and gdk-3.0.pc
# only list them privately, so its hook's pkg-config doesn't return them. Hooks only get NIX_ variables.
"NIX_CFLAGS_COMPILE_${pkgs.stdenv.cc.suffixSalt}" =
lib.concatMapStringsSep " " (pkg: "-isystem ${lib.getDev pkg}/include")
(
with pkgs;
[
libxext
libxfixes
wayland
]
);
# better_player loads libmpv at runtime to play videos # better_player loads libmpv at runtime to play videos
LD_LIBRARY_PATH = "./build/native_assets/linux:${ LD_LIBRARY_PATH = "./build/native_assets/linux:${
lib.makeLibraryPath [ lib.makeLibraryPath [

View file

@ -65,6 +65,9 @@
apps = apps =
let let
buildEnv = import ./build_env.nix { inherit pkgs lib; }; buildEnv = import ./build_env.nix { inherit pkgs lib; };
testEnv = buildEnv.env // {
DBUS_SESSION_CONFIG = "${pkgs.dbus}/share/dbus-1/session.conf";
};
e2e = pkgs.writeShellApplication { e2e = pkgs.writeShellApplication {
name = "nexus-e2e"; name = "nexus-e2e";
runtimeInputs = runtimeInputs =
@ -75,7 +78,7 @@
curl curl
dbus dbus
]); ]);
runtimeEnv = buildEnv.env; runtimeEnv = testEnv;
text = builtins.readFile ./e2e.sh; text = builtins.readFile ./e2e.sh;
}; };
screenshots = pkgs.writeShellApplication { screenshots = pkgs.writeShellApplication {
@ -87,7 +90,7 @@
oxipng oxipng
pngquant pngquant
]); ]);
runtimeEnv = buildEnv.env; runtimeEnv = testEnv;
text = builtins.readFile ./screenshots.sh; text = builtins.readFile ./screenshots.sh;
}; };

View file

@ -69,7 +69,7 @@ for file in "${files[@]}"; do
name="$(basename "$file" .dart)" name="$(basename "$file" .dart)"
mkdir -p "$work/$name/data" "$work/$name/cache" mkdir -p "$work/$name/data" "$work/$name/cache"
XDG_DATA_HOME="$work/$name/data" XDG_CACHE_HOME="$work/$name/cache" \ XDG_DATA_HOME="$work/$name/data" XDG_CACHE_HOME="$work/$name/cache" \
dbus-run-session -- \ dbus-run-session --config-file="$DBUS_SESSION_CONFIG" -- \
flutter test "$file" -d linux \ flutter test "$file" -d linux \
--dart-define="NEXUS_E2E_HOMESERVER=$homeserver" "${flutter_args[@]}" || --dart-define="NEXUS_E2E_HOMESERVER=$homeserver" "${flutter_args[@]}" ||
status=$? status=$?

View file

@ -12,7 +12,7 @@ GOCACHE="$(go env GOCACHE)"
export GOCACHE export GOCACHE
XDG_DATA_HOME="$work/data" XDG_CACHE_HOME="$work/cache" \ XDG_DATA_HOME="$work/data" XDG_CACHE_HOME="$work/cache" \
dbus-run-session -- \ dbus-run-session --config-file="$DBUS_SESSION_CONFIG" -- \
flutter test integration_test/screenshots/screenshots_test.dart -d linux \ flutter test integration_test/screenshots/screenshots_test.dart -d linux \
--dart-define="SCREENSHOTS_DIR=$work/out" "$@" --dart-define="SCREENSHOTS_DIR=$work/out" "$@"

View file

@ -1960,4 +1960,4 @@ packages:
version: "2.2.4" version: "2.2.4"
sdks: sdks:
dart: ">=3.13.3 <4.0.0" dart: ">=3.13.3 <4.0.0"
flutter: ">=3.47.0" flutter: "3.47.4"

View file

@ -1,6 +1,6 @@
name: nexus name: nexus
description: "A simple and user-friendly Matrix client" description: "A simple and user-friendly Matrix client"
version: 1.1.1 version: 1.1.1+101010999
publish_to: none publish_to: none
flutter: flutter:
@ -16,7 +16,8 @@ flutter:
uses-material-design: true uses-material-design: true
environment: environment:
sdk: ^3.13.3 sdk: 3.13.3
flutter: 3.47.4
dependency_overrides: dependency_overrides:
dynamic_color: 2.1.0 dynamic_color: 2.1.0