databag/app/mobile/test/useTestStoreContext.hook.js
2023-02-03 13:31:41 -08:00

197 lines
6.0 KiB
JavaScript

import { useEffect, useState, useRef, useContext } from 'react';
import SQLite from "react-native-sqlite-storage";
export function useTestStoreContext() {
const [state, setState] = useState({});
const updateState = (value) => {
setState((s) => ({ ...s, ...value }))
}
const channelRevision = useRef(0);
const channels = useRef(new Map());
const initSession = async (guid) => {
}
const actions = {
init: async () => {
console.log("TEST STORE INIT");
return {};
},
setSession: async (access) => {
},
clearSession: async () => {
},
getProfile: async (guid) => {
return state.profile;
},
setProfile: async (guid, profile) => {
updateState({ profile });
},
getFirstRun: async (guid) => {
},
setFirstRun: async () => {
},
getCardRequestStatus: async (guid) => {
},
setCardRequestStatus: async (guid, status) => {
},
getProfileRevision: async (guid) => {
return state.profileRevision;
},
setProfileRevision: async (guid, revision) => {
updateState({ profileRevision: revision });
},
getAccountStatus: async (guid) => {
},
setAccountStatus: async (guid, status) => {
},
getAccountSealKey: async (guid) => {
},
setAccountSealKey: async (guid, key) => {
},
getAccountRevision: async (guid) => {
},
setAccountRevision: async (guid, revision) => {
},
getCardRevision: async (guid) => {
},
setCardRevision: async (guid, revision) => {
},
setCardItem: async (guid, card) => {
},
clearCardItem: async (guid, cardId) => {
},
setCardItemRevision: async (guid, cardId, revision) => {
},
setCardItemNotifiedView: async (guid, cardId, notified) => {
},
setCardItemNotifiedArticle: async (guid, cardId, notified) => {
},
setCardItemNotifiedProfile: async (guid, cardId, notified) => {
},
setCardItemNotifiedChannel: async (guid, cardId, notified) => {
},
setCardItemOffsync: async (guid, cardId) => {
},
clearCardItemOffsync: async (guid, cardId) => {
},
setCardItemBlocked: async (guid, cardId) => {
},
clearCardItemBlocked: async (guid, cardId) => {
},
setCardItemDetail: async (guid, cardId, revision, detail) => {
},
setCardItemProfile: async (guid, cardId, revision, profile) => {
},
getCardItemStatus: async (guid, cardId) => {
},
getCardItemView: async (guid, cardId) => {
},
getCardItems: async (guid) => {
},
getChannelRevision: async (guid) => {
return channelRevision.current;
},
setChannelRevision: async (guid, revision) => {
channelRevision.current = revision;
},
setChannelItem: async (guid, channel) => {
channels.current.set(channel.channelId, channel);
},
clearChannelItem: async (guid, channelId) => {
channels.current.delete(channelId);
},
setChannelItemRevision: async (guid, channelId, revision) => {
},
setChannelItemReadRevision: async (guid, channelId, revision) => {
},
setChannelItemSyncRevision: async (guid, channelId, revision) => {
},
setChannelItemTopicMarker: async (guid, channelId, marker) => {
},
setChannelItemBlocked: async (guid, channelId) => {
},
clearChannelItemBlocked: async (guid, channelId) => {
},
setChannelItemDetail: async (guid, channelId, revision, detail) => {
},
setChannelItemUnsealedDetail: async (guid, channelId, revision, unsealed) => {
},
setChannelItemSummary: async (guid, channelId, revision, summary) => {
},
setChannelItemUnsealedSummary: async (guid, channelId, revision, unsealed) => {
},
getChannelItemView: async (guid, channelId) => {
return channels.current.get(channelId);
},
getChannelItems: async (guid) => {
return Array.from(channels.current.values());
},
getChannelTopicItems: async (guid, channelId) => {
},
setChannelTopicItem: async (guid, channelId, topic) => {
},
setChannelTopicItemUnsealedDetail: async (guid, channelId, topicId, revision, unsealed) => {
},
clearChannelTopicItem: async (guid, channelId, topicId) => {
},
clearChannelTopicItems: async (guid, channelId) => {
},
setChannelTopicBlocked: async (guid, channelId, topicId, blocked) => {
},
getChannelTopicBlocked: async (guid) => {
},
setCardChannelItem: async (guid, cardId, channel) => {
},
clearCardChannelItem: async (guid, cardId, channelId) => {
},
setCardChannelItemRevision: async (guid, cardId, channelId, revision) => {
},
setCardChannelItemReadRevision: async (guid, cardId, channelId, revision) => {
},
setCardChannelItemSyncRevision: async (guid, cardId, channelId, revision) => {
},
setCardChannelItemTopicMarker: async (guid, cardId, channelId, marker) => {
},
setCardChannelItemDetail: async (guid, cardId, channelId, revision, detail) => {
},
setCardChannelItemUnsealedDetail: async (guid, cardId, channelId, revision, unsealed) => {
},
setCardChannelItemSummary: async (guid, cardId, channelId, revision, summary) => {
},
setCardChannelItemUnsealedSummary: async (guid, cardId, channelId, revision, unsealed) => {
},
getCardChannelItemView: async (guid, cardId, channelId) => {
},
getCardChannelItems: async (guid) => {
},
clearCardChannelItems: async (guid, cardId) => {
},
getCardChannelTopicItems: async (guid, cardId, channelId) => {
},
setCardChannelTopicItem: async (guid, cardId, channelId, topic) => {
},
setCardChannelTopicItemUnsealedDetail: async (guid, cardId, channelId, topicId, revision, unsealed) => {
},
clearCardChannelTopicItem: async (guid, cardId, channelId, topicId) => {
},
clearCardChannelTopicItems: async (guid, cardId, channelId) => {
},
setCardChannelTopicBlocked: async (guid, cardId, channelId, topicId, blocked) => {
},
getCardChannelTopicBlocked: async (guid) => {
},
}
return { state, actions }
}