fluffychat merge
This commit is contained in:
commit
c8e111c2b2
9 changed files with 12 additions and 133 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -91,3 +91,4 @@ android/app/google-services.json
|
|||
web/pkg/package.json
|
||||
web/pkg/vodozemac_bindings_dart_bg.wasm
|
||||
web/pkg/vodozemac_bindings_dart.js
|
||||
web/native_executor.js*
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import 'package:matrix/matrix.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
|
|
@ -212,7 +211,6 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
final AutoScrollController scrollController = AutoScrollController();
|
||||
|
||||
late final FocusNode inputFocus;
|
||||
StreamSubscription<html.Event>? onFocusSub;
|
||||
|
||||
Timer? typingCoolDown;
|
||||
Timer? typingTimeout;
|
||||
|
|
@ -497,10 +495,6 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
: '';
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_tryLoadTimeline();
|
||||
if (kIsWeb) {
|
||||
onFocusSub = html.window.onFocus.listen((_) => setReadMarker());
|
||||
}
|
||||
|
||||
// #Pangea
|
||||
_pangeaInit();
|
||||
// Pangea#
|
||||
|
|
@ -848,9 +842,6 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
timeline = null;
|
||||
// #Pangea
|
||||
// inputFocus.removeListener(_inputFocusListener);
|
||||
// Pangea#
|
||||
onFocusSub?.cancel();
|
||||
// #Pangea
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_storeInputTimeoutTimer?.cancel();
|
||||
_displayChatDetailsColumn.dispose();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import 'package:fluffychat/config/setting_keys.dart';
|
|||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/utils/custom_http_client.dart';
|
||||
import 'package:fluffychat/utils/custom_image_resizer.dart';
|
||||
import 'package:fluffychat/utils/init_with_restore.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart';
|
||||
|
|
@ -103,7 +102,10 @@ abstract class ClientManager {
|
|||
}
|
||||
|
||||
static NativeImplementations get nativeImplementations => kIsWeb
|
||||
? const NativeImplementationsDummy()
|
||||
? NativeImplementationsWebWorker(
|
||||
Uri.parse('native_executor.js'),
|
||||
timeout: const Duration(minutes: 1),
|
||||
)
|
||||
: NativeImplementationsIsolate(
|
||||
compute,
|
||||
vodozemacInit: () => vod.init(wasmPath: './assets/assets/vodozemac/'),
|
||||
|
|
@ -155,9 +157,6 @@ abstract class ClientManager {
|
|||
AuthenticationTypes.sso,
|
||||
},
|
||||
nativeImplementations: nativeImplementations,
|
||||
customImageResizer: PlatformInfos.isMobile || kIsWeb
|
||||
? customImageResizer
|
||||
: null,
|
||||
defaultNetworkRequestTimeout: const Duration(minutes: 30),
|
||||
enableDehydratedDevices: true,
|
||||
shareKeysWith:
|
||||
|
|
|
|||
|
|
@ -1,101 +0,0 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:native_imaging/native_imaging.dart' as native;
|
||||
|
||||
(int, int) _scaleToBox(int width, int height, {required int boxSize}) {
|
||||
final fit = applyBoxFit(
|
||||
BoxFit.scaleDown,
|
||||
Size(width.toDouble(), height.toDouble()),
|
||||
Size(boxSize.toDouble(), boxSize.toDouble()),
|
||||
).destination;
|
||||
return (fit.width.round(), fit.height.round());
|
||||
}
|
||||
|
||||
Future<MatrixImageFileResizedResponse?> customImageResizer(
|
||||
MatrixImageFileResizeArguments arguments,
|
||||
) async {
|
||||
await native.init();
|
||||
|
||||
var imageBytes = arguments.bytes;
|
||||
String? blurhash;
|
||||
|
||||
var originalWidth = 0;
|
||||
var originalHeight = 0;
|
||||
var width = 0;
|
||||
var height = 0;
|
||||
|
||||
try {
|
||||
// for the other platforms
|
||||
final dartCodec = await instantiateImageCodec(arguments.bytes);
|
||||
final frameCount = dartCodec.frameCount;
|
||||
final dartFrame = await dartCodec.getNextFrame();
|
||||
final rgbaData = await dartFrame.image.toByteData();
|
||||
if (rgbaData == null) {
|
||||
return null;
|
||||
}
|
||||
final rgba = Uint8List.view(
|
||||
rgbaData.buffer,
|
||||
rgbaData.offsetInBytes,
|
||||
rgbaData.lengthInBytes,
|
||||
);
|
||||
|
||||
width = originalWidth = dartFrame.image.width;
|
||||
height = originalHeight = dartFrame.image.height;
|
||||
|
||||
var nativeImg = native.Image.fromRGBA(width, height, rgba);
|
||||
|
||||
dartFrame.image.dispose();
|
||||
dartCodec.dispose();
|
||||
|
||||
if (arguments.calcBlurhash) {
|
||||
// scale down image for blurhashing to speed it up
|
||||
final (blurW, blurH) = _scaleToBox(width, height, boxSize: 100);
|
||||
final blurhashImg = nativeImg.resample(
|
||||
blurW,
|
||||
blurH,
|
||||
// nearest is unsupported...
|
||||
native.Transform.bilinear,
|
||||
);
|
||||
|
||||
blurhash = blurhashImg.toBlurhash(3, 3);
|
||||
|
||||
blurhashImg.free();
|
||||
}
|
||||
|
||||
if (frameCount > 1) {
|
||||
// Don't scale down animated images, since those would lose frames.
|
||||
nativeImg.free();
|
||||
} else {
|
||||
final max = arguments.maxDimension;
|
||||
if (width > max || height > max) {
|
||||
(width, height) = _scaleToBox(width, height, boxSize: max);
|
||||
|
||||
final scaledImg = nativeImg.resample(
|
||||
width,
|
||||
height,
|
||||
native.Transform.lanczos,
|
||||
);
|
||||
nativeImg.free();
|
||||
nativeImg = scaledImg;
|
||||
}
|
||||
|
||||
imageBytes = await nativeImg.toJpeg(75);
|
||||
nativeImg.free();
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logs().e("Could not generate preview", e, s);
|
||||
}
|
||||
|
||||
return MatrixImageFileResizedResponse(
|
||||
bytes: imageBytes,
|
||||
width: width,
|
||||
height: height,
|
||||
originalWidth: originalWidth,
|
||||
originalHeight: originalHeight,
|
||||
blurhash: blurhash,
|
||||
);
|
||||
}
|
||||
|
|
@ -244,8 +244,6 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
final onNotification = <String, StreamSubscription>{};
|
||||
final onLoginStateChanged = <String, StreamSubscription<LoginState>>{};
|
||||
final onUiaRequest = <String, StreamSubscription<UiaRequest>>{};
|
||||
StreamSubscription<html.Event>? onFocusSub;
|
||||
StreamSubscription<html.Event>? onBlurSub;
|
||||
|
||||
String? _cachedPassword;
|
||||
Timer? _cachedPasswordClearTimer;
|
||||
|
|
@ -478,11 +476,6 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
_registerSubs(c.clientName);
|
||||
}
|
||||
|
||||
if (kIsWeb) {
|
||||
onFocusSub = html.window.onFocus.listen((_) => webHasFocus = true);
|
||||
onBlurSub = html.window.onBlur.listen((_) => webHasFocus = false);
|
||||
}
|
||||
|
||||
if (PlatformInfos.isMobile) {
|
||||
backgroundPush = BackgroundPush(
|
||||
this,
|
||||
|
|
@ -552,8 +545,6 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
onLoginStateChanged.values.map((s) => s.cancel());
|
||||
onNotification.values.map((s) => s.cancel());
|
||||
client.httpClient.close();
|
||||
onFocusSub?.cancel();
|
||||
onBlurSub?.cancel();
|
||||
|
||||
linuxNotifications?.close();
|
||||
// #Pangea
|
||||
|
|
|
|||
|
|
@ -736,7 +736,7 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_foreground_task
|
||||
sha256: "9f1b25a81db95d7119d2c5cffc654048cbdd49d4056183e1beadc1a6a38f3e29"
|
||||
sha256: "48ea45056155a99fb30b15f14f4039a044d925bc85f381ed0b2d3b00a60b99de"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.1.0"
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ dependencies:
|
|||
file_selector: ^1.1.0
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_foreground_task: ^9.1.0
|
||||
flutter_foreground_task: ^9.2.0
|
||||
flutter_linkify: ^6.0.0
|
||||
flutter_local_notifications: ^19.5.0
|
||||
flutter_localizations:
|
||||
|
|
|
|||
|
|
@ -11,10 +11,5 @@ rm -f ./assets/vodozemac/vodozemac_bindings_dart*
|
|||
mv .vodozemac/dart/web/pkg/vodozemac_bindings_dart* ./assets/vodozemac/
|
||||
rm -rf .vodozemac
|
||||
|
||||
# Add native imaging:
|
||||
cd web/
|
||||
curl -L 'https://github.com/famedly/dart_native_imaging/releases/download/v0.2.1/native_imaging.zip' > native_imaging.zip # make sure to sync version with pubspec.yaml
|
||||
unzip native_imaging.zip
|
||||
mv js/* .
|
||||
rmdir js
|
||||
rm native_imaging.zip
|
||||
flutter pub get
|
||||
dart compile js ./web/native_executor.dart -o ./web/native_executor.js -m
|
||||
3
web/native_executor.dart
Normal file
3
web/native_executor.dart
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
void main() => startWebWorker();
|
||||
Loading…
Add table
Reference in a new issue