stream-chat-react-native-core 5.22.2-beta.3 → 5.22.2-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/commonjs/components/Channel/Channel.js +119 -91
  2. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  3. package/lib/commonjs/components/MessageList/MessageList.js +55 -38
  4. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  5. package/lib/commonjs/i18n/en.json +1 -1
  6. package/lib/commonjs/i18n/fr.json +46 -46
  7. package/lib/commonjs/i18n/hi.json +46 -46
  8. package/lib/commonjs/i18n/it.json +46 -46
  9. package/lib/commonjs/i18n/nl.json +46 -46
  10. package/lib/commonjs/i18n/ru.json +46 -46
  11. package/lib/commonjs/i18n/tr.json +46 -46
  12. package/lib/commonjs/version.json +1 -1
  13. package/lib/module/components/Channel/Channel.js +119 -91
  14. package/lib/module/components/Channel/Channel.js.map +1 -1
  15. package/lib/module/components/MessageList/MessageList.js +55 -38
  16. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  17. package/lib/module/i18n/en.json +1 -1
  18. package/lib/module/i18n/fr.json +46 -46
  19. package/lib/module/i18n/hi.json +46 -46
  20. package/lib/module/i18n/it.json +46 -46
  21. package/lib/module/i18n/nl.json +46 -46
  22. package/lib/module/i18n/ru.json +46 -46
  23. package/lib/module/i18n/tr.json +46 -46
  24. package/lib/module/version.json +1 -1
  25. package/lib/typescript/i18n/en.json +1 -1
  26. package/lib/typescript/i18n/fr.json +46 -46
  27. package/lib/typescript/i18n/hi.json +46 -46
  28. package/lib/typescript/i18n/it.json +46 -46
  29. package/lib/typescript/i18n/nl.json +46 -46
  30. package/lib/typescript/i18n/ru.json +46 -46
  31. package/lib/typescript/i18n/tr.json +46 -46
  32. package/package.json +1 -1
  33. package/src/components/Channel/Channel.tsx +32 -6
  34. package/src/components/MessageList/MessageList.tsx +41 -5
  35. package/src/i18n/en.json +1 -1
  36. package/src/i18n/fr.json +46 -46
  37. package/src/i18n/hi.json +46 -46
  38. package/src/i18n/it.json +46 -46
  39. package/src/i18n/nl.json +46 -46
  40. package/src/i18n/ru.json +46 -46
  41. package/src/i18n/tr.json +46 -46
  42. package/src/version.json +1 -1
