@r3l/app
Version:
96 lines (81 loc) • 3.42 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactRedux = require("react-redux");
var _styled = require("../../styled");
var _navigation = require("../navigation.actions");
var Breadcrumbs = function Breadcrumbs() {
var _view$discover, _community$communitie;
var dispatch = (0, _reactRedux.useDispatch)();
var auth = (0, _reactRedux.useSelector)(function (state) {
return state.auth;
});
var newPosts = (0, _reactRedux.useSelector)(function (state) {
var _state$posts;
return state === null || state === void 0 ? void 0 : (_state$posts = state.posts) === null || _state$posts === void 0 ? void 0 : _state$posts.newPostsAvailable;
});
var community = (0, _reactRedux.useSelector)(function (state) {
return state.community;
});
var view = (0, _reactRedux.useSelector)(function (state) {
var _state$navigation;
return state === null || state === void 0 ? void 0 : (_state$navigation = state.navigation) === null || _state$navigation === void 0 ? void 0 : _state$navigation.discover;
});
var communitySlug = (view === null || view === void 0 ? void 0 : (_view$discover = view.discover) === null || _view$discover === void 0 ? void 0 : _view$discover.community) || auth.community;
if (!communitySlug) {
return null;
}
var activeCommunity = community === null || community === void 0 ? void 0 : (_community$communitie = community.communities) === null || _community$communitie === void 0 ? void 0 : _community$communitie[communitySlug];
var sort = (view === null || view === void 0 ? void 0 : view.sort) || 'relevant';
var newPostsNumber = newPosts[auth.community];
var refreshPostsEl = /*#__PURE__*/_react.default.createElement(_styled.InlineLink, {
to: "#",
onClick: function onClick() {
return dispatch((0, _navigation.refreshTab)('discover'));
},
hu: 1
}, /*#__PURE__*/_react.default.createElement(_styled.Header, {
sx: {
ml: 1,
color: 'blue',
lh: 1,
fontSize: 1
}
}, "See New Posts"));
return /*#__PURE__*/_react.default.createElement(_styled.Row, null, activeCommunity ? /*#__PURE__*/_react.default.createElement(_styled.InlineLink, {
sx: {
lineHeight: 1
},
hu: 1,
c: 'black',
to: encodeURI("/".concat(communitySlug, "/").concat(sort))
}, /*#__PURE__*/_react.default.createElement(_styled.Header, {
sx: {
color: 'black',
lineHeight: 1,
fontSize: 1,
m: 0
}
}, "Community: ", activeCommunity === null || activeCommunity === void 0 ? void 0 : activeCommunity.name, ' ')) : null, view !== null && view !== void 0 && view.tag ? /*#__PURE__*/_react.default.createElement(_styled.InlineLink, {
sx: {
lineHeight: 1
},
lh: 1,
hu: 1,
to: encodeURI("/".concat(communitySlug, "/").concat(sort, "/").concat(view.tag))
}, /*#__PURE__*/_react.default.createElement(_styled.Header, {
sx: {
color: 'black',
lineHeight: 1,
fontSize: 1,
m: 0
}
}, "\xA0\u2192 #", view === null || view === void 0 ? void 0 : view.tag)) : null, newPostsNumber ? refreshPostsEl : null);
};
var _default = Breadcrumbs;
exports.default = _default;
//# sourceMappingURL=breadcrumbs.component.js.map