vkdart

Форк
0
62 строки · 2.4 Кб
1
import 'package:vkdart/util.dart';
2
import 'package:vkdart/vkontakte.dart';
3

4
/// Model Wall Reply.
5
///
6
/// See https://dev.vk.com/ru/reference/objects/comment
7
class WallReplyAttachmentModel extends CustomAttachmentModel {
8
  // ignore: public_member_api_docs
9
  WallReplyAttachmentModel(super.payload) : super(attachType: 'wall_reply');
10

11
  @override
12
  int get id => payload['id'] ?? payload['cid'];
13

14
  /// The ID of the comment author.
15
  int get fromId => payload['from_id'];
16

17
  /// The date the comment was created in Unixtime format.
18
  int get createdAt => payload['date'];
19

20
  /// The text of the comment.
21
  String? get text => payload['text'];
22

23
  /// is the commentator a VK Donut subscriber.
24
  bool? get isDon => payload['donut']?['is_don'];
25

26
  /// a stub for users who have not subscribed to VK Donut.
27
  String? get donutPlacholder => payload['donut']?['placeholder'];
28

29
  /// The ID of the user or community to whom the current comment was left in response (if applicable).
30
  bool? get isReplyToUser => checkBoolInProperty('reply_to_user');
31

32
  /// The ID of the comment that the current one was left in response to (if applicable).
33
  bool? get isReplyToComment => checkBoolInProperty('reply_to_comment');
34

35
  /// Media commentary attachments (photos, links, etc.).
36
  /// See https://dev.vk.com/ru/reference/objects/comment#attachments
37
  List<AttachmentModel> get attachments =>
38
      transformAttachments((payload['attachments'] as List?)
39
              ?.map((e) => (e as Map).cast<String, dynamic>())
40
              .toList() ??
41
          const []);
42

43
  /// An array of IDs of parent comments.
44
  List<int>? get parentsStack => payload['parents_stack'];
45

46
  /// the number of comments in the thread.
47
  int? get threadCount => payload['thread']?['count'];
48

49
  /// an array of objects for comments on a record (only for the wall.getComments method).
50
  List<WallReplyAttachmentModel>? get threadItems => payload['thread']?['items']
51
      ?.map((e) => WallReplyAttachmentModel((e as Map).cast<String, dynamic>()))
52
      .toList();
53

54
  /// can the current user leave comments in this thread.
55
  bool? get isThreadCanPost => payload['thread']?['can_post'];
56

57
  /// do I need to display the reply button in the branch
58
  bool? get isThreadShowReplyButton => payload['thread']?['show_reply_button'];
59

60
  /// can communities leave comments in the thread?
61
  bool? get isThreadGroupsCanPost => payload['thread']?['groups_can_post'];
62
}
63

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.