Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
erich2s committed Oct 31, 2023
1 parent 2e9e91c commit 63012bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/components/admin/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
let isFirstLoad = true;
let count = 0;

export default function Map() {
console.log("渲染map次数:", count++);
const mapRef = useRef<HTMLDivElement>(null);
// NOTE:窗口大小从父组件传下来的时候,会有延迟,导致地图高度计算错误从而有离奇的bug,所以需要在子组件中获取窗口大小
const { width, height } = useWindowSize();
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useUncompletedReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ export default function useUncompletedReports() {
) => {
const { location, status } = report;
const index = acc.findIndex((l) => l.id === location.id);
// 对于已经存在acc里的地点,
// 如果是PENDING,pendingCount+1,
// 如果是ACCEPTED,acceptedCount+1
if (index !== -1) {
if (status === "PENDING") {
acc[index].pendingCount++;
} else if (status === "ACCEPTED") {
acc[index].acceptedCount++;
}
} else {
// 对于不存在的地点,新建一个地点对象
acc.push({
id: location.id,
name: location.name,
Expand Down

0 comments on commit 63012bc

Please sign in to comment.