更新消息中心时间显示

This commit is contained in:
al 2025-01-16 15:50:25 +08:00
parent 5bcc93de87
commit e7b05ed3c2
2 changed files with 22 additions and 8 deletions

View File

@ -9,7 +9,9 @@ import React, {
useEffect,
forwardRef,
useImperativeHandle,
useCallback,
} from "react";
import { Day } from "react-native-gifted-chat";
import { useTailwind } from "tailwind-rn";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import baseRequest from "../../../../utils/baseRequest";
@ -20,6 +22,7 @@ import { getNoticeCount } from "../../../../store/reducer";
import requireAPI from "../../../../utils/requireAPI";
import { Image } from "expo-image";
import { connect } from "react-redux";
import dayjs from "dayjs";
const MessageList = ({ navigation, noticeCount, refInstance }) => {
const dispatch = useDispatch();
const [data, setData] = useState([]);
@ -139,7 +142,7 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
newInfoItems[parseInt(it)]["count"] = noticeObj[it].unread_cnt;
if (noticeObj[it]["most_recent_notif"]) {
const time = noticeObj[it]["most_recent_notif"]["push_time"];
newInfoItems[parseInt(it)]["time"] = formatDate(
newInfoItems[parseInt(it)]["time"] = renderDay(
time ? time : noticeObj[it]["most_recent_notif"]["ct"]
);
newInfoItems[parseInt(it)]["subtitle"] =
@ -178,6 +181,17 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
console.error(error);
}
};
//
const renderDay = (time) => {
const now = dayjs();
if (now.diff(dayjs(time * 1000), "hour") - now.hour() < 1) {
return dayjs(time * 1000).format("HH:mm");
} else if (now.diff(dayjs(time * 1000), "hour") - now.hour() < 24) {
return "昨天" + dayjs(time * 1000).format("HH:mm");
} else {
return dayjs(time * 1000).format("MM-DD");
}
};
const renderSystemItem = (
{ title, subtitle, time, count, icon },
index,
@ -231,7 +245,7 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
>
<Badge
status="error"
value={count > 99 ? "+99" : count}
value={count > 99 ? "99+" : count}
// containerStyle={{ position: "absolute", top: 0, right: 40 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
@ -332,7 +346,7 @@ const MessageList = ({ navigation, noticeCount, refInstance }) => {
<Badge
status="error"
value={
data.contact_cs_urc > 99 ? "+99" : data.contact_cs_urc
data.contact_cs_urc > 99 ? "99+" : data.contact_cs_urc
}
// containerStyle={{ position: "absolute", top: 0, right: 40 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}

View File

@ -348,11 +348,11 @@ export default function SpacePaymentSetting({ navigation, route }) {
});
return;
}
Toast.show({
icon: "success",
content: "修改成功,请重进空间刷新查看",
position: "top",
});
// Toast.show({
// icon: "success",
// content: "",
// position: "top",
// });
navigation.goBack();
} catch (error) {
console.error(error);