fix: eslint & fetching layout from user on login

This commit is contained in:
dan13ram
2022-01-09 16:32:04 +05:30
committed by Scott Stevenson
parent 053f4b3266
commit 1f7e5e9a81
7 changed files with 40 additions and 17 deletions

View File

@@ -27,8 +27,4 @@ const cpUpload = upload.fields([
{ name: 'image', maxCount: 1 },
{ name: 'background', maxCount: 1 },
]);
actionRoutes.post(
'/storage',
cpUpload,
web3StorageUpload,
);
actionRoutes.post('/storage', cpUpload, web3StorageUpload);

View File

@@ -12,9 +12,9 @@ export default async (req: Request, res: Response): Promise<Response> => {
const files = Object.entries(input).map(([key, [{ path }]]) => ({
name: key,
stream: () =>
fs.createReadStream(
(fs.createReadStream(
Path.isAbsolute(path) ? path : Path.join(process.cwd(), path),
) as any,
) as unknown) as ReadableStream,
}));
const cid = await storage.put(files);

View File

@@ -0,0 +1,10 @@
{
"overrides": [
{
"files": ["./src/**/*.{ts,tsx,js,jsx}", "./stories/**/*.{ts,tsx,js,jsx}"],
"rules": {
"no-console": "off"
}
}
]
}

View File

@@ -21,7 +21,8 @@ export const Listen: React.FC = () => {
const { data, error } = useSWR(podcastRSSURL, parse);
if (error) {
console.error(error);
// eslint-disable-next-line no-console
console.error('Podcast fetch error: ', error);
setLoading(false);
}

View File

@@ -29,9 +29,9 @@ export const Watch: React.FC = () => {
useEffect(() => {
const load = async () => {
const res = await fetch(URL).then((r) => r.json());
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const videosList = res.items
? res.items.map((video: any) => ({
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
res.items.map((video: any) => ({
id: video.id,
videoId: video.snippet.resourceId.videoId,
title: video.snippet.title,

View File

@@ -12,7 +12,7 @@ const Editor = dynamic<EditorProps>(
type Props = {
editorState: EditorState;
onEditorStateChange: any;
onEditorStateChange: (state: EditorState) => void;
};
export const WYSIWYGEditor: React.FC<Props> = ({

View File

@@ -148,22 +148,27 @@ type ProfileLayoutData = {
layouts: Layouts;
};
export const Grid: React.FC<Props> = ({ player }): ReactElement => {
export const Grid: React.FC<Props> = ({ player: initPlayer }): ReactElement => {
const [isOwnProfile, setIsOwnProfile] = useState(false);
const [, invalidateCache] = useInsertCacheInvalidationMutation();
const { user, fetching } = useUser();
const { connected } = useWeb3();
const [player, setPlayer] = useState(initPlayer);
useEffect(() => {
if (connected && !fetching && user?.id === player?.id) {
setIsOwnProfile(true);
if (!fetching && user?.player && user?.id === player?.id) {
setPlayer(user?.player);
if (connected) {
setIsOwnProfile(true);
}
}
}, [user, fetching, connected, player?.id]);
useEffect(() => {
if (player) {
if (player?.id) {
invalidateCache({ playerId: player.id });
}
}, [player, invalidateCache]);
}, [player?.id, invalidateCache]);
const toast = useToast();
@@ -173,7 +178,7 @@ export const Grid: React.FC<Props> = ({ player }): ReactElement => {
] = useUpdatePlayerProfileLayoutMutation();
const [saving, setSaving] = useState(false);
const layoutsFromDB = player.profile_layout
const layoutsFromDB = player?.profile_layout
? JSON.parse(player.profile_layout)
: null;
@@ -189,6 +194,17 @@ export const Grid: React.FC<Props> = ({ player }): ReactElement => {
setCurrentLayoutData,
] = useState<ProfileLayoutData>(savedLayoutData);
useEffect(() => {
const dbLayouts = player?.profile_layout
? JSON.parse(player.profile_layout)
: null;
if (dbLayouts) {
setSavedLayoutData(dbLayouts);
setCurrentLayoutData(dbLayouts);
setEditable(false);
}
}, [player?.profile_layout]);
const [changed, setChanged] = useState(false);
const [editable, setEditable] = useState(false);