@@ -21,6 +21,7 @@ import '../widgets/message_list.dart';
21
21
import '../widgets/page.dart' ;
22
22
import '../widgets/store.dart' ;
23
23
import '../widgets/theme.dart' ;
24
+ import 'open.dart' ;
24
25
25
26
AndroidNotificationHostApi get _androidHost => ZulipBinding .instance.androidNotificationHost;
26
27
@@ -550,86 +551,3 @@ class NotificationDisplayManager {
550
551
return null ;
551
552
}
552
553
}
553
-
554
- /// The information contained in 'zulip://notification/…' internal
555
- /// Android intent data URL, used for notification-open flow.
556
- class NotificationOpenPayload {
557
- final Uri realmUrl;
558
- final int userId;
559
- final Narrow narrow;
560
-
561
- NotificationOpenPayload ({
562
- required this .realmUrl,
563
- required this .userId,
564
- required this .narrow,
565
- });
566
-
567
- factory NotificationOpenPayload .parseUrl (Uri url) {
568
- if (url case Uri (
569
- scheme: 'zulip' ,
570
- host: 'notification' ,
571
- queryParameters: {
572
- 'realm_url' : var realmUrlStr,
573
- 'user_id' : var userIdStr,
574
- 'narrow_type' : var narrowType,
575
- // In case of narrowType == 'topic':
576
- // 'channel_id' and 'topic' handled below.
577
-
578
- // In case of narrowType == 'dm':
579
- // 'all_recipient_ids' handled below.
580
- },
581
- )) {
582
- final realmUrl = Uri .parse (realmUrlStr);
583
- final userId = int .parse (userIdStr, radix: 10 );
584
-
585
- final Narrow narrow;
586
- switch (narrowType) {
587
- case 'topic' :
588
- final channelIdStr = url.queryParameters['channel_id' ]! ;
589
- final channelId = int .parse (channelIdStr, radix: 10 );
590
- final topicStr = url.queryParameters['topic' ]! ;
591
- narrow = TopicNarrow (channelId, TopicName (topicStr));
592
- case 'dm' :
593
- final allRecipientIdsStr = url.queryParameters['all_recipient_ids' ]! ;
594
- final allRecipientIds = allRecipientIdsStr.split (',' )
595
- .map ((idStr) => int .parse (idStr, radix: 10 ))
596
- .toList (growable: false );
597
- narrow = DmNarrow (allRecipientIds: allRecipientIds, selfUserId: userId);
598
- default :
599
- throw const FormatException ();
600
- }
601
-
602
- return NotificationOpenPayload (
603
- realmUrl: realmUrl,
604
- userId: userId,
605
- narrow: narrow,
606
- );
607
- } else {
608
- // TODO(dart): simplify after https://github.com/dart-lang/language/issues/2537
609
- throw const FormatException ();
610
- }
611
- }
612
-
613
- Uri buildUrl () {
614
- return Uri (
615
- scheme: 'zulip' ,
616
- host: 'notification' ,
617
- queryParameters: < String , String > {
618
- 'realm_url' : realmUrl.toString (),
619
- 'user_id' : userId.toString (),
620
- ...(switch (narrow) {
621
- TopicNarrow (streamId: var channelId, : var topic) => {
622
- 'narrow_type' : 'topic' ,
623
- 'channel_id' : channelId.toString (),
624
- 'topic' : topic.apiName,
625
- },
626
- DmNarrow (: var allRecipientIds) => {
627
- 'narrow_type' : 'dm' ,
628
- 'all_recipient_ids' : allRecipientIds.join (',' ),
629
- },
630
- _ => throw UnsupportedError ('Found an unexpected Narrow of type ${narrow .runtimeType }.' ),
631
- })
632
- },
633
- );
634
- }
635
- }
0 commit comments