Skip to content

Commit

Permalink
feat: mark as unread and mark as read improvements (#2833)
Browse files Browse the repository at this point in the history
* fix: remove netinfo from native handlers and add it as dev dependency of core (#2538)

* fix: add expo-clipboard to peer deps of expo-package (#2537)

* fix: remove netinfo from native handlers and add it as dev dependency of core

* fix: lint issues

* fix: revert back isMounted logic

* fix: change peer dep

* feat: remove usage of flatlist-mvcp in favour of mvcp support in RN >= 0.72 (#2539)

* fix: add expo-clipboard to peer deps of expo-package (#2537)

* feat: remove usage of flatlist-mvcp in favour of mvcp support in RN >= 0.72

* fix: remove flatlist-mvcp from example apps

* chore: update peer dep of react native

* fix: change quotedMessage type to MessageType or undefined (#2527)

* fix: change quotedMessage type to MessageType or undefined

* docs: fix lint issues

* fix: change react-native-image-resizer to @bam.tech/react-native-image-resizer (#2534)

* fix: reaction list reactions sorting order based on created_at

* fix: show reactions using reactions_group

* fix: tests

* fix: useProcessReactions hook

* fix: useProcessReactions hook and Channel message spread

* fix: change react-native-image-resizer to @bam.tech/react-native-image-resizer

* fix: remove reaction_counts from offline DB

* chore: update yarn.lock files

* fix: add reanimated and gesture handler as peer deps to package

* fix: change old gesture handler useAnimatedGestureHandler to the new API (#2563)

* feat: configure ReactionList reaction theme (#2561)

* fix: expo sample app keyboardVerticalOffset for channel and thread screen

* fix: change old gesture handler useAnimatedGestureHandler to the new API

* feat: move react-native-quick-sqlite to op-sqlite (#2541)

* feat: move react-native-quick-sqlite to op-sqlite

* docs: update docs

* fix: podfile changes

* docs: add troubleshoot guide

* fix: issues with import

* fix: update yarn.lock

* chore: update deps of expo messaging app

* feat: use react-native-blob-util instead of the react-native-fs and make it optional dependency (#2578)

* feat: use react-native-blob-util instead of the react-native-fs and make it optional dependency

* chore: fix peerdeps and add dcos

* fix: deps version on package.json

* docs: add migration guide for v5 to v6

* docs: add migration guide for v5 to v6

* docs: add migration guide for v5 to v6

* fix: upgrade cameraroll, documentpicker, haptics feedback and image crop picker to new arch compatible version

* fix: change react-native-image-crop-picker to react-native-image-picker and make it optional

* docs: add migration guide

* fix: make expo-image-picker optional

* fix: make expo-image-picker optional

* docs: apply docs changes

* fix: add check for handlers in native.ts

* fix: resolve conflicts from branch develop to v6 (#2621)

* fix: resolve conflicts from branch develop to v6

* fix: remove cameraroll on ts messaging app

* fix: remove shared folder

* chore: bump vale version

* chore: bump vale version

* chore: update vale version

* chore: resolve conflicts from develop

* chore: fix vale issues

* chore: fix vale issues

* fix: react-native-safe-area-context ios build issue

* fix: bottom sheet version

* fix: remove flipper debugger

* fix: issue with rn-svg on android and rn-video fabric compatibility

* fix: animations usage in ImageGallery (#2627)

* fix: remove rn-sqlite patch

* fix: animations laginess on the ImageGallery and MessageOverlay on new architecture (#2633)

* chore: resolve conflicts from develop (#2682)

* fix: upgrade firebase versions to fix crash (#2646)

* fix: audio recording variety bugs (#2648)

* fix: variety of bugs in async audio feature

* fix: upload of empty messages and console.log cleanup

* fix: expo permission race conditions

* fix: create pure version of stopRecording() for usage on unmount

* fix: remove redundant export

* fix: actually amend failing test suites

* chore: remove constructors as they are not needed

* fix: pr remarks

* chore: write some simplistic functionality tests

* chore: return class instance rather than class itself for better usability

* chore: add more robust tests

* fix: linter errors

* fix: only display waveform whenever the mic is locked

* docs: add Deep Linking guide for the chat SDK (#2651)

* fix: change Block user action to Ban user action and UI cookbook for blocking users (#2649)

* fix: change Block user action to Ban user action

* fix: change Block user action to Ban user action

* fix: add back blockUser action and deprecate it

* docs: UI Cookbook for Blocking users

* chore(release): 5.36.1

* chore(release): 1.28.1

* fix: issue with loading app settings when the connectUser is not called on app (#2654)

* fix: issue with loading app settings when the connectUser is not called on app

* fix: add comments

* fix: add comments

* fix: unable to upload file due to special characters in the file name (#2656)

* fix: sdk size pr (#2657)

* [CI] Update SDK Size (#2653)

Co-authored-by: Khushal Agarwal <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1148-731.o3ts4yn1huletmfehy03vvfvxg.dx.internal.cloudapp.net>

* chore(release): 5.36.2

* chore(release): 1.28.2

* feat: add live location sharing cookbook (#2659)

* feat: add live location ui cookbook

* fix: prettier lint

* Update docusaurus/docs/reactnative/guides/live-location-sharing.mdx

Co-authored-by: Oliver Lazoroski <[email protected]>

* lint fixes

* fix lint issues

* fix locks

* move to ruby 3.1 and greater

---------

Co-authored-by: Oliver Lazoroski <[email protected]>

* chore(release): 5.37.0

* chore(release): 1.29.0

* fix: avoid prepending http before native supported url schemes (#2661)

* fix: avoid prepending http before native supported url schemes

* fix: move check to link parsing module

* fix: bad memoisation in window, screen dimension listener hooks (#2664)

* fix: bad memoisation in window, screen dimension listener hooks

* remove unused variable

* feat: add create chat client hook for easy usage (#2660)

* feat: add create chat client hook for easy usage

* docs: use useCreateChatClient hook for client creation

* fix: bump fastlane plugin version (#2665)

* fix: add theme properties for EmptyStateIndicator for message list (#2667)

* fix: add theme properties for EmptyStateIndicator for message list

* fix: update snapshots

* fix: apply card cover theme property order

* fix: pagination typescript errors and db synchronization bugs (#2669)

* fix: pagination typescript errors and db synchronization bugs

* chore: write test for db serialization issue

* fix: linter issues

* [CI] Bump max tolerance for sdk size analysis (#2674)

* chore: bump sample app version to v1.30.0

* fix: remove  nin and ne  operator usage in the SDK and the sample app (#2672)

* fix: remove  and  operator usage in the SDK and the sample app

* fix: remove console log

* fix: change console log to warn

* fix: add improvemnts

* fix: import of debouncefunc

* fix: import of debouncefunc

* fix: restructure queryMembers, queryUsers and ACItriggersettings

* fix: error bubbling for suggestions in auto complete input

* fix: request image access permissions for iOS only for native image picking (#2677)

* fix: properly resolve sendMessage during memoization (#2675)

* fix: properly resolve sendMessage during memoization

* fix: remedy change so that it does not cause performance issues

* chore: revert sendMessage in the dep array

* fix: deprecate messageReactions prop and use isMessageActionsVisible instead for messageActions (#2676)

* fix: deprecate messageReactions prop and use isMessageActionsVisible instead for messageActions

* docs: fix custom message actions

* fix: execution logic for showMessageOverlay

* chore(release): 5.38.0

* chore(release): 1.29.1

* fix: update yarn.lock for the project (#2681)

* fix: copy message action type for message actions (#2679)

* chore: update sdk size (#2678)

Co-authored-by: Khushal Agarwal <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1756-392.rxb2ubmju23uthz3oztawtjyeg.dx.internal.cloudapp.net>

* chore: resolve conflicts from develop

* fix: vale lint issues

* fix: new arch project config

---------

Co-authored-by: Ivan Sekovanikj <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Alexey Alter-Pesotskiy <[email protected]>
Co-authored-by: Stream SDK Bot <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1148-731.o3ts4yn1huletmfehy03vvfvxg.dx.internal.cloudapp.net>
Co-authored-by: Santhosh Vaiyapuri <[email protected]>
Co-authored-by: Oliver Lazoroski <[email protected]>
Co-authored-by: Ivan Sekovanikj <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1756-392.rxb2ubmju23uthz3oztawtjyeg.dx.internal.cloudapp.net>

* fix: chat.test.ts

* chore: cleanup v3 docs setup and e2e tests from project (#2701)

* feat: add new message action list and reaction selector UI (#2686)

* feat: remove StreamChatRN in favour of a global context ChatConfigContext that allows providing global values (#2703)

* fix: remove deprecated code from v6 branch (#2702)

* fix: remove deprecated code from v6 branch

* fix: remove deprecated code from v6 branch

* docs: add deprecated docs

* docs: add deprecated docs

* chore: resolve conflicts from base branch

* docs: improve deprecated docs

* chore: resolve conflicts from develop

* feat: new reaction list design and improvements to MessageSimple component (#2700)

* feat: add new message action list and reaction selector UI

* fix: remove unnecessary props from OverlayContext

* docs: add comments for the props

* tests: add tests for the components

* tests: add tests for the components

* fix: chat.test.ts

* fix: chat.test.ts

* fix: add tests for the code

* fix: use rn animated to create new modal and add docs

* fix: add opacity for the message action list item when pressed

* fix: make modal better and change component names

* fix: update test snapdhots

* docs: message actions customizations

* docs: message actions customizations

* fix: theme improvements

* fix: message component render improvements

* docs: update migration guide

* feat: new reaction list design and improvements to MessageSimple component

* tests: add tests for the components

* docs: reaction list new design docs

* docs: add changes to migration guide

* docs: add changes to migration guide

* docs: add changes to migration guide

* chore: resolve conflicts from base branch

* chore: resolve conflicts from base branch

* fix: sample app overlay backdrop bug

* fix: reaction list type

* feat: add FlatList for Reaction Picker

* feat: add FlatList for Reaction Picker

* feat: add FlatList for Reaction Picker

* fix: circular dependency issue

* fix: upgrade expo to latest in expo messaging app

* fix: padding for reaction picker

* fix: update dependencies for native cli apps

* fix: add Flatlist mvcp as optional package and peer deps versions (#2720)

* fix: add Flatlist mvcp as optional package and peer deps versions

* fix: add Flatlist mvcp as optional package and peer deps versions

* docs: fix native handler docs

* docs: fix vale issues

* docs: remove native handler docs

* fix: lint issues

* fix: design issues with ReactionList bottom UI (#2717)

* fix: design issues with ReactionList bottom UI

* fix: vale issues

* fix: add a log that complains for removal for mvcp package on RN version <0.72 (#2724)

* fix: add a log that complains for removal for mvcp package on RN version <0.72

* fix: add a log that complains for removal for mvcp package on RN version <0.72

* fix: build issues

* fix: add variable under the if block

Co-authored-by: Oliver Lazoroski <[email protected]>

* fix: log

---------

Co-authored-by: Oliver Lazoroski <[email protected]>

* fix: bottom sheet modal improvements

* fix: use process reactions improvements for thread list

* docs: docusaurus setup for v6 release (#2721)

* docs: docusaurus setup for v6 release

* docs: docusaurus setup for v6 release

* docs: fix vale issues

* docs: add v5 docs to v5 folder

* chore: setup workflow and improve migration guide for v6 rc release (#2727)

* fix: linting issues

* featv6 rc release

* feat!: v6 rc release

* feat!: v6 rc release

* BREAKING CHANGE: v6 rc release

* fix: upgrade react native version in sample apps to 0.73.10 (#2728)

* feat!: rc release v6 (#2729)

* feat: styles changes for MessageActionList

* feat: styles changes for MessageUserReactions

* chore: fix noteKeywords in release config

* feat: improve Message.tsx render conditional (#2733)

BREAKING CHANGE: Update the Message.tsx conditional in the component to use ternary

* feat: remove dry run mode from release config

BREAKING CHANGE: Update the release config

* fix: way of reading the value from animated shared values in the components (#2738)

* fix: way of reading the value from animated shared values in the components

* fix: unify styles to one hook

* fix: lint issues

* fix: upgrade the RN version in example apps to 0.75.4 (#2739)

* fix: upgrade the RN version in example apps to 0.74.6

* fix: upgrade the RN version in example apps to 0.75.4

* fix: upgrade the RN version in example apps to 0.75.4

* fix: pod install issue

* fix: pod install issue

* fix: pod install issue

* fix: pod install issue

* fix: pod install issue

* feat: move react native image resizer native module to the SDK (#2751)

* feat: move react native image resizer to the native package natively

* fix: android and ios native module

* fix: add StreamChatReactNative module for ios

* fix: add StreamChatReactNative module for ios and android

* fix: add StreamChatReactNative module for ios and android

* docs: update docs for the removal of the image resizer package

* fix: tests for audio controller

* fix: tests for audio controller

* fix: update sample app

* fix: update sample app

* fix: update sample app

* fix: attachment picker image picker icon visibility as per dependency

* fix: changes after merge

* fix: lint issues

* fix: revalidate pod cache

* chore: revert cache revalidation

* fix: sender and receiver message theme colors

* fix: sender and receiver message theme colors (#2767)

* fix: upgrade op-sqlite version to be compatible with latest react native version (#2761)

* fix: upgrade op-sqlite version to be compatible with latest react native version

* fix: lint issues

* docs: add new architecture guide docs

* revert: "docs: add new architecture guide docs"

This reverts commit be16a66.

* docs: fix migration guide

* fix: add back set initial state

* chore: backport the polls docs to v5 too

* fix: add versioned sidebar update as well

* chore: upgrade sample apps to RN 0.76.1 and added new arch docs (#2756)

* chore: upgrade sample apps to RN 0.76.1

* docs: add new architecture guide

* docs: add new architecture guide

* fix: vale issues

* chore: update the sample apps

* fix: poll offline fixes (#2772)

* fix: message disallowed indicator display (#2754)

* fix: native image picker poll control (#2762)

* fix: check for channel validity before consuming config (#2760)

* fix: receiverMessageBackgroundColor hotfix (#2763)

* fix: receiverMessageBackgroundColor hotfix

* fix: tests

* chore(release): 5.41.3

* chore(release): 1.31.4

* fix: theme for the message bubble and replies (#2766)

* fix: theme for the message bubble and replies

* fix: theme for the message bubble and replies

* fix: add null coleasing operator

* fix: poll edge cases (#2768)

* fix: poll related edge cases with offline storage

* feat: offline db for polls wip

* fix: reconcile own_votes properly

* fix: all underlying offline store issues with polls

* fix: properly resolve own_votes and latest_answers

* fix: remove faulty poll check

* chore: remove commented out code

* chore: remove log

* fix: multiple answers bug and remove logs

* chore: remove index as we have primary key

* chore(release): 5.41.4

* chore(release): 1.31.5

* fix: errors during resolving conflicts and yarn.locks

* fix: pod cache revalidation

* fix: lint issues

---------

Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Khushal Agarwal <[email protected]>

* fix: revert cache revalidation and introduce dummy change in docs to trigger build

* fix: resolve lint issues once again

* fix: remove channel constants - isAdmin, isOwner and isModerator

* fix: offline mode channel hydration issues

* fix: remove channel constants - isAdmin, isOwner and isModerator (#2778)

* fix: sender and receiver message theme colors

* fix: remove channel constants - isAdmin, isOwner and isModerator

* fix: faulty build for sample apps

* fix: update yarn.lock files to fix build

* fix: android modal size

* fix: race conditions on db open and close

* fix: move dropTables into check as well

* fix: crash in some instances of useIsChannelMuted hook invocation

* fix: properly use hook in channel preview

* fix: edge cases and test

* refactor: remove stale subscriber count logic and types refactor (#2782)

* fix: regex state machine stack depth crash

* fix: update test

* fix: channel hook regressions

* fix: expo media library permissions race conditions

* feat: new message list pagination implementation

* feat: enable moderation v2 on the sdk and sample apps

* fix: listen to correct channel read events

* fix: add FlatList default for Expo

* fix: channel state initial data

* fix: revert back the onStartReached change

* fix: lint and tests

* feat: add support for membership customization

* fix: modify deployment workflow of SampleApp so that we get a release

* fix: try bumping firebase version

* fix: revert FB changes and CODE_SIGN_STYLE regression

* fix: PROVISIONING_PROFILE_SPECIFIER specific val

* fix: certificate distribution settings

* fix: upgrade bottom sheet and fix reanimated errors in new arch (#2806)

* fix: upgrade bottom sheet to get rid of warnings

* fix: add sample app yarn.lock as well

* fix: all remnants of reanimated errors

* fix: update peer dependencies

* fix: added tests for the hooks and message pagination

* fix: podlock file for sample app

* fix: channel.state break on going to background

* fix: expo media library exceptions in new arch

* chore: resolve conflicts from develop on v6 (#2813)

* chore(release): 5.42.0

* chore(release): 1.31.6

* fix: android modal size (#2784)

* fix: backport crash fix (#2787)

* fix: crash in some instances of useIsChannelMuted hook invocation

* fix: properly use hook in channel preview

* fix: edge cases and test

* chore(release): 5.42.1

* chore(release): 1.31.7

* fix: recursion depth on regex parse issue (#2790)

* fix: channel hook regressions

* fix: expo media library permissions race conditions

* fix: listen to correct channel read events

* chore(release): 5.42.2

* chore(release): 1.31.8

* feat: moderation v2 support (#2801)

* feat: enable moderation v2 on the sdk and sample apps

* chore: update yarn.lock files as well

* feat: add support for membership customization (#2802)

* feat: add support for membership customization

* fix: lint issues

* chore(release): 5.43.0

* chore(release): 1.32.0

* fix: channel.state break on going to background (#2809)

* chore(release): 5.43.1

* chore(release): 1.32.1

* chore: resolve conflicts from develop on v6

---------

Co-authored-by: Ivan Sekovanikj <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Ivan Sekovanikj <[email protected]>

* fix: camera roll issues

* fix: refactor photo resolution to native level

* fix: expo media library

* fix: properly resolve videos too

* chore: remove console.log

* chore: update yarn.lock files for example apps

* fix: throttle logic for the copy message state

* fix: bring back camera-roll to SampleApp

* fix: also podfile.lock

* fix: remove console.log

* fix: issues with video preview

* chore: remove console.log

* feat: mark as unread and handle markRead in the SDK

* chore: resolve conflicts from develop

* feat: ai-bot integration poc (#2819)

* feat: add StreamingMessageView to kick off ai feature

* fix: issues with message view

* feat: add AITypingIndicatorView

* feat: make send message button react to ai state

* fix: improve typewriter animation

* fix: improvements in ui and typewriter

* chore: add customizations to StreamingMessageView

* fix: hook deps

* chore: extract logic in hook

* fix: custom events

* fix: revert the type change in favor of changes in the LLC

* feat: codeblock scrollable view

* feat: table initial reimpl

* feat: finish table impl

* fix: horizontal scroll list performance issues

* feat: add markdown parsing fixes, optimistic code capture and various improvements

* fix: theme prop and theming in general

* fix: remove edited lalbel for ai messages

* fix: bug with stop streaming button and types

* fix: colors in md rendering

* fix: rename custom scrollview

* chore: translations

* fix: remove TODO

* chore: extract indicator styles in theme

* fix: safeguard if channel does not exist

* fix: get rid of enum and introduce proper type

* fix: allow only message overrides

* chore: update event names as per the changes

* fix: bump stream-chat-js version to v8.46.0

* fix: use channel method for sending events

* fix: cover background mode case

* fix: use type from LLC

* chore: add jsdocs

* fix: move check to checker fn

* fix: add overrides for StreamingMessageView

* chore: add override for stop streaming button

* fix: message list improvements and channel first message mark unread improvements

* fix: lint issues

* chore: upgrade expo sample app to expo 52

* fix: remove unnecessary android and ios permissions

* chore: update yarn.lock files

* tests: add tests for the mark as unread feature

* fix: unread message indicator on small message list

* fix: date separator for small list

* fix: improve scrolling fast scenario for scroll to target message

* refactor: remove stale subscriber count logic and types refactor (#2832)

* refactor: remove stale subscriber count logic and types refactor (#2782)

* fix: lint issues

* feat: Message list pagination implementation using hasPrev and hasNext (#2799)

* refactor: remove stale subscriber count logic and types refactor (#2782)

* feat: new message list pagination implementation

* fix: channel state initial data

* fix: revert back the onStartReached change

* fix: lint and tests

* fix: added tests for the hooks and message pagination

* fix: podlock file for sample app

* fix: throttle logic for the copy message state

* fix: add back channel.deleted event

* fix: useeffect deps

* fix: add theme for the bottom sheet styles and message user reactions item (#2827)

* fix: refactor some of the buttons

* fix: refactor context usage

* fix: solve final cyclical dep

* fix: add corrected app.json

* tests: add tests

* fix: convert all poll buttons to pressables

* fix: lint issues (that somehow passed without issues before)

* chore: move add comment button to correct file

* fix: move vote button to correct file too

* fix: scroll to first unread message bug

* fix: tests and lint issues

* fix: image gallery issues (#2835)

* fix: infinite image loading issue

* fix: image gallery animations issue

* fix: attachment picker unread floating indicator issue

* fix: remove unnecessary logs

* fix: add tests

* fix: add improvements around read channel state

* fix: image gallery header and footer safe area view (#2840)

* fix: tests and lint issues

* fix: tests and lint issues

* chore: remove disable if frozen channel (#2841)

* chore: write tests for disallowed sending messages (#2839)

* chore: write tests for disallowed sending messages

* fix: make test name more concise

* chore: remove redundant assertion

* chore: add test for the editing state as well

* fix: only disable message input ui when capabilities change (#2836)

* chore: remove disableIfFrozenChannel prop

* fix: lint issues

* fix: old arch image resizer native module spec file name fix (#2842)

* fix: image gallery header and footer safe area view

* fix: old arch image resizer native module spec file name fix

* chore: fix all of the GH workflow stuff related to v6 in prep for releasing (#2843)

* fix: move logic to component

* fix: lint issues

* fix: issues with handleSyncDb events

* fix: dep update

* fix: dep update

* fiX: message list scroll settime outs

* fix: lint issues

* fix: broken tests

---------

Co-authored-by: Ivan Sekovanikj <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Alexey Alter-Pesotskiy <[email protected]>
Co-authored-by: Stream SDK Bot <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1148-731.o3ts4yn1huletmfehy03vvfvxg.dx.internal.cloudapp.net>
Co-authored-by: Santhosh Vaiyapuri <[email protected]>
Co-authored-by: Oliver Lazoroski <[email protected]>
Co-authored-by: Ivan Sekovanikj <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1756-392.rxb2ubmju23uthz3oztawtjyeg.dx.internal.cloudapp.net>
  • Loading branch information
10 people committed Dec 24, 2024
1 parent 0de896d commit 672e060
Show file tree
Hide file tree
Showing 43 changed files with 2,138 additions and 1,201 deletions.
10 changes: 5 additions & 5 deletions examples/SampleApp/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ PODS:
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.10)
- SocketRocket (0.7.1)
- stream-chat-react-native (6.0.0):
- stream-chat-react-native (6.0.1):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -2474,7 +2474,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 1dca942403ed9342f98334bf4c3621f011aa7946
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: 1bf99bb46c6af9a2712592e707347315f23947aa
Firebase: 7a56fe4f56b5ab81b86a6822f5b8f909ae6fc7e2
FirebaseAnalytics: 2f4a11eeb7a0e9c6fcf642d4e6aaca7fa4d38c28
Expand All @@ -2488,7 +2488,7 @@ SPEC CHECKSUMS:
FirebaseRemoteConfigInterop: e75e348953352a000331eb77caf01e424248e176
FirebaseSessions: b252b3f91a51186188882ea8e7e1730fc1eee391
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
GoogleAppMeasurement: ee5c2d2242816773fbf79e5b0563f5355ef1c315
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d
Expand Down Expand Up @@ -2576,9 +2576,9 @@ SPEC CHECKSUMS:
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
stream-chat-react-native: 557a9b07b068fea9a1670302ca43f8589d884e33
stream-chat-react-native: 4b3bb162446ad9b25c745fc8083a2516d363d5eb
Yoga: 7548e4449365bf0ef60db4aefe58abff37fcabec

PODFILE CHECKSUM: 4f662370295f8f9cee909f1a4c59a614999a209d

COCOAPODS: 1.14.3
COCOAPODS: 1.16.2
8 changes: 4 additions & 4 deletions examples/SampleApp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7952,10 +7952,10 @@ statuses@~1.5.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==

[email protected].0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-6.0.0.tgz#77798c7082877572ef70223e1f799d22f0c78fe7"
integrity sha512-3cFao8iL2MjP7nhVRAl1vi526FbPlqUj4BHnYQ7sUNe+xb4z/HCEL6fKFh8kIfK5MEAacOQO4juPPQktoIf7zg==
[email protected].1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-6.0.1.tgz#a67f14685519cafa58466d28eee8f1edc9dbafcf"
integrity sha512-kyHgGn2PF+JTt7eEKdHMot9Nxzx+yecnlut9oyhi/IJbxOwpjIgB87+rdQXEI5o8SeNwQuAeV3VatxGaxl5Jbw==
dependencies:
"@gorhom/bottom-sheet" "^5.0.6"
dayjs "1.10.5"
Expand Down
125 changes: 101 additions & 24 deletions package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Channel as ChannelType,
EventHandler,
FormatMessageResponse,
logChatPromiseExecution,
MessageResponse,
Reaction,
SendMessageAPIResponse,
Expand Down Expand Up @@ -92,7 +91,7 @@ import {
isImagePickerAvailable,
} from '../../native';
import * as dbApi from '../../store/apis';
import { DefaultStreamChatGenerics, FileTypes } from '../../types/types';
import { ChannelUnreadState, DefaultStreamChatGenerics, FileTypes } from '../../types/types';
import { addReactionToLocalState } from '../../utils/addReactionToLocalState';
import { compressedImageURI } from '../../utils/compressImage';
import { DBSyncManager } from '../../utils/DBSyncManager';
Expand Down Expand Up @@ -179,6 +178,7 @@ import { ScrollToBottomButton as ScrollToBottomButtonDefault } from '../MessageL
import { StickyHeader as StickyHeaderDefault } from '../MessageList/StickyHeader';
import { TypingIndicator as TypingIndicatorDefault } from '../MessageList/TypingIndicator';
import { TypingIndicatorContainer as TypingIndicatorContainerDefault } from '../MessageList/TypingIndicatorContainer';
import { UnreadMessagesNotification as UnreadMessagesNotificationDefault } from '../MessageList/UnreadMessagesNotification';
import { MessageActionList as MessageActionListDefault } from '../MessageMenu/MessageActionList';
import { MessageActionListItem as MessageActionListItemDefault } from '../MessageMenu/MessageActionListItem';
import { MessageMenu as MessageMenuDefault } from '../MessageMenu/MessageMenu';
Expand All @@ -188,6 +188,15 @@ import { MessageUserReactionsAvatar as MessageUserReactionsAvatarDefault } from
import { MessageUserReactionsItem as MessageUserReactionsItemDefault } from '../MessageMenu/MessageUserReactionsItem';
import { Reply as ReplyDefault } from '../Reply/Reply';

export type MarkReadFunctionOptions = {
/**
* Signal, whether the `channelUnreadUiState` should be updated.
* By default, the local state update is prevented when the Channel component is mounted.
* This is in order to keep the UI indicating the original unread state, when the user opens a channel.
*/
updateChannelUnreadState?: boolean;
};

const styles = StyleSheet.create({
selectChannel: { fontWeight: 'bold', padding: 16 },
});
Expand Down Expand Up @@ -301,6 +310,7 @@ export type ChannelPropsWithContext<
| 'handleDelete'
| 'handleEdit'
| 'handleFlag'
| 'handleMarkUnread'
| 'handleMute'
| 'handlePinMessage'
| 'handleReaction'
Expand Down Expand Up @@ -360,6 +370,7 @@ export type ChannelPropsWithContext<
| 'VideoThumbnail'
| 'PollContent'
| 'hasCreatePoll'
| 'UnreadMessagesNotification'
| 'StreamingMessageView'
>
> &
Expand All @@ -384,7 +395,10 @@ export type ChannelPropsWithContext<
* Overrides the Stream default mark channel read request (Advanced usage only)
* @param channel Channel object
*/
doMarkReadRequest?: (channel: ChannelType<StreamChatGenerics>) => void;
doMarkReadRequest?: (
channel: ChannelType<StreamChatGenerics>,
setChannelUnreadUiState?: (state: ChannelUnreadState) => void,
) => void;
/**
* Overrides the Stream default send message request (Advanced usage only)
* @param channelId
Expand Down Expand Up @@ -433,6 +447,10 @@ export type ChannelPropsWithContext<
* Custom loading error indicator to override the Stream default
*/
LoadingErrorIndicator?: React.ComponentType<LoadingErrorProps>;
/**
* Boolean flag to enable/disable marking the channel as read on mount
*/
markReadOnMount?: boolean;
maxMessageLength?: number;
/**
* Load the channel at a specified message instead of the most recent message.
Expand Down Expand Up @@ -529,6 +547,7 @@ const ChannelWithContext = <
handleDelete,
handleEdit,
handleFlag,
handleMarkUnread,
handleMute,
handlePinMessage,
handleQuotedReply,
Expand Down Expand Up @@ -566,6 +585,7 @@ const ChannelWithContext = <
loadingMore: loadingMoreProp,
loadingMoreRecent: loadingMoreRecentProp,
markdownRules,
markReadOnMount = true,
maxMessageLength: maxMessageLengthProp,
maxNumberOfFiles = 10,
maxTimeBetweenGroupedMessages,
Expand Down Expand Up @@ -647,6 +667,7 @@ const ChannelWithContext = <
threadMessages,
TypingIndicator = TypingIndicatorDefault,
TypingIndicatorContainer = TypingIndicatorContainerDefault,
UnreadMessagesNotification = UnreadMessagesNotificationDefault,
UploadProgressIndicator = UploadProgressIndicatorDefault,
UrlPreview = CardDefault,
VideoThumbnail = VideoThumbnailDefault,
Expand Down Expand Up @@ -674,10 +695,13 @@ const ChannelWithContext = <
const [thread, setThread] = useState<MessageType<StreamChatGenerics> | null>(threadProps || null);
const [threadHasMore, setThreadHasMore] = useState(true);
const [threadLoadingMore, setThreadLoadingMore] = useState(false);
const [channelUnreadState, setChannelUnreadState] = useState<ChannelUnreadState | undefined>(
undefined,
);

const syncingChannelRef = useRef(false);

const { setTargetedMessage, targetedMessage } = useTargetedMessage();
const { highlightedMessageId, setTargetedMessage, targetedMessage } = useTargetedMessage();

/**
* This ref will hold the abort controllers for
Expand All @@ -692,6 +716,7 @@ const ChannelWithContext = <
const {
copyStateFromChannel,
initStateFromChannel,
setRead,
setTyping,
state: channelState,
} = useChannelDataState<StreamChatGenerics>(channel);
Expand Down Expand Up @@ -754,6 +779,22 @@ const ChannelWithContext = <
}
}

if (event.type === 'notification.mark_unread') {
setChannelUnreadState((prev) => {
if (!(event.last_read_at && event.user)) return prev;
return {
first_unread_message_id: event.first_unread_message_id,
last_read: new Date(event.last_read_at),
last_read_message_id: event.last_read_message_id,
unread_messages: event.unread_messages ?? 0,
};
});
}

if (event.type === 'channel.truncated' && event.cid === channel.cid) {
setChannelUnreadState(undefined);
}

// only update channel state if the events are not the previously subscribed useEffect's subscription events
if (channel && channel.initialized) {
copyChannelState();
Expand All @@ -764,6 +805,8 @@ const ChannelWithContext = <
useEffect(() => {
let listener: ReturnType<typeof channel.on>;
const initChannel = async () => {
setLastRead(new Date());
const unreadCount = channel.countUnread();
if (!channel || !shouldSyncChannel || channel.offlineMode) return;
let errored = false;

Expand All @@ -782,14 +825,32 @@ const ChannelWithContext = <
loadInitialMessagesStateFromChannel(channel, channel.state.messagePagination.hasPrev);
}

if (client.user?.id && channel.state.read[client.user.id]) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { user, ...ownReadState } = channel.state.read[client.user.id];
setChannelUnreadState(ownReadState);
}

if (messageId) {
await loadChannelAroundMessage({ messageId, setTargetedMessage });
} else if (
initialScrollToFirstUnreadMessage &&
channel.countUnread() > scrollToFirstUnreadThreshold
client.user &&
unreadCount > scrollToFirstUnreadThreshold
) {
await loadChannelAtFirstUnreadMessage({ setTargetedMessage });
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { user, ...ownReadState } = channel.state.read[client.user.id];
await loadChannelAtFirstUnreadMessage({
channelUnreadState: ownReadState,
setChannelUnreadState,
setTargetedMessage,
});
}

if (unreadCount > 0 && markReadOnMount) {
await markRead({ updateChannelUnreadState: false });
}

listener = channel.on(handleEvent);
};

Expand Down Expand Up @@ -819,12 +880,12 @@ const ChannelWithContext = <
*/
useEffect(() => {
const handleEvent: EventHandler<StreamChatGenerics> = (event) => {
if (channel.cid === event.cid) copyChannelState();
if (channel.cid === event.cid) setRead(channel);
};

const { unsubscribe } = client.on('notification.mark_read', handleEvent);
return unsubscribe;
}, [channel.cid, client, copyChannelState]);
}, [channel, client, setRead]);

const threadPropsExists = !!threadProps;

Expand Down Expand Up @@ -858,23 +919,33 @@ const ChannelWithContext = <
/**
* CHANNEL METHODS
*/
const markRead: ChannelContextValue<StreamChatGenerics>['markRead'] = useRef(
throttle(
() => {
if (!channel || channel?.disconnected || !clientChannelConfig?.read_events) {
return;
}
const markRead: ChannelContextValue<StreamChatGenerics>['markRead'] = throttle(
async (options?: MarkReadFunctionOptions) => {
const { updateChannelUnreadState = true } = options ?? {};
if (!channel || channel?.disconnected || !clientChannelConfig?.read_events) {
return;
}

if (doMarkReadRequest) {
doMarkReadRequest(channel);
} else {
logChatPromiseExecution(channel.markRead(), 'mark read');
if (doMarkReadRequest) {
doMarkReadRequest(channel, updateChannelUnreadState ? setChannelUnreadState : undefined);
} else {
try {
const response = await channel.markRead();
if (updateChannelUnreadState && response && lastRead) {
setChannelUnreadState({
last_read: lastRead,
last_read_message_id: response?.event.last_read_message_id,
unread_messages: 0,
});
}
} catch (err) {
console.log('Error marking channel as read:', err);
}
},
defaultThrottleInterval,
throttleOptions,
),
).current;
}
},
defaultThrottleInterval,
throttleOptions,
);

const reloadThread = async () => {
if (!channel || !thread?.id) return;
Expand Down Expand Up @@ -1596,8 +1667,9 @@ const ChannelWithContext = <
overrideCapabilities: overrideOwnCapabilities,
});

const channelContext = useCreateChannelContext({
const channelContext = useCreateChannelContext<StreamChatGenerics>({
channel,
channelUnreadState,
disabled: !!channel?.data?.frozen,
EmptyStateIndicator,
enableMessageGroupingByUser,
Expand All @@ -1608,9 +1680,11 @@ const ChannelWithContext = <
!!(clientChannelConfig?.commands || [])?.some((command) => command.name === 'giphy'),
hideDateSeparators,
hideStickyDateHeader,
highlightedMessageId,
isChannelActive: shouldSyncChannel,
lastRead,
loadChannelAroundMessage,
loadChannelAtFirstUnreadMessage,
loading: channelMessagesState.loading,
LoadingIndicator,
markRead,
Expand All @@ -1620,6 +1694,7 @@ const ChannelWithContext = <
read: channelState.read ?? {},
reloadChannel,
scrollToFirstUnreadThreshold,
setChannelUnreadState,
setLastRead,
setTargetedMessage,
StickyHeader,
Expand Down Expand Up @@ -1748,6 +1823,7 @@ const ChannelWithContext = <
handleDelete,
handleEdit,
handleFlag,
handleMarkUnread,
handleMute,
handlePinMessage,
handleQuotedReply,
Expand Down Expand Up @@ -1815,6 +1891,7 @@ const ChannelWithContext = <
targetedMessage,
TypingIndicator,
TypingIndicatorContainer,
UnreadMessagesNotification,
updateMessage,
UrlPreview,
VideoThumbnail,
Expand Down
Loading

0 comments on commit 672e060

Please sign in to comment.