From 140a6408655f8f013f30ac5dcc0fe9445b8a523e Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Sun, 23 Oct 2022 14:38:29 -0700 Subject: [PATCH] remove unneeded logs --- src/client/webapp/elements/require/atoms-funcs.ts | 14 +------------- src/client/webapp/elements/require/atoms.ts | 12 +----------- src/client/webapp/elements/sections/guild.tsx | 1 - src/client/webapp/guild-combined.ts | 8 ++++---- 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/client/webapp/elements/require/atoms-funcs.ts b/src/client/webapp/elements/require/atoms-funcs.ts index ba5ed25..067ceef 100644 --- a/src/client/webapp/elements/require/atoms-funcs.ts +++ b/src/client/webapp/elements/require/atoms-funcs.ts @@ -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 extends (...args: infer A) => unknown ? A : never; @@ -47,23 +46,15 @@ export function createFetchValueFunc( ): 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); } diff --git a/src/client/webapp/elements/require/atoms.ts b/src/client/webapp/elements/require/atoms.ts index d08327a..a1dab46 100644 --- a/src/client/webapp/elements/require/atoms.ts +++ b/src/client/webapp/elements/require/atoms.ts @@ -57,7 +57,6 @@ import { multipleScrollingGuildSubscriptionEffect, useRecoilValueLoadableOrElse, } from './atoms-funcs'; -import { randomUUID } from 'crypto'; import assert from 'assert'; export const overlayState = atom({ @@ -89,10 +88,7 @@ export const guildMetaState = atomFamily, 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({ 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({ function createCurrentGuildStateGetter(subSelectorFamily: (guildId: number) => RecoilValueReadOnly) { 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(() => { diff --git a/src/client/webapp/elements/sections/guild.tsx b/src/client/webapp/elements/sections/guild.tsx index 9248852..3f2d7f0 100644 --- a/src/client/webapp/elements/sections/guild.tsx +++ b/src/client/webapp/elements/sections/guild.tsx @@ -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); diff --git a/src/client/webapp/guild-combined.ts b/src/client/webapp/guild-combined.ts index 33944bb..16a65fa 100644 --- a/src/client/webapp/guild-combined.ts +++ b/src/client/webapp/guild-combined.ts @@ -370,7 +370,7 @@ export default class CombinedGuild } async fetchMessagesRecent(channelId: string, number: number): Promise { // 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 { // 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 { 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 { // 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 {