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.21 kB
JavaScript
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?.target;
var byTarget = target ? notifications.filter(notification => (0, _notificationTarget.isNotificationForTarget)(notification, target)) : options?.requireTarget ? [] : notifications;
return {
notifications: options?.filter ? byTarget.filter(options.filter) : byTarget
};
}, [options?.filter, options?.requireTarget, options?.target]);
var _useStateStore = (0, _useStateStore2.useStateStore)(client.notifications.store, selector),
notifications = _useStateStore.notifications;
return notifications;
};
exports.useNotifications = useNotifications;
//# sourceMappingURL=useNotifications.js.map