@@ -1,76 +1,76 @@
1
1
  {
2
- "1 Reply": "",
3
- "1 Thread Reply": "1 thread antwoord",
4
- "Allow access to your Gallery": "",
5
- "Allow camera access in device settings": "",
2
+ "1 Reply": "1 Antwoord",
3
+ "1 Thread Reply": "",
4
+ "Allow access to your Gallery": "Geef toegang tot uw galerij",
5
+ "Allow camera access in device settings": "Sta cameratoegang toe in de apparaatinstellingen",
6
6
  "Also send to channel": "",
7
- "Are you sure you want to permanently delete this message?": "Weet u zeker dat u dit bericht definitief wilt verwijderen?",
8
- "Block User": "Blokkeer Gebruiker",
9
- "Cancel": "Annuleer",
10
- "Cannot Flag Message": "Kan bericht niet rapporteren",
11
- "Copy Message": "Bericht kopiëren",
12
- "Delete": "Verwijderen",
13
- "Delete Message": "Verwijder bericht",
14
- "Device camera is used to take photos or videos.": "",
15
- "Do you want to send a copy of this message to a moderator for further investigation?": "Wil je een kopie van dit bericht naar een moderator sturen voor verder onderzoek?",
16
- "Edit Message": "Pas bericht aan",
7
+ "Are you sure you want to permanently delete this message?": "",
8
+ "Block User": "",
9
+ "Cancel": "",
10
+ "Cannot Flag Message": "",
11
+ "Copy Message": "",
12
+ "Delete": "",
13
+ "Delete Message": "",
14
+ "Device camera is used to take photos or videos.": "De camera van het apparaat wordt gebruikt om foto's of video's te maken.",
15
+ "Do you want to send a copy of this message to a moderator for further investigation?": "",
16
+ "Edit Message": "",
17
17
  "Editing Message": "",
18
- "Emoji matching": "",
18
+ "Emoji matching": "Emoji-overeenkomsten",
19
19
  "Empty message...": "",
20
20
  "Error loading": "",
21
21
  "Error loading channel list...": "",
22
22
  "Error loading messages for this channel...": "",
23
23
  "Error while loading, please reload/refresh": "",
24
24
  "File type not supported": "Bestandstype niet ondersteund",
25
- "Flag": "Markeer",
26
- "Flag Message": "Markeer bericht",
27
- "Flag action failed either due to a network issue or the message is already flagged": "Rapporteren mislukt door een netwerk fout of het berich is al gerapporteerd",
25
+ "Flag": "",
26
+ "Flag Message": "",
27
+ "Flag action failed either due to a network issue or the message is already flagged": "",
28
28
  "How about sending your first message to a friend?": "",
29
- "Instant Commands": "",
29
+ "Instant Commands": "Directe Opdrachten",
30
30
  "Let's start chatting!": "",
31
31
  "Links are disabled": "Het versturen van links staat uit",
32
- "Loading channels...": "",
33
- "Loading messages...": "",
34
- "Loading...": "",
35
- "Maximum file size upload limit reached. Please upload a file below {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB.": "Maximale uploadlimiet voor bestandsgrootte bereikt. Upload een bestand van minder dan {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB.",
36
- "Message Reactions": "",
32
+ "Loading channels...": "Kanalen aan het laden...",
33
+ "Loading messages...": "Berichten aan het laden...",
34
+ "Loading...": "Aan het laden...",
35
+ "Maximum file size upload limit reached. Please upload a file below {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB.": "",
36
+ "Message Reactions": "Bericht Reacties",
37
37
  "Message deleted": "",
38
- "Message flagged": "Bericht gemarkeerd",
39
- "Mute User": "Gebruiker dempen",
38
+ "Message flagged": "",
39
+ "Mute User": "",
40
40
  "Not supported": "",
41
41
  "Nothing yet...": "",
42
- "Ok": "Oké",
43
- "Only visible to you": "Alleen zichtbaar voor jou",
44
- "Open Settings": "",
42
+ "Ok": "",
43
+ "Only visible to you": "",
44
+ "Open Settings": "Open instellingen",
45
45
  "Photo": "Foto",
46
- "Photos and Videos": "",
47
- "Pin to Conversation": "Vastmaken aan gesprek",
46
+ "Photos and Videos": "Foto's en video's",
47
+ "Pin to Conversation": "",
48
48
  "Pinned by": "",
49
- "Please enable access to your photos and videos so you can share them.": "",
50
- "Please select a channel first": "Selecteer eerst een kanaal",
49
+ "Please enable access to your photos and videos so you can share them.": "Schakel toegang tot uw foto's en video's in zodat u ze kunt delen.",
50
+ "Please select a channel first": "",
51
51
  "Reconnecting...": "",
52
- "Reply": "Antwoord",
52
+ "Reply": "",
53
53
  "Reply to Message": "",
54
- "Resend": "Opnieuw versturen",
54
+ "Resend": "",
55
55
  "Search GIFs": "",
56
- "Select More Photos": "",
56
+ "Select More Photos": "Selecteer Meer foto's",
57
57
  "Send a message": "",
58
58
  "Sending links is not allowed in this conversation": "In dit gesprek is het niet toegestaan links te versturen",
59
59
  "Slow mode ON": "",
60
- "The message has been reported to a moderator.": "Het bericht is gerapporteerd aan een moderator.",
61
- "Thread Reply": "Discussie beantwoorden",
62
- "Unblock User": "Deblokkeer gebruiker",
63
- "Unknown User": "",
64
- "Unmute User": "Dempen van gebruiker opheffen",
65
- "Unpin from Conversation": "Losmaken van gesprek",
60
+ "The message has been reported to a moderator.": "",
61
+ "Thread Reply": "",
62
+ "Unblock User": "",
63
+ "Unknown User": "Onbekende gebruiker",
64
+ "Unmute User": "",
65
+ "Unpin from Conversation": "",
66
66
  "Unread Messages": "",
67
67
  "Video": "Video",
68
68
  "You": "",
69
- "You can't send messages in this channel": "",
69
+ "You can't send messages in this channel": "Je kan geen berichten sturen in dit kanaal",
70
70
  "{{ firstUser }} and {{ nonSelfUserLength }} more are typing": "",
71
- "{{ index }} of {{ photoLength }}": "",
72
- "{{ replyCount }} Replies": "",
73
- "{{ replyCount }} Thread Replies": "{{replyCount}} Discussiereacties",
71
+ "{{ index }} of {{ photoLength }}": "{{ index }} van {{ photoLength }}",
72
+ "{{ replyCount }} Replies": "{{ replyCount }} Antwoorden",
73
+ "{{ replyCount }} Thread Replies": "",
74
74
  "{{ user }} is typing": "",
75
75
  "🏙 Attachment...": ""
76
76
  }
