diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d7275b990..a78ec2574 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -34,6 +34,11 @@ jobs: with: name: Web Build path: pangeachat-web.tar.gz + - name: Upload files for deploy stage + uses: actions/upload-artifact@v3 + with: + name: web + path: build/web - name: Upload to release uses: actions/upload-release-asset@v1 env: @@ -162,7 +167,10 @@ jobs: deploy_web: runs-on: ubuntu-latest needs: build_web - environment: staging + environment: production + env: + WEBAPP_S3_BUCKET: ${{ vars.WEBAPP_S3_BUCKET }} + CF_DISTRIBUTION_ID: ${{ vars.CF_DISTRIBUTION_ID }} steps: - uses: actions/checkout@v2 - name: Download web @@ -175,4 +183,10 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.AWS_DEFAULT_REGION }} \ No newline at end of file + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: Copy files to the production website with the AWS CLI + run: | + aws s3 sync ./build/web s3://$WEBAPP_S3_BUCKET + - name: AWS CloudFront Invalidation + run: | + aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths "/*" diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 3136bfd56..2842c6759 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -63,7 +63,10 @@ abstract class AppConfig { static const bool enableSentry = true; static const String sentryDns = 'https://8591d0d863b646feb4f3dda7e5dcab38@o256755.ingest.sentry.io/5243143'; - static bool renderHtml = true; + // #Pangea + static bool renderHtml = false; + // static bool renderHtml = true; + // Pangea# static bool hideRedactedEvents = false; static bool hideUnknownEvents = true; static bool hideUnimportantStateEvents = true; diff --git a/lib/pangea/models/pangea_message_event.dart b/lib/pangea/models/pangea_message_event.dart index e9ed46487..a9ac18464 100644 --- a/lib/pangea/models/pangea_message_event.dart +++ b/lib/pangea/models/pangea_message_event.dart @@ -85,10 +85,7 @@ class PangeaMessageEvent { _representations = []; - final bool latestHasTokens = - _latestEdit.content[ModelKey.tokensSent] != null; - - if (_latestEdit.content[ModelKey.originalSent] != null && latestHasTokens) { + if (_latestEdit.content[ModelKey.originalSent] != null) { try { _representations!.add( RepresentationEvent( @@ -96,9 +93,12 @@ class PangeaMessageEvent { _latestEdit.content[ModelKey.originalSent] as Map, ), - tokens: PangeaMessageTokens.fromJson( - _latestEdit.content[ModelKey.tokensSent] as Map, - ), + tokens: _latestEdit.content[ModelKey.tokensSent] != null + ? PangeaMessageTokens.fromJson( + _latestEdit.content[ModelKey.tokensSent] + as Map, + ) + : null, choreo: _latestEdit.content[ModelKey.choreoRecord] != null ? ChoreoRecord.fromJson( _latestEdit.content[ModelKey.choreoRecord] @@ -110,26 +110,37 @@ class PangeaMessageEvent { ); } catch (err, s) { ErrorHandler.logError( + m: "error parsing originalSent", e: err, s: s, ); } } - if (_latestEdit.content[ModelKey.originalWritten] != null && - latestHasTokens) { - _representations!.add( - RepresentationEvent( - content: PangeaRepresentation.fromJson( - _latestEdit.content[ModelKey.originalWritten] - as Map, + if (_latestEdit.content[ModelKey.originalWritten] != null) { + try { + _representations!.add( + RepresentationEvent( + content: PangeaRepresentation.fromJson( + _latestEdit.content[ModelKey.originalWritten] + as Map, + ), + tokens: _latestEdit.content[ModelKey.tokensWritten] != null + ? PangeaMessageTokens.fromJson( + _latestEdit.content[ModelKey.tokensWritten] + as Map, + ) + : null, + timeline: timeline, ), - tokens: PangeaMessageTokens.fromJson( - _latestEdit.content[ModelKey.tokensWritten] as Map, - ), - timeline: timeline, - ), - ); + ); + } catch (err, s) { + ErrorHandler.logError( + m: "error parsing originalWritten", + e: err, + s: s, + ); + } } _representations!.addAll( @@ -175,6 +186,11 @@ class PangeaMessageEvent { RepresentationEvent? rep = representationByLanguage(langCode); + //if event is less than 1 minute old, then print new event + // if (isNew) { + // debugger(when: kDebugMode); + // } + while ((isNew || eventId.contains("web")) && tries < 20) { if (rep != null) return rep; await Future.delayed(const Duration(milliseconds: 500)); diff --git a/lib/pangea/models/pangea_representation_event.dart b/lib/pangea/models/pangea_representation_event.dart index bc1ed921a..857abb8f5 100644 --- a/lib/pangea/models/pangea_representation_event.dart +++ b/lib/pangea/models/pangea_representation_event.dart @@ -62,16 +62,19 @@ class RepresentationEvent { if (_tokens != null) return _tokens!.tokens; if (_event == null) { - debugger(when: kDebugMode); - ErrorHandler.logError( - m: '_event and _tokens both null', - s: StackTrace.current, - ); + // debugger(when: kDebugMode); + // ErrorHandler.logError( + // m: '_event and _tokens both null', + // s: StackTrace.current, + // ); return null; } - final Set tokenEvents = - _event!.aggregatedEvents(timeline, PangeaEventTypes.tokens); + final Set tokenEvents = _event?.aggregatedEvents( + timeline, + PangeaEventTypes.tokens, + ) ?? + {}; if (tokenEvents.isEmpty) return null; @@ -79,13 +82,13 @@ class RepresentationEvent { debugger(when: kDebugMode); Sentry.addBreadcrumb( Breadcrumb( - message: "Token events for representation ${_event!.eventId}: " + message: "Token events for representation ${_event?.eventId}: " "Content: ${tokenEvents.map((e) => e.content).toString()}" "Type: ${tokenEvents.map((e) => e.type).toString()}", ), ); ErrorHandler.logError( - m: 'should not have more than one tokenEvent per representation ${_event!.eventId}', + m: 'should not have more than one tokenEvent per representation ${_event?.eventId}', s: StackTrace.current, ); } @@ -97,12 +100,13 @@ class RepresentationEvent { Future?> tokensGlobal(BuildContext context) async { if (tokens != null) return tokens!; + if (_event == null) { - debugger(when: kDebugMode); - ErrorHandler.logError( - m: '_event and _tokens both null', - s: StackTrace.current, - ); + // debugger(when: kDebugMode); + // ErrorHandler.logError( + // m: '_event and _tokens both null', + // s: StackTrace.current, + // ); return null; } @@ -141,16 +145,16 @@ class RepresentationEvent { } final Set choreoMatrixEvents = - _event!.aggregatedEvents(timeline, PangeaEventTypes.choreoRecord); + _event?.aggregatedEvents(timeline, PangeaEventTypes.choreoRecord) ?? {}; if (choreoMatrixEvents.isEmpty) return null; if (choreoMatrixEvents.length > 1) { debugger(when: kDebugMode); ErrorHandler.logError( - m: 'should not have more than one choreoEvent per representation ${_event!.eventId}', + m: 'should not have more than one choreoEvent per representation ${_event?.eventId}', s: StackTrace.current, - data: _event!.toJson(), + data: _event?.toJson(), ); } diff --git a/lib/pangea/utils/error_handler.dart b/lib/pangea/utils/error_handler.dart index 7784b1614..874ad4170 100644 --- a/lib/pangea/utils/error_handler.dart +++ b/lib/pangea/utils/error_handler.dart @@ -1,14 +1,12 @@ import 'dart:async'; +import 'package:fluffychat/pangea/config/environment.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; - import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:http/http.dart' as http; import 'package:sentry_flutter/sentry_flutter.dart'; -import 'package:fluffychat/pangea/config/environment.dart'; - class ErrorHandler { ErrorHandler(); @@ -68,7 +66,8 @@ class ErrorHandler { String? m, Map? data, }) async { - if ((e ?? m) != null) debugPrint("error: ${e?.toString() ?? m}"); + if (m != null) debugPrint("error message: $m"); + if ((e ?? m) != null) debugPrint("error to string: ${e?.toString() ?? m}"); if (data != null) { Sentry.addBreadcrumb(Breadcrumb.fromJson(data)); } diff --git a/scripts/enable-android-google-services.patch b/scripts/enable-android-google-services.patch index 7895a16eb..db9d5c3e0 100644 --- a/scripts/enable-android-google-services.patch +++ b/scripts/enable-android-google-services.patch @@ -1,5 +1,5 @@ diff --git a/android/app/build.gradle b/android/app/build.gradle -index 001fbd72..339b35af 100644 +index bf972f30..46cebdc6 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -70,6 +70,10 @@ @@ -28,13 +28,15 @@ index 001fbd72..339b35af 100644 -//apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.google.gms.google-services' diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro -new file mode 100644 -index 00000000..40570865 ---- /dev/null +index d0e0fbc9..0a546da0 100644 +--- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro -@@ -0,0 +1,41 @@ +@@ -1 +1,42 @@ +--keep class net.sqlcipher.** { *; } +\ No newline at end of file +-optimizationpasses 5 +## Flutter wrapper ++-keep class net.sqlcipher.** { *; } +-keep class io.flutter.app.** { *; } +-keep class io.flutter.plugin.** { *; } +-keep class io.flutter.util.** { *; } @@ -108,4 +110,4 @@ index 1afc4606..894d1571 100644 - override fun provideFlutterEngine(context: Context): FlutterEngine? { return provideEngine(this) - } \ No newline at end of file + }