Merge pull request '处理未登录状态下地址栏输入跳转消息页面情况' (#157) from durian/forgeplus-react:pre_develop_dev into pre_develop_dev

This commit is contained in:
baladiwei 2021-10-13 16:49:24 +08:00
commit 095e27fcc3
1 changed files with 15 additions and 5 deletions

View File

@ -9,10 +9,9 @@ import './Index.scss';
import '../manager/Index.scss'
function MyNotice(props) {
let current_user = props.current_user;
let resetUserInfo = props.resetUserInfo;
let { current_user, resetUserInfo, location, mygetHelmetapi, history}= props;
//tab
let popover = props.location.query && props.location.query.noticeType;
let popover = location && location.query && location.query.noticeType;
let pageSize = 15;
const [noticeType, setNoticeType] = useState(popover==="atme"?"2":"0");//tab
const [selectedNum, setSelectedNum] = useState(0);//@
@ -27,6 +26,17 @@ function MyNotice(props) {
const [currentPage, setCurrentPage] = useState(1);//
const [onlyUnread, setOnlyUnread] = useState();
//访/settings/profile
//访/explore
useEffect(()=>{
let notice_url = mygetHelmetapi && mygetHelmetapi.common && mygetHelmetapi.common.notice;
if(!current_user){
history.push(`/explore`);
}else if(!notice_url){
history.push(`/settings/profile`);
}
},[mygetHelmetapi])
useEffect(()=>{
popover==="atme" ? setNoticeType("2"):setNoticeType("0");
},[popover])
@ -46,7 +56,7 @@ function MyNotice(props) {
limit: pageSize,
page: currentPage,
};
axios.get(`/users/${current_user.login}/messages.json`, {
current_user && axios.get(`/users/${current_user.login}/messages.json`, {
params: params,
}).then((response) => {
if(response && response.data){
@ -59,7 +69,7 @@ function MyNotice(props) {
}
function readNotice(id){
if(id){
if(id && current_user){
const params = {
type: noticeType === "0" ? "notification" : noticeType === "2" ? "atme" : "",
ids:id,