@@ -1,76 +1,76 @@
1
1
  {
2
- "1 Reply": "",
3
- "1 Thread Reply": "1 тема Ответить",
4
- "Allow access to your Gallery": "",
5
- "Allow camera access in device settings": "",
2
+ "1 Reply": "1 Ответ",
3
+ "1 Thread Reply": "",
4
+ "Allow access to your Gallery": "Разрешить доступ к вашей галерее",
5
+ "Allow camera access in device settings": "Разрешите доступ к камере в настройках устройства.",
6
6
  "Also send to channel": "",
7
- "Are you sure you want to permanently delete this message?": "Вы действительно хотите удалить это сообщение без возможности восстановления?",
8
- "Block User": "Заблокировать пользователя",
9
- "Cancel": "Отмена",
10
- "Cannot Flag Message": "Невозможно пожаловаться на сообщение",
11
- "Copy Message": "Копировать сообщение",
12
- "Delete": "удалять",
13
- "Delete Message": "Удалить сообщение",
14
- "Device camera is used to take photos or videos.": "",
15
- "Do you want to send a copy of this message to a moderator for further investigation?": "Вы хотите отправить копию этого сообщения модератору для дальнейшего изучения?",
16
- "Edit Message": "Редактировать сообщение",
7
+ "Are you sure you want to permanently delete this message?": "",
8
+ "Block User": "",
9
+ "Cancel": "",
10
+ "Cannot Flag Message": "",
11
+ "Copy Message": "",
12
+ "Delete": "",
13
+ "Delete Message": "",
14
+ "Device camera is used to take photos or videos.": "Камера устройства используется для съемки фотографий или видео.",
15
+ "Do you want to send a copy of this message to a moderator for further investigation?": "",
16
+ "Edit Message": "",
17
17
  "Editing Message": "",
18
- "Emoji matching": "",
18
+ "Emoji matching": "Соответствие эмодзи",
19
19
  "Empty message...": "",
20
20
  "Error loading": "",
21
21
  "Error loading channel list...": "",
22
22
  "Error loading messages for this channel...": "",
23
23
  "Error while loading, please reload/refresh": "",
24
24
  "File type not supported": "Тип файла не поддерживается",
25
- "Flag": "Пометить",
26
- "Flag Message": "Пометить сообщение",
27
- "Flag action failed either due to a network issue or the message is already flagged": "Не удалось отправить жалобу. Возможные причины: проблема с подключением к интернету или ваша жалоба уже была принята.",
25
+ "Flag": "",
26
+ "Flag Message": "",
27
+ "Flag action failed either due to a network issue or the message is already flagged": "",
28
28
  "How about sending your first message to a friend?": "",
29
- "Instant Commands": "",
29
+ "Instant Commands": "Мгновенные Команды",
30
30
  "Let's start chatting!": "",
31
31
  "Links are disabled": "Ссылки отключены",
32
- "Loading channels...": "",
33
- "Loading messages...": "",
34
- "Loading...": "",
35
- "Maximum file size upload limit reached. Please upload a file below {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB.": "Достигнут предел максимального размера файла для загрузки. Загрузите файл размером менее {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} МБ.",
36
- "Message Reactions": "",
32
+ "Loading channels...": "Загружаю каналы...",
33
+ "Loading messages...": "Загружаю сообщения...",
34
+ "Loading...": "Загружаю...",
35
+ "Maximum file size upload limit reached. Please upload a file below {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB.": "",
36
+ "Message Reactions": "Сообщения Реакции",
37
37
  "Message deleted": "",
38
- "Message flagged": "Сообщение отмечено",
39
- "Mute User": "Отключить пользователя",
38
+ "Message flagged": "",
39
+ "Mute User": "",
40
40
  "Not supported": "",
41
41
  "Nothing yet...": "",
42
- "Ok": "",
43
- "Only visible to you": "Видно только вам",
44
- "Open Settings": "",
42
+ "Ok": "",
43
+ "Only visible to you": "",
44
+ "Open Settings": "Открыть настройки",
45
45
  "Photo": "Фото",
46
- "Photos and Videos": "",
47
- "Pin to Conversation": "Закрепить к беседе",
46
+ "Photos and Videos": "Фото и видео",
47
+ "Pin to Conversation": "",
48
48
  "Pinned by": "",
49
- "Please enable access to your photos and videos so you can share them.": "",
50
- "Please select a channel first": "Пожалуйста, сначала выберите канал",
49
+ "Please enable access to your photos and videos so you can share them.": "Разрешите доступ к своим фотографиям и видео, чтобы вы могли ими поделиться.",
50
+ "Please select a channel first": "",
51
51
  "Reconnecting...": "",
52
- "Reply": "Ответить",
52
+ "Reply": "",
53
53
  "Reply to Message": "",
54
- "Resend": "Отправить",
54
+ "Resend": "",
55
55
  "Search GIFs": "",
56
- "Select More Photos": "",
56
+ "Select More Photos": "Выбрать больше фотографий",
57
57
  "Send a message": "",
58
58
  "Sending links is not allowed in this conversation": "Отправка ссылок недоступна в этом чате",
59
59
  "Slow mode ON": "",
60
- "The message has been reported to a moderator.": "Сообщение отправлено модератору.",
61
- "Thread Reply": "Тема Ответить",
62
- "Unblock User": "Разблокировать пользователя",
63
- "Unknown User": "",
64
- "Unmute User": "Включить микрофон",
65
- "Unpin from Conversation": "Открепить от беседы",
60
+ "The message has been reported to a moderator.": "",
61
+ "Thread Reply": "",
62
+ "Unblock User": "",
63
+ "Unknown User": "Неизвестный пользователь",
64
+ "Unmute User": "",
65
+ "Unpin from Conversation": "",
66
66
  "Unread Messages": "",
67
67
  "Video": "видео",
68
68
  "You": "",
69
- "You can't send messages in this channel": "",
69
+ "You can't send messages in this channel": "Вы не можете отправлять сообщения в этот канал",
70
70
  "{{ firstUser }} and {{ nonSelfUserLength }} more are typing": "",
71
- "{{ index }} of {{ photoLength }}": "",
72
- "{{ replyCount }} Replies": "",
73
- "{{ replyCount }} Thread Replies": "{{replyCount}} Ответы в темах",
71
+ "{{ index }} of {{ photoLength }}": "{{ index }} из {{ photoLength }}",
72
+ "{{ replyCount }} Replies": "{{ replyCount }} Ответов",
73
+ "{{ replyCount }} Thread Replies": "",
74
74
  "{{ user }} is typing": "",
75
75
  "🏙 Attachment...": ""
76
76
  }
