Compare commits
No commits in common. "7eac4fc7599f14c26447593ec701be7b54aae734" and "b9722e1df23fab0bf79812afcf10c369aff03bcd" have entirely different histories.
7eac4fc759
...
b9722e1df2
|
|
@ -1,5 +1,4 @@
|
|||
.search-container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
padding-right: 10px;
|
||||
padding-left: 10px;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export default function ItemList({ isFetching, blacklistItems, showDialog }: { i
|
|||
<div className="list-container">
|
||||
<div className="item-list">
|
||||
{blacklistItems.map((item) => {
|
||||
return <Button onClick={() => showDialog(item)} variant="text">{width < 570 ? trimLink(item.link) : item.link} | {item.nicknames[item.nicknames.length - 1]}</Button>
|
||||
return <Button onClick={() => showDialog(item)} variant="text">{width < 570 ? trimLink(item.link) : item.link}</Button>
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {useEffect, useState} from "react";
|
||||
import '../assets/styles/home.css';
|
||||
import {
|
||||
Box, Button,
|
||||
Box,
|
||||
Divider, Fab,
|
||||
TextField,
|
||||
ThemeProvider, Typography,
|
||||
|
|
@ -15,20 +15,17 @@ import ItemList from "~/components/itemList";
|
|||
import ItemDialog from "~/components/itemDialog";
|
||||
import OutlinedFlagIcon from '@mui/icons-material/OutlinedFlag';
|
||||
import ReportDialog from "~/components/reportDialog";
|
||||
import LoopIcon from '@mui/icons-material/Loop';
|
||||
|
||||
export default function Home() {
|
||||
const outerTheme = useTheme();
|
||||
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const [isFetchingList, setIsFetchingList] = useState(false);
|
||||
const [totalBlacklistItems, setTotalBlacklistItems] = useState<BlacklistItem[]>([]);
|
||||
const [blacklistItems, setBlacklistItems] = useState<BlacklistItem[]>([]);
|
||||
const [showDialog, setShowDialog] = useState(false);
|
||||
const [currentDialogBlacklistItem, setCurrentDialogBlacklistItem] = useState<BlacklistItem|null>(null);
|
||||
const [fabIsHovered, setFabIsHovered] = useState(false);
|
||||
const [showReportDialog, setReportShowDialog] = useState(false);
|
||||
const [triggerUpdate, setTriggerUpdate] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
let isIgnore = false;
|
||||
|
|
@ -37,7 +34,6 @@ export default function Home() {
|
|||
if (!isIgnore) {
|
||||
if (res instanceof Array){
|
||||
setBlacklistItems(res);
|
||||
setTotalBlacklistItems(res);
|
||||
} else if (res instanceof ResponseError) {
|
||||
// TODO error handler
|
||||
console.log(res);
|
||||
|
|
@ -48,19 +44,7 @@ export default function Home() {
|
|||
return () => {
|
||||
isIgnore = true; // При следующем изменении someValue старый запрос будет проигнорирован
|
||||
};
|
||||
}, [triggerUpdate, showReportDialog]);
|
||||
|
||||
useEffect(() => {
|
||||
if (searchText !== ""){
|
||||
setIsFetchingList(true);
|
||||
let result = search(searchText);
|
||||
console.log(result);
|
||||
setBlacklistItems(result);
|
||||
setIsFetchingList(false);
|
||||
} else {
|
||||
setBlacklistItems(totalBlacklistItems);
|
||||
}
|
||||
}, [searchText]);
|
||||
}, [searchText, showReportDialog]);
|
||||
|
||||
function handleSearch(text: string) {
|
||||
setSearchText(text);
|
||||
|
|
@ -83,24 +67,6 @@ export default function Home() {
|
|||
setReportShowDialog(false);
|
||||
};
|
||||
|
||||
const sync = () => {
|
||||
setSearchText('');
|
||||
setTriggerUpdate(triggerUpdate + 1)
|
||||
};
|
||||
|
||||
const search = (searchString: string) => {
|
||||
searchString = searchString.toLowerCase();
|
||||
return totalBlacklistItems.filter((item) => {
|
||||
return item.link.toLowerCase().includes(searchString)
|
||||
|| item.nicknames.some((nickname) => {
|
||||
return nickname.toLowerCase().includes(searchString)
|
||||
})
|
||||
|| item.comments.some((comment) => {
|
||||
return comment.toLowerCase().includes(searchString)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={customTheme(outerTheme)}>
|
||||
<div className="bg-dark">
|
||||
|
|
@ -113,15 +79,6 @@ export default function Home() {
|
|||
onChange={(e) => handleSearch(e.target.value)}
|
||||
fullWidth
|
||||
/>
|
||||
<Button
|
||||
variant="outlined"
|
||||
sx={{ marginLeft: '10px' }}
|
||||
onClick={() => {
|
||||
sync();
|
||||
}}
|
||||
>
|
||||
<LoopIcon/>
|
||||
</Button>
|
||||
</div>
|
||||
<div style={{justifyItems: 'center'}}>
|
||||
<Divider sx={{marginTop: '10px', marginBottom: '10px'}}/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue