Skip to content

Commit

Permalink
TW-1127 Import fixes from #1008
Browse files Browse the repository at this point in the history
  • Loading branch information
keshan3262 committed Oct 27, 2023
1 parent 01ec465 commit b7f4339
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/app/pages/Home/OtherComponents/Tokens/AcceptAdsBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { FC, useCallback, useMemo } from 'react';
import { useDispatch } from 'react-redux';

import { Banner, BannerButtonProps } from 'app/atoms/Banner';
import { useUserAnalyticsAndAdsSettings } from 'app/hooks/use-user-analytics-and-ads-settings.hook';
import { togglePartnersPromotionAction } from 'app/store/partners-promotion/actions';
import { setAdsBannerVisibilityAction } from 'app/store/settings/actions';
import { T } from 'lib/i18n';
Expand All @@ -14,7 +13,6 @@ import { AssetsSelectors } from '../Assets.selectors';
export const AcceptAdsBanner: FC = () => {
const dispatch = useDispatch();

useUserAnalyticsAndAdsSettings();
const onEnableButtonClick = useCallback(() => {
dispatch(togglePartnersPromotionAction(true));
dispatch(setAdsBannerVisibilityAction(false));
Expand Down
19 changes: 9 additions & 10 deletions src/lib/temple/front/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ export function usePassiveStorage<T = any>(key: string, fallback?: T) {
setValue(finalData);
}, [finalData]);

const prevValue = useRef(value);

useEffect(() => {
if (prevValue.current !== value && value !== undefined) {
putToStorage(key, value);
}

prevValue.current = value;
}, [key, value]);
const updateValue = useCallback(
(newValue: T | null | undefined) => {
const newValueWithFallback = fallback === undefined ? newValue : newValue ?? fallback;
putToStorage(key, newValueWithFallback);
setValue(newValueWithFallback);
},
[fallback, key]
);

return [value, setValue];
return [value, updateValue];
}

function onStorageChanged<T = any>(key: string, callback: (newValue: T) => void) {
Expand Down

0 comments on commit b7f4339

Please sign in to comment.