UNPKG

stream-chat-react-native-core

Version:

The official React Native and Expo components for Stream Chat, a service for building chat applications

25 lines 1.35 kB
Object.defineProperty(exports, "__esModule", { value: true }); exports.useNotifications = void 0; var _react = require("react"); var _ChatContext = require("../../../contexts/chatContext/ChatContext"); var _useStateStore2 = require("../../../hooks/useStateStore"); var _notificationTarget = require("../notificationTarget"); var useNotifications = options => { var _useChatContext = (0, _ChatContext.useChatContext)(), client = _useChatContext.client; var selector = (0, _react.useCallback)(state => { var notifications = state.notifications; var target = options == null ? void 0 : options.target; var byTarget = target ? notifications.filter(notification => (0, _notificationTarget.isNotificationForTarget)(notification, target)) : options != null && options.requireTarget ? [] : notifications; return { notifications: options != null && options.filter ? byTarget.filter(options.filter) : byTarget }; }, [options == null ? void 0 : options.filter, options == null ? void 0 : options.requireTarget, options == null ? void 0 : options.target]); var _useStateStore = (0, _useStateStore2.useStateStore)(client.notifications.store, selector), notifications = _useStateStore.notifications; return notifications; }; exports.useNotifications = useNotifications; //# sourceMappingURL=useNotifications.js.map