|
3 | 3 | import 'dart:async'; |
4 | 4 | import 'dart:ui'; |
5 | 5 |
|
6 | | -import 'package:collection/collection.dart'; |
7 | 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; |
8 | 7 | import 'package:ion/app/features/auth/providers/auth_provider.m.dart'; |
9 | | -import 'package:ion/app/features/chat/community/models/entities/tags/pubkey_tag.f.dart'; |
10 | 8 | import 'package:ion/app/features/ion_connect/ion_connect.dart'; |
| 9 | +import 'package:ion/app/features/ion_connect/model/event_reference.f.dart'; |
11 | 10 | import 'package:ion/app/features/ion_connect/model/global_subscription_event_handler.dart'; |
12 | | -import 'package:ion/app/features/ion_connect/model/related_hashtag.f.dart'; |
13 | 11 | import 'package:ion/app/features/ion_connect/providers/ion_connect_cache.r.dart'; |
14 | 12 | import 'package:ion/app/features/tokenized_communities/models/entities/community_token_definition.f.dart'; |
15 | | -import 'package:ion/app/features/tokenized_communities/models/entities/constants.dart'; |
16 | 13 | import 'package:ion/app/features/tokenized_communities/views/creator_token_is_live_dialog.dart'; |
| 14 | +import 'package:ion/app/features/user/model/user_metadata.f.dart'; |
17 | 15 | import 'package:ion/app/services/storage/local_storage.r.dart'; |
18 | 16 | import 'package:ion/app/services/ui_event_queue/ui_event_queue_notifier.r.dart'; |
19 | 17 | import 'package:riverpod_annotation/riverpod_annotation.dart'; |
@@ -42,19 +40,24 @@ class CommunityTokenDefinitionHandler extends GlobalSubscriptionEventHandler { |
42 | 40 |
|
43 | 41 | @override |
44 | 42 | Future<void> handle(EventMessage eventMessage) async { |
45 | | - final isFirstBuyEvent = currentUserMasterPubkey != null && |
46 | | - eventMessage.tags |
47 | | - .any((tag) => tag.equals([RelatedHashtag.tagName, communityTokenActionTopic])) && |
48 | | - eventMessage.tags.any((tag) => tag.equals([PubkeyTag.tagName, currentUserMasterPubkey!])); |
49 | | - |
50 | | - final isShown = localStorage.getBool(localStorageKey) ?? false; |
| 43 | + final entity = CommunityTokenDefinitionEntity.fromEventMessage(eventMessage); |
51 | 44 |
|
52 | | - if (!isShown && isFirstBuyEvent) { |
| 45 | + if (entity |
| 46 | + case CommunityTokenDefinitionEntity( |
| 47 | + data: CommunityTokenDefinitionIon( |
| 48 | + eventReference: ReplaceableEventReference( |
| 49 | + masterPubkey: final originalEventMasterPubkey, |
| 50 | + kind: UserMetadataEntity.kind |
| 51 | + ), |
| 52 | + type: CommunityTokenDefinitionIonType.firstBuyAction |
| 53 | + ) |
| 54 | + ) |
| 55 | + when originalEventMasterPubkey == currentUserMasterPubkey && |
| 56 | + (localStorage.getBool(localStorageKey) ?? false)) { |
53 | 57 | uiEventQueueCallback(); |
54 | 58 | await localStorage.setBool(key: localStorageKey, value: true); |
55 | 59 | } |
56 | 60 |
|
57 | | - final entity = CommunityTokenDefinitionEntity.fromEventMessage(eventMessage); |
58 | 61 | await ionConnectCache.cache(entity); |
59 | 62 | } |
60 | 63 | } |
|
0 commit comments