@@ -1,76 +1,76 @@
1
1
  {
2
- "1 Reply": "",
3
- "1 Thread Reply": "1 Konu Yanıtı",
4
- "Allow access to your Gallery": "",
5
- "Allow camera access in device settings": "",
2
+ "1 Reply": "1 Cevap",
3
+ "1 Thread Reply": "",
4
+ "Allow access to your Gallery": "Galerinize erişime izin verin",
5
+ "Allow camera access in device settings": "Cihaz ayarlarında kamera erişimine izin ver",
6
6
  "Also send to channel": "",
7
- "Are you sure you want to permanently delete this message?": "Bu mesajı kalıcı olarak silmek istediğinizden emin misiniz?",
8
- "Block User": "Kullanıcıyı engelle",
9
- "Cancel": "İptal",
10
- "Cannot Flag Message": "Raporlama Başarısız",
11
- "Copy Message": "Mesajı Kopyala",
12
- "Delete": "Sil",
13
- "Delete Message": "Mesajı Sil",
14
- "Device camera is used to take photos or videos.": "",
15
- "Do you want to send a copy of this message to a moderator for further investigation?": "Detaylı inceleme için bu mesajın kopyasını moderatöre göndermek istiyor musunuz?",
16
- "Edit Message": "Mesajı Düzenle",
7
+ "Are you sure you want to permanently delete this message?": "",
8
+ "Block User": "",
9
+ "Cancel": "",
10
+ "Cannot Flag Message": "",
11
+ "Copy Message": "",
12
+ "Delete": "",
13
+ "Delete Message": "",
14
+ "Device camera is used to take photos or videos.": "Cihaz kamerası fotoğraf veya video çekmek için kullanılır.",
15
+ "Do you want to send a copy of this message to a moderator for further investigation?": "",
16
+ "Edit Message": "",
17
17
  "Editing Message": "",
18
- "Emoji matching": "",
18
+ "Emoji matching": "Emoji eşleştirme",
19
19
  "Empty message...": "",
20
20
  "Error loading": "",
21
21
  "Error loading channel list...": "",
22
22
  "Error loading messages for this channel...": "",
23
23
  "Error while loading, please reload/refresh": "",
24
24
  "File type not supported": "Dosya türü desteklenmiyor",
25
- "Flag": "Raporla",
26
- "Flag Message": "Mesajı Raporla",
27
- "Flag action failed either due to a network issue or the message is already flagged": "Mesajın daha önce raporlanmış olması veya bir ağ bağlantısı sorunu nedeniyle raporlama işlemi başarısız oldu.",
25
+ "Flag": "",
26
+ "Flag Message": "",
27
+ "Flag action failed either due to a network issue or the message is already flagged": "",
28
28
  "How about sending your first message to a friend?": "",
29
- "Instant Commands": "",
29
+ "Instant Commands": "Anlık Komutlar",
30
30
  "Let's start chatting!": "",
31
31
  "Links are disabled": "Bağlantılar devre dışı",
32
- "Loading channels...": "",
33
- "Loading messages...": "",
34
- "Loading...": "",
35
- "Maximum file size upload limit reached. Please upload a file below {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB.": "Maksimum dosya boyutu yükleme sınırına ulaşıldı. Lütfen {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB'ın altında bir dosya yükleyin.",
36
- "Message Reactions": "",
32
+ "Loading channels...": "Kanallar yükleniyor...",
33
+ "Loading messages...": "Mesajlar yükleniyor...",
34
+ "Loading...": "Yükleniyor...",
35
+ "Maximum file size upload limit reached. Please upload a file below {{MAX_FILE_SIZE_TO_UPLOAD_IN_MB}} MB.": "",
36
+ "Message Reactions": "Mesaj Tepkileri",
37
37
  "Message deleted": "",
38
- "Message flagged": "Mesaj işaretlendi",
39
- "Mute User": "Kullanıcıyı sessize al",
38
+ "Message flagged": "",
39
+ "Mute User": "",
40
40
  "Not supported": "",
41
41
  "Nothing yet...": "",
42
- "Ok": "Tamam",
43
- "Only visible to you": "Sadece siz görebilirsiniz",
44
- "Open Settings": "",
42
+ "Ok": "",
43
+ "Only visible to you": "",
44
+ "Open Settings": "Ayarları aç",
45
45
  "Photo": "Fotoğraf",
46
- "Photos and Videos": "",
47
- "Pin to Conversation": "Konuşmaya sabitle",
46
+ "Photos and Videos": "Fotoğraflar ve Videolar",
47
+ "Pin to Conversation": "",
48
48
  "Pinned by": "",
49
- "Please enable access to your photos and videos so you can share them.": "",
50
- "Please select a channel first": "Lütfen önce bir kanal seçiniz",
49
+ "Please enable access to your photos and videos so you can share them.": "Paylaşım yapabilmek için lutfen fotoğraflarınıza ve videolarınıza erişimi etkinleştirin.",
50
+ "Please select a channel first": "",
51
51
  "Reconnecting...": "",
52
- "Reply": "Yanıtla",
52
+ "Reply": "",
53
53
  "Reply to Message": "",
54
- "Resend": "Yeniden gönder",
54
+ "Resend": "",
55
55
  "Search GIFs": "",
56
- "Select More Photos": "",
56
+ "Select More Photos": "Daha Fazla Fotoğraf Seçin",
57
57
  "Send a message": "",
58
58
  "Sending links is not allowed in this conversation": "Bu konuşmada bağlantı göndermek desteklenmiyor",
59
59
  "Slow mode ON": "",
60
- "The message has been reported to a moderator.": "Mesaj moderatöre bildirildi.",
61
- "Thread Reply": "Konu Yanıtı",
62
- "Unblock User": "Kullanıcının engelini kaldır",
63
- "Unknown User": "",
64
- "Unmute User": "Kullanıcının sesini aç",
65
- "Unpin from Conversation": "Sabitlemeyi kaldır",
60
+ "The message has been reported to a moderator.": "",
61
+ "Thread Reply": "",
62
+ "Unblock User": "",
63
+ "Unknown User": "Bilinmeyen kullanıcı",
64
+ "Unmute User": "",
65
+ "Unpin from Conversation": "",
66
66
  "Unread Messages": "",
67
67
  "Video": "Video",
68
68
  "You": "",
69
- "You can't send messages in this channel": "",
69
+ "You can't send messages in this channel": "Bu konuşmaya mesaj gönderemezsiniz",
70
70
  "{{ firstUser }} and {{ nonSelfUserLength }} more are typing": "",
71
- "{{ index }} of {{ photoLength }}": "",
72
- "{{ replyCount }} Replies": "",
73
- "{{ replyCount }} Thread Replies": "{{responseCount}} Konu Cevapı",
71
+ "{{ index }} of {{ photoLength }}": "{{ index }} / {{ photoLength }}",
72
+ "{{ replyCount }} Replies": "{{ replyCount }} Cevap",
73
+ "{{ replyCount }} Thread Replies": "",
74
74
  "{{ user }} is typing": "",
75
75
  "🏙 Attachment...": ""
76
76
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "5.22.2-beta.3",
4
+ "version": "5.22.2-beta.5",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -817,12 +817,43 @@ const ChannelWithContext = <
817
817
  async (
818
818
  queryCall: () => Promise<void>,
819
819
  onAfterQueryCall: (() => void) | undefined = undefined,
820
+ // if we are targeting a message after the query, pass it here
821
+ targetMessageId: string | undefined = undefined,
820
822
  ) => {
821
823
  setError(false);
822
824
  try {
823
825
  await queryCall();
824
826
  setLastRead(new Date());
825
827
  setHasMore(true);
828
+ if (channel && targetMessageId) {
829
+ // 30 is the maxToRenderPerBatch in MessageList
830
+ const limit = 30 * 3; // we allow 3 batches of messages to be rendered
831
+ const currentMessages = channel.state.messages;
832
+ // number of messages are over the limit, limit the length of messages
833
+ if (currentMessages.length > limit) {
834
+ const targetMessageIndex = currentMessages.findIndex(
835
+ ({ id }) => id === targetMessageId,
836
+ );
837
+ let startIndex = Math.max(targetMessageIndex - Math.floor(limit / 2), 0);
838
+ const endIndex = targetMessageIndex + Math.floor(limit / 2);
839
+ if (endIndex > currentMessages.length) {
840
+ startIndex = Math.max(startIndex - (endIndex - currentMessages.length - 1) - 1, 0);
841
+ }
842
+ const hadLatestMessages = channel.state.messages === channel.state.latestMessages;
843
+ const recentMessage = currentMessages[currentMessages.length - 1];
844
+ channel.state.clearMessages();
845
+ channel.state.messages = currentMessages.slice(startIndex, endIndex);
846
+ const stillHasLatestMessages =
847
+ hadLatestMessages &&
848
+ channel.state.messages[channel.state.messages.length - 1] === recentMessage;
849
+ setHasNoMoreRecentMessagesToLoad(stillHasLatestMessages);
850
+ channel.state.setIsUpToDate(stillHasLatestMessages);
851
+ }
852
+ } else {
853
+ const areLatestMessages = channel.state.messages === channel.state.latestMessages;
854
+ setHasNoMoreRecentMessagesToLoad(areLatestMessages);
855
+ channel.state.setIsUpToDate(areLatestMessages);
856
+ }
826
857
  copyChannelState();
827
858
  onAfterQueryCall?.();
828
859
  } catch (err) {
@@ -851,7 +882,6 @@ const ChannelWithContext = <
851
882
  // if last read date is present we can just fetch messages around that date
852
883
  // last read date not being present is an edge case if somewhere the user of SDK deletes the read state (this will usually never happen)
853
884
  if (lastReadDate) {
854
- setHasNoMoreRecentMessagesToLoad(false); // we are jumping to a message, hence we do not know for sure anymore if there are no more recent messages
855
885
  // get totally 30 messages... max 15 before last read date and max 15 after last read date
856
886
  // ref: https://github.com/GetStream/chat/pull/2588
857
887
  await channel.query(
@@ -870,7 +900,6 @@ const ChannelWithContext = <
870
900
  // we just load the latest messages (25 is the default) and we cant scroll to first unread message
871
901
  await channel.state.loadMessageIntoState('latest');
872
902
  }
873
- setLoading(false);
874
903
  },
875
904
  () => {
876
905
  if (unreadMessageIdToScrollTo) {
@@ -891,20 +920,17 @@ const ChannelWithContext = <
891
920
  async () => {
892
921
  setLoading(true);
893
922
  if (messageIdToLoadAround) {
894
- setHasNoMoreRecentMessagesToLoad(false); // we are jumping to a message, hence we do not know for sure anymore if there are no more recent messages
895
- channel.state.setIsUpToDate(false);
896
923
  await channel.state.loadMessageIntoState(messageIdToLoadAround);
897
924
  } else {
898
925
  await channel.state.loadMessageIntoState('latest');
899
- channel.state.setIsUpToDate(true);
900
926
  }
901
- setLoading(false);
902
927
  },
903
928
  () => {
904
929
  if (messageIdToLoadAround) {
905
930
  setTargetedMessage(messageIdToLoadAround);
906
931
  }
907
932
  },
933
+ messageIdToLoadAround,
908
934
  );
909
935
 
910
936
  /**
@@ -344,6 +344,11 @@ const MessageListWithContext = <
344
344
  */
345
345
  const initialScrollSettingTimeoutRef = useRef<NodeJS.Timeout>();
346
346
 
347
+ /**
348
+ * The timeout id used to temporarily load the initial scroll set flag
349
+ */
350
+ const tempDisablePaginationTrackersTimeoutRef = useRef<NodeJS.Timeout>();
351
+
347
352
  /**
348
353
  * If a messageId was requested to scroll to but was unloaded,
349
354
  * this flag keeps track of it to scroll to it after loading the message
@@ -421,6 +426,22 @@ const MessageListWithContext = <
421
426
  onEndReachedTracker.current = {};
422
427
  });
423
428
 
429
+ /**
430
+ * Disables the pagination trackers for a second
431
+ * This is used to prevent the onEndReached and onStartReached from firing
432
+ * when we scroll to the bottom or top of the list automatically without user interaction
433
+ * Ex: for targeted message scroll
434
+ */
435
+ const tempDisablePaginationTrackersRef = useRef((messageListLength: number) => {
436
+ clearTimeout(tempDisablePaginationTrackersTimeoutRef.current);
437
+ onStartReachedTracker.current[messageListLength] = true;
438
+ onEndReachedTracker.current[messageListLength] = true;
439
+ tempDisablePaginationTrackersTimeoutRef.current = setTimeout(() => {
440
+ onStartReachedTracker.current[messageListLength] = false;
441
+ onEndReachedTracker.current[messageListLength] = false;
442
+ }, 1000);
443
+ });
444
+
424
445
  useEffect(() => {
425
446
  setScrollToBottomButtonVisible(false);
426
447
  }, [disabled]);
@@ -809,6 +830,10 @@ const MessageListWithContext = <
809
830
  >((info) => {
810
831
  // We got a failure as we tried to scroll to an item that was outside the render length
811
832
  if (!flatListRef.current) return;
833
+ const dataLength = flatListRef.current.props?.data?.length;
834
+ if (dataLength) {
835
+ tempDisablePaginationTrackersRef.current(dataLength);
836
+ }
812
837
  // we don't know the actual size of all items but we can see the average, so scroll to the closest offset
813
838
  flatListRef.current.scrollToOffset({
814
839
  animated: false,
@@ -818,11 +843,16 @@ const MessageListWithContext = <
818
843
  // with a little delay to wait for scroll to offset to complete, we can then scroll to the index
819
844
  failScrollTimeoutId.current = setTimeout(() => {
820
845
  try {
846
+ if (dataLength) {
847
+ tempDisablePaginationTrackersRef.current(dataLength);
848
+ }
821
849
  flatListRef.current?.scrollToIndex({
822
850
  animated: false,
823
851
  index: info.index,
824
852
  viewPosition: 0.5, // try to place message in the center of the screen
825
853
  });
854
+ // in case the target message was cleared out
855
+ // the state being set again will trigger the highlight again
826
856
  if (messageIdLastScrolledToRef.current) {
827
857
  setTargetedMessage(messageIdLastScrolledToRef.current);
828
858
  }
@@ -860,6 +890,10 @@ const MessageListWithContext = <
860
890
  if (indexOfParentInMessageList !== -1 && flatListRef.current) {
861
891
  clearTimeout(failScrollTimeoutId.current);
862
892
  scrollToIndexFailedRetryCountRef.current = 0;
893
+ // we are scrolling automatically to the message instead of user initiating it,
894
+ // so we don't need to load more older messages
895
+ tempDisablePaginationTrackersRef.current(messageList.length);
896
+ // now scroll to it
863
897
  flatListRef.current.scrollToIndex({
864
898
  animated: true,
865
899
  index: indexOfParentInMessageList,
@@ -884,6 +918,7 @@ const MessageListWithContext = <
884
918
  useEffect(() => {
885
919
  scrollToDebounceTimeoutRef.current = setTimeout(() => {
886
920
  if (initialScrollToFirstUnreadMessage) {
921
+ clearTimeout(initialScrollSettingTimeoutRef.current);
887
922
  initialScrollSettingTimeoutRef.current = setTimeout(() => {
888
923
  // small timeout to ensure that handleScroll is called after scrollToIndex to set this flag
889
924
  setInitialScrollDone(true);
@@ -902,8 +937,14 @@ const MessageListWithContext = <
902
937
  );
903
938
  if (indexOfParentInMessageList !== -1 && flatListRef.current) {
904
939
  // By a fresh scroll we should clear the retries for the previous failed scroll
940
+ clearTimeout(scrollToDebounceTimeoutRef.current);
905
941
  clearTimeout(failScrollTimeoutId.current);
942
+ // we are scrolling automatically to the message instead of user initiating it,
943
+ // so we don't need to load more older messages
944
+ tempDisablePaginationTrackersRef.current(messageList.length);
945
+ // reset the retry count
906
946
  scrollToIndexFailedRetryCountRef.current = 0;
947
+ // now scroll to it
907
948
  flatListRef.current.scrollToIndex({
908
949
  animated: false,
909
950
  index: indexOfParentInMessageList,
@@ -915,11 +956,6 @@ const MessageListWithContext = <
915
956
  messageIdLastScrolledToRef.current = messageIdToScroll;
916
957
  }
917
958
  }, 150);
918
- return () => {
919
- clearTimeout(failScrollTimeoutId.current);
920
- clearTimeout(scrollToDebounceTimeoutRef.current);
921
- clearTimeout(initialScrollSettingTimeoutRef.current);
922
- };
923
959
  }, [targetedMessage, initialScrollToFirstUnreadMessage, messageList]);
924
960
 
925
961
  const messagesWithImages =
package/src/i18n/en.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "File type not supported": "File type not supported",
25
25
  "Flag": "Flag",
26
26
  "Flag Message": "Flag Message",
27
- "Flag action failed either due to a network issue or the message is already flagged": "Flag action failed either due to a network issue or the message is already flagged.",
27
+ "Flag action failed either due to a network issue or the message is already flagged": "Flag action failed either due to a network issue or the message is already flagged",
28
28
  "How about sending your first message to a friend?": "How about sending your first message to a friend?",
29
29
  "Instant Commands": "Instant Commands",
30
30
  "Let's start chatting!": "Let's start chatting!",