Skip to content

Commit

Permalink
fix: issue with blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMarin committed Aug 30, 2024
1 parent f5ae200 commit 9fc0535
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/pages/RelaySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import useRelaySettings from '@app/hooks/useRelaySettings';
import * as S from '@app/pages/uiComponentsPages/UIComponentsPage.styles';
import { themeObject } from '@app/styles/themes/themeVariables';
import { categories, noteOptions, appBuckets, Settings, Category } from '@app/constants/relaySettings';
import { InfoCircleOutlined } from '@ant-design/icons';
const { Panel } = Collapse;
const StyledPanel = styled(Panel)``;
const { Option } = Select;
Expand All @@ -31,7 +30,6 @@ const RelaySettingsPage: React.FC = () => {
const dispatch = useAppDispatch();
const relaymode = useAppSelector((state) => state.mode.relayMode);


const [storedDynamicKinds, setStoredDynamicKinds] = useState<string[]>(
JSON.parse(localStorage.getItem('dynamicKinds') || '[]'),
);
Expand Down Expand Up @@ -76,6 +74,10 @@ const RelaySettingsPage: React.FC = () => {
notes: noteOptions.filter((note) => note.category === category.id),
}));

useEffect(() => {
console.log(settings);
console.log(blacklist)
}, [settings,blacklist]);
const enterLoading = (index: number) => {
setLoadings((loadings) => {
const newLoadings = [...loadings];
Expand All @@ -92,7 +94,6 @@ const RelaySettingsPage: React.FC = () => {
});
};


const photoFormatOptions = [
'jpeg',
'jpg',
Expand Down Expand Up @@ -225,13 +226,11 @@ const RelaySettingsPage: React.FC = () => {
const chunkSizeOptions = ['2', '4', '6', '8', '10', '12'];
const maxFileSizeUnitOptions = ['MB', 'GB', 'TB'];



const handleModeChange = (checked: boolean) => {
const newMode = checked ? 'smart' : 'unlimited';
updateSettings('mode', newMode);
dispatch(setMode(newMode));

console.log("changing mode")
if (newMode === 'unlimited') {
setBlacklist({
kinds: [],
Expand All @@ -252,8 +251,11 @@ const RelaySettingsPage: React.FC = () => {
};

const handleBlacklistChange = (category: Category, checkedValues: string[]) => {
const isDynamicKind = category === 'dynamicKinds' || 'appBuckets';
console.log("changing blacklist")
debugger
const isDynamicKind = category === 'dynamicKinds' || category === 'appBuckets';
if (isDynamicKind) {
console.log("changing dynamic kind")
setSettings((prevSettings) => {
const updatedSettings = { ...prevSettings, [category]: checkedValues };
updateSettings(category, checkedValues);
Expand All @@ -276,6 +278,7 @@ const RelaySettingsPage: React.FC = () => {
};

const handleSettingsChange = (category: Category, checkedValues: string[]) => {
console.log("changing settings", category, checkedValues)
if (settings.mode === 'unlimited') {
handleBlacklistChange(category, checkedValues);
} else {
Expand Down Expand Up @@ -364,8 +367,8 @@ const RelaySettingsPage: React.FC = () => {
updateSettings('chunked', settings.chunked),
updateSettings('maxFileSize', settings.maxFileSize),
updateSettings('maxFileSizeUnit', settings.maxFileSizeUnit),
updateSettings('appBuckets', settings.appBuckets),
updateSettings('dynamicAppBuckets', settings.dynamicAppBuckets),
// updateSettings('appBuckets', settings.appBuckets),
//updateSettings('dynamicAppBuckets', settings.dynamicAppBuckets),
]);

await saveSettings();
Expand Down Expand Up @@ -409,6 +412,8 @@ const RelaySettingsPage: React.FC = () => {
}, [relaySettings]);

useEffect(() => {
if(settings.mode === 'unlimited') return
console.log("resetting blacklist changing")
setBlacklist({
kinds: [],
photos: [],
Expand Down

0 comments on commit 9fc0535

Please sign in to comment.