remove unneeded logs

This commit is contained in:
Michael Peters 2022-10-23 14:38:29 -07:00
parent 85547116f9
commit 140a640865
4 changed files with 6 additions and 29 deletions

View File

@ -27,9 +27,8 @@ import {
LoadedScrollingEnd,
LoadedValueScrolling,
} from './loadables';
import { guildsManagerState, guildState } from './atoms';
import { guildState } from './atoms';
import { Changes } from '../../data-types';
import { randomUUID } from 'crypto';
// general typescript type that infers the arguments of a function
export type Arguments<T> = T extends (...args: infer A) => unknown ? A : never;
@ -47,23 +46,15 @@ export function createFetchValueFunc<T>(
): FetchValueFunc {
const { node, setSelf, getPromise } = atomEffectParam;
const fetchValueFunc = async () => {
const fvfId = randomUUID().slice(0, 4);
LOG.debug(`${fvfId} awaiting getPromise(guildState(${guildId}))`);
const guild = await getPromise(guildState(guildId));
LOG.debug(`${fvfId} got guild from gm for g#${guildId}: ${guild}`);
const guildsManager = await getPromise(guildsManagerState);
LOG.debug(`${fvfId} got gm - ${guildsManager?.guilds.length} guilds, ${guildsManager}`);
if (guild === null) return; // NOTE: This would only happen if this atom is created before its corresponding guild exists in the guildsManager
const selfState = await getPromise(node);
if (isPended(selfState)) return; // don't send another request if we're already loading
LOG.debug(`${fvfId} setting to pended`);
setSelf(DEF_PENDED_VALUE);
try {
LOG.debug(`${fvfId} fetchFunc before`);
const value = await fetchFunc(guild);
LOG.debug(`${fvfId} fetchFunc after`);
setSelf(createLoadedValue(value, fetchValueFunc));
} catch (e: unknown) {
setSelf(createFailedValue(e, fetchValueFunc));
@ -358,16 +349,13 @@ export function guildDataSubscriptionLoadableSingleEffect<
const { trigger } = atomEffectParam;
if (skipFunc && skipFunc()) return; // don't run if this atom should be skipped for some reason (e.g. null resourceId)
LOG.debug(`single effect for guild #${guildId}`);
const fetchValueFunc = createFetchValueFunc(atomEffectParam, guildId, fetchFunc);
// fetch initial value on first get
if (trigger === 'get') {
(async () => {
try {
LOG.debug('awaiting fetchValueFunc Single');
await fetchValueFunc();
LOG.debug('done fetchValueFunc Single');
} catch (e: unknown) {
LOG.error('error fetching initial value', e);
}

View File

@ -57,7 +57,6 @@ import {
multipleScrollingGuildSubscriptionEffect,
useRecoilValueLoadableOrElse,
} from './atoms-funcs';
import { randomUUID } from 'crypto';
import assert from 'assert';
export const overlayState = atom<ReactNode>({
@ -89,10 +88,7 @@ export const guildMetaState = atomFamily<LoadableValue<GuildMetadata>, number>({
effects_UNSTABLE: (guildId: number) => [
guildDataSubscriptionLoadableSingleEffect(
guildId,
async (guild: CombinedGuild) => {
LOG.debug('fetching guild metadata');
return await guild.fetchMetadata();
},
async (guild: CombinedGuild) => await guild.fetchMetadata(),
{
updatedEvent: {
name: 'update-metadata',
@ -384,13 +380,9 @@ export const guildState = selectorFamily<CombinedGuild | null, number>({
get:
(guildId: number) =>
({ get }) => {
const id = randomUUID().slice(0, 4);
LOG.debug(`${id} - use guildState g#${guildId}`)
const guildsManager = get(guildsManagerState);
LOG.debug(`${id} - gm - ${guildsManager ? guildsManager.guilds.length + ' guilds' : guildsManager} - [${guildsManager?.guilds.map(guild => guild.id) ?? ''}]`);
if (guildsManager === null) return null;
const guild = guildsManager.guilds.find(guild => guild.id === guildId) ?? null;
LOG.debug(`${id} - gm guild member: m#${guild?.memberId}`);
return guild;
},
dangerouslyAllowMutability: true,
@ -404,7 +396,6 @@ export const currGuildIdState = atom<number | null>({
function createCurrentGuildStateGetter<T>(subSelectorFamily: (guildId: number) => RecoilValueReadOnly<T>) {
return ({ get }: { get: GetRecoilValue }) => {
const currGuildId = get(currGuildIdState);
LOG.debug(`current guild id is ${currGuildId} - guild state getter`);
if (currGuildId === null) return null;
const value = get(subSelectorFamily(currGuildId));
@ -554,7 +545,6 @@ export function useInitRecoil() {
const guildsManager = useRecoilValue(guildsManagerState);
assert(guildsManager !== null);
LOG.debug(`recoil init, gm has ${guildsManager.guilds.length} guilds`);
const setGuilds = useSetRecoilState(allGuildsState);
const [currGuildId, setCurrGuildId] = useRecoilState(currGuildIdState);
useEffect(() => {

View File

@ -21,7 +21,6 @@ const GuildElement: FC = () => {
// TODO: Handle fetch errors in message list
// TODO: React set hasMessagesAbove and hasMessagesBelow when re-verified?
LOG.debug('grabbing recoil values for current guild');
const guild = useRecoilValue(currGuildState);
const selfMember = useRecoilValue(currGuildSelfMemberState);
const channels = useRecoilValue(currGuildChannelsState);

View File

@ -370,7 +370,7 @@ export default class CombinedGuild
}
async fetchMessagesRecent(channelId: string, number: number): Promise<Message[]> {
// xUtil.failSometimes(0.05); // for testing
LOG.debug(`g#${this.id}: fetch recent messages`);
LOG.debug(`g#${this.id}: fetch recent messages ch#${channelId.slice(0, 4)}, ${number}`);
const members = await this.grabRAMMembersMap();
const channels = await this.grabRAMChannelsMap();
const messages = await this.fetchable.fetchMessagesRecent(channelId, number);
@ -381,7 +381,7 @@ export default class CombinedGuild
}
async fetchMessagesBefore(channelId: string, messageOrderId: string, number: number): Promise<Message[]> {
// xUtil.failSometimes(0.05); // for testing
LOG.debug(`g#${this.id}: fetch messages before`);
LOG.debug(`g#${this.id}: fetch messages before ch#${channelId.slice(0, 4)}, mo#${messageOrderId}, ${number}`);
const members = await this.grabRAMMembersMap();
const channels = await this.grabRAMChannelsMap();
const messages = await this.fetchable.fetchMessagesBefore(channelId, messageOrderId, number);
@ -392,7 +392,7 @@ export default class CombinedGuild
}
async fetchMessagesAfter(channelId: string, messageOrderId: string, number: number): Promise<Message[]> {
Util.failSometimes(0.75); // for testing
LOG.debug(`g#${this.id}: fetch messages after`);
LOG.debug(`g#${this.id}: fetch messages after ch#${channelId.slice(0, 4)}, mo#${messageOrderId}, ${number}`);
const members = await this.grabRAMMembersMap();
const channels = await this.grabRAMChannelsMap();
const messages = await this.fetchable.fetchMessagesAfter(channelId, messageOrderId, number);
@ -403,7 +403,7 @@ export default class CombinedGuild
}
async fetchResource(resourceId: string): Promise<Resource> {
// xUtil.failSometimes(0.05); // for testing
LOG.debug(`g#${this.id}: fetch resource`);
LOG.debug(`g#${this.id}: fetch resource r#${resourceId.slice(0, 4)}`);
return await this.fetchable.fetchResource(resourceId);
}
async fetchTokens(): Promise<Token[]> {