minor fixes

This commit is contained in:
Ren Amamiya
2023-04-24 18:31:44 +07:00
parent f0d0e79e3d
commit 1486d1bc09
9 changed files with 71 additions and 70 deletions

View File

@@ -6,9 +6,18 @@ import { updateChannelMetadata } from '@utils/storage';
import { useCallback, useContext, useEffect, useState } from 'react';
export const useChannelMetadata = (id: string, fallback: string) => {
export const useChannelMetadata = (id: string, fallback: any) => {
let parseFallback: any;
if (typeof fallback === 'object') {
parseFallback = fallback.metadata;
} else {
const json = JSON.parse(fallback.metadata);
parseFallback = json;
}
const pool: any = useContext(RelayContext);
const [metadata, setMetadata] = useState(fallback);
const [metadata, setMetadata] = useState(parseFallback);
const fetchMetadata = useCallback(() => {
const unsubscribe = pool.subscribe(