diff --git a/net/web/src/App.js b/net/web/src/App.js index e00267b0..1f381e84 100644 --- a/net/web/src/App.js +++ b/net/web/src/App.js @@ -26,36 +26,32 @@ function App() { - - - - - - - - - - - } /> - } /> - } /> - } /> - - - - }> - - - - - - - - - - - + + + + + + + + + } /> + } /> + } /> + } /> + + + + }> + + + + + + + + + diff --git a/net/web/src/context/ArticleContext.js b/net/web/src/context/ArticleContext.js deleted file mode 100644 index 8c9916b3..00000000 --- a/net/web/src/context/ArticleContext.js +++ /dev/null @@ -1,14 +0,0 @@ -import { createContext } from 'react'; -import { useArticleContext } from './useArticleContext.hook'; - -export const ArticleContext = createContext({}); - -export function ArticleContextProvider({ children }) { - const { state, actions } = useArticleContext(); - return ( - - {children} - - ); -} - diff --git a/net/web/src/context/GroupContext.js b/net/web/src/context/GroupContext.js deleted file mode 100644 index 365db76a..00000000 --- a/net/web/src/context/GroupContext.js +++ /dev/null @@ -1,14 +0,0 @@ -import { createContext } from 'react'; -import { useGroupContext } from './useGroupContext.hook'; - -export const GroupContext = createContext({}); - -export function GroupContextProvider({ children }) { - const { state, actions } = useGroupContext(); - return ( - - {children} - - ); -} - diff --git a/net/web/src/context/useAppContext.hook.js b/net/web/src/context/useAppContext.hook.js index 5d988c4c..df6e8733 100644 --- a/net/web/src/context/useAppContext.hook.js +++ b/net/web/src/context/useAppContext.hook.js @@ -7,8 +7,6 @@ import { addAccount } from 'api/addAccount'; import { getUsername } from 'api/getUsername'; import { AccountContext } from './AccountContext'; import { ProfileContext } from './ProfileContext'; -import { ArticleContext } from './ArticleContext'; -import { GroupContext } from './GroupContext'; import { CardContext } from './CardContext'; import { ChannelContext } from './ChannelContext'; import { StoreContext } from './StoreContext'; @@ -36,15 +34,11 @@ export function useAppContext() { const profileContext = useContext(ProfileContext); const channelContext = useContext(ChannelContext); const cardContext = useContext(CardContext); - const groupContext = useContext(GroupContext); - const articleContext = useContext(ArticleContext); const resetData = () => { revision.current = null; accountContext.actions.clearToken(); profileContext.actions.clearToken(); - articleContext.actions.clearToken(); - groupContext.actions.clearToken(); cardContext.actions.clearToken(); channelContext.actions.clearToken(); setState({}); @@ -123,8 +117,6 @@ export function useAppContext() { if (appRevision) { accountContext.actions.setRevision(appRevision.account); profileContext.actions.setRevision(appRevision.profile); - articleContext.actions.setRevision(appRevision.article); - groupContext.actions.setRevision(appRevision.group); cardContext.actions.setRevision(appRevision.card); channelContext.actions.setRevision(appRevision.channel); } @@ -135,8 +127,6 @@ export function useAppContext() { accountContext.actions.setToken(token); profileContext.actions.setToken(token); - articleContext.actions.setToken(token); - groupContext.actions.setToken(token); cardContext.actions.setToken(token); channelContext.actions.setToken(token); diff --git a/net/web/src/context/useArticleContext.hook.js b/net/web/src/context/useArticleContext.hook.js deleted file mode 100644 index 86801f3d..00000000 --- a/net/web/src/context/useArticleContext.hook.js +++ /dev/null @@ -1,31 +0,0 @@ -import { useEffect, useState } from 'react'; - -export function useArticleContext() { - const [state, setState] = useState({ - token: null, - revision: 0, - }); - - useEffect(() => { - }, []); - - const updateState = (value) => { - setState((s) => ({ ...s, ...value })) - } - - const actions = { - setToken: (token) => { - updateState({ token }); - }, - clearToken: () => { - setState({ init: false }); - }, - setRevision: async (revision) => { - updateState({ revision }); - }, - } - - return { state, actions } -} - - diff --git a/net/web/src/context/useGroupContext.hook.js b/net/web/src/context/useGroupContext.hook.js deleted file mode 100644 index 1a9d9b09..00000000 --- a/net/web/src/context/useGroupContext.hook.js +++ /dev/null @@ -1,63 +0,0 @@ -import { useState, useRef } from 'react'; -import { getGroups } from 'api/getGroups'; - -export function useGroupContext() { - const [state, setState] = useState({ - init: false, - groups: new Map(), - }); - const access = useRef(null); - const revision = useRef(null); - const groups = useRef(new Map()); - const next = useRef(null); - - const updateState = (value) => { - setState((s) => ({ ...s, ...value })) - } - - const updateGroups = async () => { - let delta = await getGroups(access.current, revision.current); - for (let group of delta) { - if (group.data) { - groups.current.set(group.id, group); - } - else { - groups.current.delete(group.id); - } - } - } - - const setGroups = async (rev) => { - if (next.current == null) { - if (revision.current !== rev) { - await updateGroups(); - updateState({ init: true, groups: groups.current }); - revision.current = rev; - } - if (next.current != null) { - let r = next.current; - next.current = null; - setGroups(r); - } - } - else { - next.current = rev; - } - } - - const actions = { - setToken: (token) => { - access.current = token; - }, - clearToken: () => { - access.current = null; - setState({ init: false }); - }, - setRevision: async (rev) => { - setGroups(rev); - }, - } - - return { state, actions } -} -