added kind 6 to newsfeed and changed useMetadata to useProfileMetadata

This commit is contained in:
Ren Amamiya
2023-04-16 16:43:17 +07:00
parent a7e95fd18a
commit 3aeb70f234
19 changed files with 297 additions and 83 deletions

View File

@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
const getOnLineStatus = () =>
typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean' ? navigator.onLine : true;
export const useNavigatorOnLine = () => {
export const useNetworkStatus = () => {
const [status, setStatus] = useState(getOnLineStatus());
const setOnline = () => setStatus(true);

View File

@@ -2,7 +2,7 @@ import useLocalStorage from '@rehooks/local-storage';
import { fetch } from '@tauri-apps/api/http';
import { useCallback, useEffect, useMemo, useState } from 'react';
export const fetchMetadata = async (pubkey: string) => {
export const fetchProfileMetadata = async (pubkey: string) => {
const result = await fetch(`https://rbr.bio/${pubkey}/metadata.json`, {
method: 'GET',
timeout: 5,
@@ -10,7 +10,7 @@ export const fetchMetadata = async (pubkey: string) => {
return await result.data;
};
export const useMetadata = (pubkey) => {
export const useProfileMetadata = (pubkey) => {
const [activeAccount]: any = useLocalStorage('activeAccount', {});
const [plebs] = useLocalStorage('activeAccountFollows', []);
const [profile, setProfile] = useState(null);
@@ -47,7 +47,7 @@ export const useMetadata = (pubkey) => {
useEffect(() => {
if (!cacheProfile) {
fetchMetadata(pubkey)
fetchProfileMetadata(pubkey)
.then((res: any) => {
// update state
setProfile(JSON.parse(res.content));