Skip to content

Commit

Permalink
Merge branch 'develop' into ff_series_pageview
Browse files Browse the repository at this point in the history
  • Loading branch information
phuocbitmark authored Jun 6, 2024
2 parents 26c5b85 + ceb7040 commit 2df6be5
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 144 deletions.
19 changes: 17 additions & 2 deletions lib/screen/customer_support/support_thread_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import 'package:autonomy_flutter/model/customer_support.dart' as app;
import 'package:autonomy_flutter/model/customer_support.dart';
import 'package:autonomy_flutter/model/pair.dart';
import 'package:autonomy_flutter/service/audit_service.dart';
import 'package:autonomy_flutter/service/auth_service.dart';
import 'package:autonomy_flutter/service/customer_support_service.dart';
import 'package:autonomy_flutter/service/feralfile_service.dart';
import 'package:autonomy_flutter/util/constants.dart';
import 'package:autonomy_flutter/util/datetime_ext.dart';
import 'package:autonomy_flutter/util/jwt.dart';
import 'package:autonomy_flutter/util/log.dart' as log_util;
import 'package:autonomy_flutter/util/string_ext.dart';
import 'package:autonomy_flutter/util/ui_helper.dart';
Expand Down Expand Up @@ -124,6 +126,8 @@ class _SupportThreadPageState extends State<SupportThreadPage>
final _customerSupportService = injector<CustomerSupportService>();
final _feralFileService = injector<FeralFileService>();

String? _userId;

types.TextMessage get _introMessenger => types.TextMessage(
author: _bitmark,
id: _introMessengerID,
Expand Down Expand Up @@ -152,6 +156,7 @@ class _SupportThreadPageState extends State<SupportThreadPage>

@override
void initState() {
unawaited(_getUserId());
unawaited(_fetchCustomerSupportAvailability());
unawaited(injector<CustomerSupportService>().processMessages());
injector<CustomerSupportService>()
Expand Down Expand Up @@ -205,6 +210,16 @@ class _SupportThreadPageState extends State<SupportThreadPage>
}
}

Future<String> _getUserId() async {
if (_userId != null) {
return _userId!;
}
final jwt = await injector<AuthService>().getAuthToken();
final data = parseJwt(jwt.jwtToken);
_userId = data['sub'] ?? '';
return _userId!;
}

@override
void afterFirstLayout(BuildContext context) {
final payload = widget.payload;
Expand Down Expand Up @@ -682,7 +697,7 @@ class _SupportThreadPageState extends State<SupportThreadPage>
return;
}
final issueDetails = await _customerSupportService.getDetails(_issueID!);

await _getUserId();
final parsedMessages = (await Future.wait(
issueDetails.messages.map((e) => _convertChatMessage(e, null))))
.expand((i) => i)
Expand Down Expand Up @@ -934,7 +949,7 @@ class _SupportThreadPageState extends State<SupportThreadPage>
Map<String, dynamic> metadata = {};
if (message is app.Message) {
id = tempID ?? '${message.id}';
author = message.from.contains('did:key') ? _user : _bitmark;
author = message.from == _userId ? _user : _bitmark;
status = types.Status.delivered;
createdAt = message.timestamp;
text = message.filteredMessage;
Expand Down
Loading

0 comments on commit 2df6be5

Please sign in to comment.