UNPKG

stream-chat-react-native-core

Version:

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

50 lines 1.61 kB
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.useEndVote = void 0; var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _contexts = require("../../../contexts"); var _hooks = require("../../../hooks"); var _Notifications = require("../../Notifications"); var useEndVote = () => { var _usePollContext = (0, _contexts.usePollContext)(), poll = _usePollContext.poll; var _useNotificationApi = (0, _Notifications.useNotificationApi)(), addNotification = _useNotificationApi.addNotification; var _useTranslationContex = (0, _contexts.useTranslationContext)(), t = _useTranslationContex.t; return (0, _hooks.useStableCallback)((0, _asyncToGenerator2.default)(function* () { try { var response = yield poll.close(); addNotification({ message: t('Poll ended'), options: { severity: 'success', type: 'api:poll:end:success' }, origin: { emitter: 'PollActions' } }); return response; } catch (error) { addNotification({ message: t('Failed to end the poll'), options: { ...(error instanceof Error ? { originalError: error } : {}), severity: 'error', type: 'api:poll:end:failed' }, origin: { emitter: 'PollActions' } }); throw error; } })); }; exports.useEndVote = useEndVote; //# sourceMappingURL=useEndVote.js.map