bumped back react version, got rid of ensureVerified, it runs again!
This commit is contained in:
parent
a6a512617c
commit
4b15aad6cd
78
package-lock.json
generated
78
package-lock.json
generated
@ -21,9 +21,10 @@
|
|||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"nyc-dark": "^3.0.3",
|
"nyc-dark": "^3.0.3",
|
||||||
"pg": "^8.7.1",
|
"pg": "^8.7.1",
|
||||||
"react": "^18.2.0",
|
"react": "^17.0.2",
|
||||||
"react-contenteditable": "^3.3.6",
|
"react-contenteditable": "^3.3.6",
|
||||||
"recoil": "^0.7.5",
|
"react-dom": "^17.0.2",
|
||||||
|
"recoil": "^0.5.2",
|
||||||
"sass": "^1.43.4",
|
"sass": "^1.43.4",
|
||||||
"sharp": "^0.31.1",
|
"sharp": "^0.31.1",
|
||||||
"socket.io": "^4.3.1",
|
"socket.io": "^4.3.1",
|
||||||
@ -48,7 +49,6 @@
|
|||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
"eslint-plugin-unused-imports": "^2.0.0",
|
||||||
"jest": "^29.1.2",
|
"jest": "^29.1.2",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"react-dom": "^18.2.0",
|
|
||||||
"ts-jest": "^29.0.3",
|
"ts-jest": "^29.0.3",
|
||||||
"typescript": "^4.4.4"
|
"typescript": "^4.4.4"
|
||||||
}
|
}
|
||||||
@ -6461,11 +6461,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react": {
|
"node_modules/react": {
|
||||||
"version": "18.2.0",
|
"version": "17.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
|
||||||
"integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
|
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"loose-envify": "^1.1.0"
|
"loose-envify": "^1.1.0",
|
||||||
|
"object-assign": "^4.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
@ -6484,16 +6485,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-dom": {
|
"node_modules/react-dom": {
|
||||||
"version": "18.2.0",
|
"version": "17.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
|
||||||
"integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
|
"integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"loose-envify": "^1.1.0",
|
"loose-envify": "^1.1.0",
|
||||||
"scheduler": "^0.23.0"
|
"object-assign": "^4.1.1",
|
||||||
|
"scheduler": "^0.20.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^18.2.0"
|
"react": "17.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-is": {
|
"node_modules/react-is": {
|
||||||
@ -6542,9 +6543,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/recoil": {
|
"node_modules/recoil": {
|
||||||
"version": "0.7.5",
|
"version": "0.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/recoil/-/recoil-0.7.5.tgz",
|
"resolved": "https://registry.npmjs.org/recoil/-/recoil-0.5.2.tgz",
|
||||||
"integrity": "sha512-GVShsj5+M/2GULWBs5WBJGcsNis/d3YvDiaKjYh3mLKXftjtmk9kfaQ8jwjoIXySCwn8/RhgJ4Sshwgzj2UpFA==",
|
"integrity": "sha512-Edibzpu3dbUMLy6QRg73WL8dvMl9Xqhp+kU+f2sJtXxsaXvAlxU/GcnDE8HXPkprXrhHF2e6SZozptNvjNF5fw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hamt_plus": "1.0.2"
|
"hamt_plus": "1.0.2"
|
||||||
},
|
},
|
||||||
@ -6773,12 +6774,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/scheduler": {
|
"node_modules/scheduler": {
|
||||||
"version": "0.23.0",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
|
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz",
|
||||||
"integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
|
"integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"loose-envify": "^1.1.0"
|
"loose-envify": "^1.1.0",
|
||||||
|
"object-assign": "^4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
@ -12771,11 +12772,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react": {
|
"react": {
|
||||||
"version": "18.2.0",
|
"version": "17.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
|
||||||
"integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
|
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"loose-envify": "^1.1.0"
|
"loose-envify": "^1.1.0",
|
||||||
|
"object-assign": "^4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-contenteditable": {
|
"react-contenteditable": {
|
||||||
@ -12788,13 +12790,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-dom": {
|
"react-dom": {
|
||||||
"version": "18.2.0",
|
"version": "17.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
|
||||||
"integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
|
"integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"loose-envify": "^1.1.0",
|
"loose-envify": "^1.1.0",
|
||||||
"scheduler": "^0.23.0"
|
"object-assign": "^4.1.1",
|
||||||
|
"scheduler": "^0.20.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-is": {
|
"react-is": {
|
||||||
@ -12830,9 +12832,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"recoil": {
|
"recoil": {
|
||||||
"version": "0.7.5",
|
"version": "0.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/recoil/-/recoil-0.7.5.tgz",
|
"resolved": "https://registry.npmjs.org/recoil/-/recoil-0.5.2.tgz",
|
||||||
"integrity": "sha512-GVShsj5+M/2GULWBs5WBJGcsNis/d3YvDiaKjYh3mLKXftjtmk9kfaQ8jwjoIXySCwn8/RhgJ4Sshwgzj2UpFA==",
|
"integrity": "sha512-Edibzpu3dbUMLy6QRg73WL8dvMl9Xqhp+kU+f2sJtXxsaXvAlxU/GcnDE8HXPkprXrhHF2e6SZozptNvjNF5fw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"hamt_plus": "1.0.2"
|
"hamt_plus": "1.0.2"
|
||||||
}
|
}
|
||||||
@ -12980,12 +12982,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scheduler": {
|
"scheduler": {
|
||||||
"version": "0.23.0",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
|
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz",
|
||||||
"integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
|
"integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"loose-envify": "^1.1.0"
|
"loose-envify": "^1.1.0",
|
||||||
|
"object-assign": "^4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"nyc-dark": "^3.0.3",
|
"nyc-dark": "^3.0.3",
|
||||||
"pg": "^8.7.1",
|
"pg": "^8.7.1",
|
||||||
"react": "^18.2.0",
|
"react": "^17.0.2",
|
||||||
"react-contenteditable": "^3.3.6",
|
"react-contenteditable": "^3.3.6",
|
||||||
"recoil": "^0.7.5",
|
"react-dom": "^17.0.2",
|
||||||
|
"recoil": "^0.5.2",
|
||||||
"sass": "^1.43.4",
|
"sass": "^1.43.4",
|
||||||
"sharp": "^0.31.1",
|
"sharp": "^0.31.1",
|
||||||
"socket.io": "^4.3.1",
|
"socket.io": "^4.3.1",
|
||||||
@ -45,7 +46,6 @@
|
|||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
"eslint-plugin-unused-imports": "^2.0.0",
|
||||||
"jest": "^29.1.2",
|
"jest": "^29.1.2",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"react-dom": "^18.2.0",
|
|
||||||
"ts-jest": "^29.0.3",
|
"ts-jest": "^29.0.3",
|
||||||
"typescript": "^4.4.4"
|
"typescript": "^4.4.4"
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,12 @@ export class AutoVerifierWithArg<T, K> {
|
|||||||
private tokenizer: (query: K) => string, // must be one-to-one mapping
|
private tokenizer: (query: K) => string, // must be one-to-one mapping
|
||||||
private primaryFunc: (query: K) => Promise<T | null>,
|
private primaryFunc: (query: K) => Promise<T | null>,
|
||||||
private trustedFunc: (query: K) => Promise<T | null>,
|
private trustedFunc: (query: K) => Promise<T | null>,
|
||||||
private ensureTrustedFuncReady: () => Promise<void>,
|
|
||||||
private verifyFunc: (query: K, primaryResult: T | null, trustedResult: T | null) => Promise<boolean>,
|
private verifyFunc: (query: K, primaryResult: T | null, trustedResult: T | null) => Promise<boolean>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
static createStandardPartialMessageListAutoVerifier<T extends WithEquals<T> & { id: string }>(
|
static createStandardPartialMessageListAutoVerifier<T extends WithEquals<T> & { id: string }>(
|
||||||
primaryFunc: (query: PartialMessageListQuery) => Promise<T[] | null>,
|
primaryFunc: (query: PartialMessageListQuery) => Promise<T[] | null>,
|
||||||
trustedFunc: (query: PartialMessageListQuery) => Promise<T[] | null>,
|
trustedFunc: (query: PartialMessageListQuery) => Promise<T[] | null>,
|
||||||
ensureTrustedFuncReady: () => Promise<void>,
|
|
||||||
changesFunc: (
|
changesFunc: (
|
||||||
query: PartialMessageListQuery,
|
query: PartialMessageListQuery,
|
||||||
changesType: AutoVerifierChangesType,
|
changesType: AutoVerifierChangesType,
|
||||||
@ -44,7 +42,6 @@ export class AutoVerifierWithArg<T, K> {
|
|||||||
query => `ch#${query.channelId} mo#${query.messageOrderId}->${query.number}`,
|
query => `ch#${query.channelId} mo#${query.messageOrderId}->${query.number}`,
|
||||||
query => primaryFunc(query),
|
query => primaryFunc(query),
|
||||||
query => trustedFunc(query),
|
query => trustedFunc(query),
|
||||||
ensureTrustedFuncReady,
|
|
||||||
async (query: PartialMessageListQuery, primaryResult: T[] | null, trustedResult: T[] | null) => {
|
async (query: PartialMessageListQuery, primaryResult: T[] | null, trustedResult: T[] | null) => {
|
||||||
// lOG.debug('messages verify: ', {
|
// lOG.debug('messages verify: ', {
|
||||||
// query,
|
// query,
|
||||||
@ -66,7 +63,6 @@ export class AutoVerifierWithArg<T, K> {
|
|||||||
static createStandardIDQueriedSingleAutoVerifier<T extends WithEquals<T> & { id: string }>(
|
static createStandardIDQueriedSingleAutoVerifier<T extends WithEquals<T> & { id: string }>(
|
||||||
primaryFunc: (query: IDQuery) => Promise<T | null>,
|
primaryFunc: (query: IDQuery) => Promise<T | null>,
|
||||||
trustedFunc: (query: IDQuery) => Promise<T | null>,
|
trustedFunc: (query: IDQuery) => Promise<T | null>,
|
||||||
ensureTrustedFuncReady: () => Promise<void>,
|
|
||||||
changesFunc: (
|
changesFunc: (
|
||||||
query: IDQuery,
|
query: IDQuery,
|
||||||
changesType: AutoVerifierChangesType,
|
changesType: AutoVerifierChangesType,
|
||||||
@ -78,7 +74,6 @@ export class AutoVerifierWithArg<T, K> {
|
|||||||
query => `id#${query.id}`,
|
query => `id#${query.id}`,
|
||||||
query => primaryFunc(query),
|
query => primaryFunc(query),
|
||||||
query => trustedFunc(query),
|
query => trustedFunc(query),
|
||||||
ensureTrustedFuncReady,
|
|
||||||
async (query: IDQuery, primaryResult: T | null, trustedResult: T | null) => {
|
async (query: IDQuery, primaryResult: T | null, trustedResult: T | null) => {
|
||||||
const changesType = AutoVerifier.getSingleChangesType<T>(primaryResult, trustedResult);
|
const changesType = AutoVerifier.getSingleChangesType<T>(primaryResult, trustedResult);
|
||||||
return await changesFunc(query, changesType, primaryResult, trustedResult);
|
return await changesFunc(query, changesType, primaryResult, trustedResult);
|
||||||
@ -120,7 +115,6 @@ export class AutoVerifierWithArg<T, K> {
|
|||||||
autoVerifier = new AutoVerifier<T>(
|
autoVerifier = new AutoVerifier<T>(
|
||||||
async () => await this.primaryFunc(query),
|
async () => await this.primaryFunc(query),
|
||||||
async () => await this.trustedFunc(query),
|
async () => await this.trustedFunc(query),
|
||||||
this.ensureTrustedFuncReady,
|
|
||||||
async (primaryResult: T | null, trustedResult: T | null) =>
|
async (primaryResult: T | null, trustedResult: T | null) =>
|
||||||
await this.verifyFunc(query, primaryResult, trustedResult),
|
await this.verifyFunc(query, primaryResult, trustedResult),
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
import * as electronRemote from '@electron/remote';
|
||||||
|
const electronConsole = electronRemote.getGlobal('console') as Console;
|
||||||
|
import Logger from '../../../../../logger/logger';
|
||||||
|
const LOG = Logger.create(__filename, electronConsole);
|
||||||
|
|
||||||
import React, { FC, useCallback, useMemo, useRef } from 'react';
|
import React, { FC, useCallback, useMemo, useRef } from 'react';
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||||
import CombinedGuild from '../../../guild-combined';
|
import CombinedGuild from '../../../guild-combined';
|
||||||
@ -18,6 +23,10 @@ const GuildListElement: FC<GuildListElementProps> = (props: GuildListElementProp
|
|||||||
|
|
||||||
const rootRef = useRef<HTMLDivElement>(null);
|
const rootRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useMemo(() => {
|
||||||
|
LOG.debug(`list element guild id: ${guild.id}`)
|
||||||
|
}, [ guild.id ]);
|
||||||
|
|
||||||
const guildsManager = useRecoilValue(guildsManagerState);
|
const guildsManager = useRecoilValue(guildsManagerState);
|
||||||
const [currGuildId, setCurrGuildId] = useRecoilState(currGuildIdState);
|
const [currGuildId, setCurrGuildId] = useRecoilState(currGuildIdState);
|
||||||
const guildMeta = useRecoilValue(guildMetaState(guild.id));
|
const guildMeta = useRecoilValue(guildMetaState(guild.id));
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
} from './loadables';
|
} from './loadables';
|
||||||
import { guildState } from './atoms';
|
import { guildState } from './atoms';
|
||||||
import { Changes } from '../../data-types';
|
import { Changes } from '../../data-types';
|
||||||
|
import { randomUUID } from 'crypto';
|
||||||
|
|
||||||
// general typescript type that infers the arguments of a function
|
// general typescript type that infers the arguments of a function
|
||||||
export type Arguments<T> = T extends (...args: infer A) => unknown ? A : never;
|
export type Arguments<T> = T extends (...args: infer A) => unknown ? A : never;
|
||||||
@ -46,15 +47,21 @@ export function createFetchValueFunc<T>(
|
|||||||
): FetchValueFunc {
|
): FetchValueFunc {
|
||||||
const { node, setSelf, getPromise } = atomEffectParam;
|
const { node, setSelf, getPromise } = atomEffectParam;
|
||||||
const fetchValueFunc = async () => {
|
const fetchValueFunc = async () => {
|
||||||
|
const fvfId = randomUUID().slice(0, 4);
|
||||||
|
LOG.debug(`${fvfId} awaiting getPromise(guildState(${guildId}))`);
|
||||||
const guild = await getPromise(guildState(guildId));
|
const guild = await getPromise(guildState(guildId));
|
||||||
|
LOG.debug(`${fvfId} got guild from gm for g#${guildId}: ${guild}`);
|
||||||
if (guild === null) return; // NOTE: This would only happen if this atom is created before its corresponding guild exists in the 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);
|
const selfState = await getPromise(node);
|
||||||
if (isPended(selfState)) return; // don't send another request if we're already loading
|
if (isPended(selfState)) return; // don't send another request if we're already loading
|
||||||
|
|
||||||
|
LOG.debug(`${fvfId} setting to pended`);
|
||||||
setSelf(DEF_PENDED_VALUE);
|
setSelf(DEF_PENDED_VALUE);
|
||||||
try {
|
try {
|
||||||
|
LOG.debug(`${fvfId} fetchFunc before`);
|
||||||
const value = await fetchFunc(guild);
|
const value = await fetchFunc(guild);
|
||||||
|
LOG.debug(`${fvfId} fetchFunc after`);
|
||||||
setSelf(createLoadedValue(value, fetchValueFunc));
|
setSelf(createLoadedValue(value, fetchValueFunc));
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
setSelf(createFailedValue(e, fetchValueFunc));
|
setSelf(createFailedValue(e, fetchValueFunc));
|
||||||
@ -349,13 +356,16 @@ export function guildDataSubscriptionLoadableSingleEffect<
|
|||||||
const { trigger } = atomEffectParam;
|
const { trigger } = atomEffectParam;
|
||||||
if (skipFunc && skipFunc()) return; // don't run if this atom should be skipped for some reason (e.g. null resourceId)
|
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);
|
const fetchValueFunc = createFetchValueFunc(atomEffectParam, guildId, fetchFunc);
|
||||||
|
|
||||||
// fetch initial value on first get
|
// fetch initial value on first get
|
||||||
if (trigger === 'get') {
|
if (trigger === 'get') {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
LOG.debug('awaiting fetchValueFunc Single');
|
||||||
await fetchValueFunc();
|
await fetchValueFunc();
|
||||||
|
LOG.debug('done fetchValueFunc Single');
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
LOG.error('error fetching initial value', e);
|
LOG.error('error fetching initial value', e);
|
||||||
}
|
}
|
||||||
@ -386,13 +396,16 @@ export function guildDataSubscriptionLoadableMultipleEffect<
|
|||||||
const effect: AtomEffect<LoadableValue<T[]>> = atomEffectParam => {
|
const effect: AtomEffect<LoadableValue<T[]>> = atomEffectParam => {
|
||||||
const { trigger } = atomEffectParam;
|
const { trigger } = atomEffectParam;
|
||||||
|
|
||||||
|
/* LOG.debug(`multiple effect for guild #${guildId}`); */
|
||||||
const fetchValueFunc = createFetchValueFunc(atomEffectParam, guildId, fetchFunc);
|
const fetchValueFunc = createFetchValueFunc(atomEffectParam, guildId, fetchFunc);
|
||||||
|
|
||||||
// fetch initial value on first get
|
// fetch initial value on first get
|
||||||
if (trigger === 'get') {
|
if (trigger === 'get') {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
/* LOG.debug('awaiting fetchValueFunc Multiple'); */
|
||||||
await fetchValueFunc();
|
await fetchValueFunc();
|
||||||
|
/* LOG.debug('done fetchValueFunc Multiple'); */
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
LOG.error('error fetching initial value', e);
|
LOG.error('error fetching initial value', e);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ import {
|
|||||||
multipleScrollingGuildSubscriptionEffect,
|
multipleScrollingGuildSubscriptionEffect,
|
||||||
useRecoilValueLoadableOrElse,
|
useRecoilValueLoadableOrElse,
|
||||||
} from './atoms-funcs';
|
} from './atoms-funcs';
|
||||||
|
import { randomUUID } from 'crypto';
|
||||||
|
|
||||||
export const overlayState = atom<ReactNode>({
|
export const overlayState = atom<ReactNode>({
|
||||||
key: 'overlayState',
|
key: 'overlayState',
|
||||||
@ -86,7 +87,10 @@ export const guildMetaState = atomFamily<LoadableValue<GuildMetadata>, number>({
|
|||||||
effects_UNSTABLE: (guildId: number) => [
|
effects_UNSTABLE: (guildId: number) => [
|
||||||
guildDataSubscriptionLoadableSingleEffect(
|
guildDataSubscriptionLoadableSingleEffect(
|
||||||
guildId,
|
guildId,
|
||||||
async (guild: CombinedGuild) => await guild.fetchMetadata(),
|
async (guild: CombinedGuild) => {
|
||||||
|
LOG.debug('fetching guild metadata', { guild });
|
||||||
|
return await guild.fetchMetadata();
|
||||||
|
},
|
||||||
{
|
{
|
||||||
updatedEvent: {
|
updatedEvent: {
|
||||||
name: 'update-metadata',
|
name: 'update-metadata',
|
||||||
@ -378,9 +382,13 @@ export const guildState = selectorFamily<CombinedGuild | null, number>({
|
|||||||
get:
|
get:
|
||||||
(guildId: number) =>
|
(guildId: number) =>
|
||||||
({ get }) => {
|
({ get }) => {
|
||||||
|
const id = randomUUID().slice(0, 4);
|
||||||
|
LOG.debug(`${id} - use guildState g#${guildId}`)
|
||||||
const guildsManager = get(guildsManagerState);
|
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;
|
if (guildsManager === null) return null;
|
||||||
const guild = guildsManager.guilds.find(guild => guild.id === guildId) ?? null;
|
const guild = guildsManager.guilds.find(guild => guild.id === guildId) ?? null;
|
||||||
|
LOG.debug(`${id} - gm guild member: m#${guild?.memberId}`);
|
||||||
return guild;
|
return guild;
|
||||||
},
|
},
|
||||||
dangerouslyAllowMutability: true,
|
dangerouslyAllowMutability: true,
|
||||||
@ -394,6 +402,7 @@ export const currGuildIdState = atom<number | null>({
|
|||||||
function createCurrentGuildStateGetter<T>(subSelectorFamily: (guildId: number) => RecoilValueReadOnly<T>) {
|
function createCurrentGuildStateGetter<T>(subSelectorFamily: (guildId: number) => RecoilValueReadOnly<T>) {
|
||||||
return ({ get }: { get: GetRecoilValue }) => {
|
return ({ get }: { get: GetRecoilValue }) => {
|
||||||
const currGuildId = get(currGuildIdState);
|
const currGuildId = get(currGuildIdState);
|
||||||
|
LOG.debug(`current guild id is ${currGuildId} - guild state getter`);
|
||||||
if (currGuildId === null) return null;
|
if (currGuildId === null) return null;
|
||||||
|
|
||||||
const value = get(subSelectorFamily(currGuildId));
|
const value = get(subSelectorFamily(currGuildId));
|
||||||
@ -540,6 +549,7 @@ export function useRecoilValueSoftImgSrc(recoilValue: RecoilValue<string>): stri
|
|||||||
|
|
||||||
// initialize with a guildsManager
|
// initialize with a guildsManager
|
||||||
export function useInitRecoil(guildsManager: GuildsManager) {
|
export function useInitRecoil(guildsManager: GuildsManager) {
|
||||||
|
LOG.debug(`recoil init, gm has ${guildsManager.guilds.length} guilds`);
|
||||||
const setGuildsManager = useSetRecoilState(guildsManagerState);
|
const setGuildsManager = useSetRecoilState(guildsManagerState);
|
||||||
const setGuilds = useSetRecoilState(allGuildsState);
|
const setGuilds = useSetRecoilState(allGuildsState);
|
||||||
const [currGuildId, setCurrGuildId] = useRecoilState(currGuildIdState);
|
const [currGuildId, setCurrGuildId] = useRecoilState(currGuildIdState);
|
||||||
|
@ -21,15 +21,19 @@ const GuildElement: FC = () => {
|
|||||||
// TODO: Handle fetch errors in message list
|
// TODO: Handle fetch errors in message list
|
||||||
// TODO: React set hasMessagesAbove and hasMessagesBelow when re-verified?
|
// TODO: React set hasMessagesAbove and hasMessagesBelow when re-verified?
|
||||||
|
|
||||||
|
LOG.debug('grabbing recoil values for current guild');
|
||||||
const guild = useRecoilValue(currGuildState);
|
const guild = useRecoilValue(currGuildState);
|
||||||
const selfMember = useRecoilValue(currGuildSelfMemberState);
|
const selfMember = useRecoilValue(currGuildSelfMemberState);
|
||||||
const channels = useRecoilValue(currGuildChannelsState);
|
const channels = useRecoilValue(currGuildChannelsState);
|
||||||
const activeChannel = useRecoilValue(currGuildActiveChannelState);
|
const activeChannel = useRecoilValue(currGuildActiveChannelState);
|
||||||
const setActiveChannelId = useSetRecoilState(guildActiveChannelIdState(guild?.id ?? -1));
|
const setActiveChannelId = useSetRecoilState(guildActiveChannelIdState(guild?.id ?? -1));
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// lOG.debug('guild changed', { guildId: guild?.id ?? '<null>' });
|
LOG.debug('guild changed', { guildId: guild?.id ?? '<null>' });
|
||||||
// }, [ guild ]);
|
}, [ guild ]);
|
||||||
|
useEffect(() => {
|
||||||
|
LOG.debug('self member changed', { selfMember });
|
||||||
|
}, [ selfMember ]);
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// lOG.debug('active channel changed', { activeChannel });
|
// lOG.debug('active channel changed', { activeChannel });
|
||||||
// }, [ activeChannel ])
|
// }, [ activeChannel ])
|
||||||
|
@ -38,21 +38,18 @@ export default class PairVerifierFetchable extends EventEmitter<Conflictable> im
|
|||||||
this.fetchMetadataVerifier = AutoVerifier.createStandardSingleAutoVerifier<GuildMetadata>(
|
this.fetchMetadataVerifier = AutoVerifier.createStandardSingleAutoVerifier<GuildMetadata>(
|
||||||
async () => await this.primary.fetchMetadata(),
|
async () => await this.primary.fetchMetadata(),
|
||||||
async () => await this.trusted.fetchMetadata(),
|
async () => await this.trusted.fetchMetadata(),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleMetadataConflict.bind(this),
|
this.handleMetadataConflict.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.fetchMembersVerifier = AutoVerifier.createStandardListAutoVerifier<Member>(
|
this.fetchMembersVerifier = AutoVerifier.createStandardListAutoVerifier<Member>(
|
||||||
async () => await this.primary.fetchMembers(),
|
async () => await this.primary.fetchMembers(),
|
||||||
async () => await this.trusted.fetchMembers(),
|
async () => await this.trusted.fetchMembers(),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleMembersConflict.bind(this),
|
this.handleMembersConflict.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.fetchChannelsVerifier = AutoVerifier.createStandardListAutoVerifier<Channel>(
|
this.fetchChannelsVerifier = AutoVerifier.createStandardListAutoVerifier<Channel>(
|
||||||
async () => await this.primary.fetchChannels(),
|
async () => await this.primary.fetchChannels(),
|
||||||
async () => await this.trusted.fetchChannels(),
|
async () => await this.trusted.fetchChannels(),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleChannelsConflict.bind(this),
|
this.handleChannelsConflict.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -61,14 +58,12 @@ export default class PairVerifierFetchable extends EventEmitter<Conflictable> im
|
|||||||
// async () => { LOG.debug('fetching primary tokens for ' + this.trusted.constructor.name); return await this.trusted.fetchTokens() },
|
// async () => { LOG.debug('fetching primary tokens for ' + this.trusted.constructor.name); return await this.trusted.fetchTokens() },
|
||||||
async () => await this.primary.fetchTokens(),
|
async () => await this.primary.fetchTokens(),
|
||||||
async () => await this.trusted.fetchTokens(),
|
async () => await this.trusted.fetchTokens(),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleTokensConflict.bind(this),
|
this.handleTokensConflict.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.fetchResourceVerifier = AutoVerifierWithArg.createStandardIDQueriedSingleAutoVerifier<Resource>(
|
this.fetchResourceVerifier = AutoVerifierWithArg.createStandardIDQueriedSingleAutoVerifier<Resource>(
|
||||||
async (query: IDQuery) => await this.primary.fetchResource(query.id),
|
async (query: IDQuery) => await this.primary.fetchResource(query.id),
|
||||||
async (query: IDQuery) => await this.trusted.fetchResource(query.id),
|
async (query: IDQuery) => await this.trusted.fetchResource(query.id),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleResourceConflict.bind(this),
|
this.handleResourceConflict.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -77,7 +72,6 @@ export default class PairVerifierFetchable extends EventEmitter<Conflictable> im
|
|||||||
await this.primary.fetchMessagesRecent(query.channelId, query.number),
|
await this.primary.fetchMessagesRecent(query.channelId, query.number),
|
||||||
async (query: PartialMessageListQuery) =>
|
async (query: PartialMessageListQuery) =>
|
||||||
await this.trusted.fetchMessagesRecent(query.channelId, query.number),
|
await this.trusted.fetchMessagesRecent(query.channelId, query.number),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleMessagesConflict.bind(this),
|
this.handleMessagesConflict.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -86,7 +80,6 @@ export default class PairVerifierFetchable extends EventEmitter<Conflictable> im
|
|||||||
await this.primary.fetchMessagesBefore(query.channelId, query.messageOrderId as string, query.number),
|
await this.primary.fetchMessagesBefore(query.channelId, query.messageOrderId as string, query.number),
|
||||||
async (query: PartialMessageListQuery) =>
|
async (query: PartialMessageListQuery) =>
|
||||||
await this.trusted.fetchMessagesBefore(query.channelId, query.messageOrderId as string, query.number),
|
await this.trusted.fetchMessagesBefore(query.channelId, query.messageOrderId as string, query.number),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleMessagesConflict.bind(this),
|
this.handleMessagesConflict.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -95,7 +88,6 @@ export default class PairVerifierFetchable extends EventEmitter<Conflictable> im
|
|||||||
await this.primary.fetchMessagesAfter(query.channelId, query.messageOrderId as string, query.number),
|
await this.primary.fetchMessagesAfter(query.channelId, query.messageOrderId as string, query.number),
|
||||||
async (query: PartialMessageListQuery) =>
|
async (query: PartialMessageListQuery) =>
|
||||||
await this.trusted.fetchMessagesAfter(query.channelId, query.messageOrderId as string, query.number),
|
await this.trusted.fetchMessagesAfter(query.channelId, query.messageOrderId as string, query.number),
|
||||||
async () => await this.trusted.ensureVerified(),
|
|
||||||
this.handleMessagesConflict.bind(this),
|
this.handleMessagesConflict.bind(this),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -355,18 +355,22 @@ export default class CombinedGuild
|
|||||||
// fetched through the triple-cache system (RAM -> Disk -> Server)
|
// fetched through the triple-cache system (RAM -> Disk -> Server)
|
||||||
async fetchMetadata(): Promise<GuildMetadata> {
|
async fetchMetadata(): Promise<GuildMetadata> {
|
||||||
// xUtil.failSometimes(0.05); // for testing
|
// xUtil.failSometimes(0.05); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch metadata`);
|
||||||
return await this.fetchable.fetchMetadata();
|
return await this.fetchable.fetchMetadata();
|
||||||
}
|
}
|
||||||
async fetchMembers(): Promise<Member[]> {
|
async fetchMembers(): Promise<Member[]> {
|
||||||
// xUtil.failSometimes(0.05); // for testing
|
// xUtil.failSometimes(0.05); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch members`);
|
||||||
return await this.fetchable.fetchMembers();
|
return await this.fetchable.fetchMembers();
|
||||||
}
|
}
|
||||||
async fetchChannels(): Promise<Channel[]> {
|
async fetchChannels(): Promise<Channel[]> {
|
||||||
// xUtil.failSometimes(0.05); // for testing
|
// xUtil.failSometimes(0.05); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch channels`);
|
||||||
return await this.fetchable.fetchChannels();
|
return await this.fetchable.fetchChannels();
|
||||||
}
|
}
|
||||||
async fetchMessagesRecent(channelId: string, number: number): Promise<Message[]> {
|
async fetchMessagesRecent(channelId: string, number: number): Promise<Message[]> {
|
||||||
// xUtil.failSometimes(0.05); // for testing
|
// xUtil.failSometimes(0.05); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch recent messages`);
|
||||||
const members = await this.grabRAMMembersMap();
|
const members = await this.grabRAMMembersMap();
|
||||||
const channels = await this.grabRAMChannelsMap();
|
const channels = await this.grabRAMChannelsMap();
|
||||||
const messages = await this.fetchable.fetchMessagesRecent(channelId, number);
|
const messages = await this.fetchable.fetchMessagesRecent(channelId, number);
|
||||||
@ -377,6 +381,7 @@ export default class CombinedGuild
|
|||||||
}
|
}
|
||||||
async fetchMessagesBefore(channelId: string, messageOrderId: string, number: number): Promise<Message[]> {
|
async fetchMessagesBefore(channelId: string, messageOrderId: string, number: number): Promise<Message[]> {
|
||||||
// xUtil.failSometimes(0.05); // for testing
|
// xUtil.failSometimes(0.05); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch messages before`);
|
||||||
const members = await this.grabRAMMembersMap();
|
const members = await this.grabRAMMembersMap();
|
||||||
const channels = await this.grabRAMChannelsMap();
|
const channels = await this.grabRAMChannelsMap();
|
||||||
const messages = await this.fetchable.fetchMessagesBefore(channelId, messageOrderId, number);
|
const messages = await this.fetchable.fetchMessagesBefore(channelId, messageOrderId, number);
|
||||||
@ -387,6 +392,7 @@ export default class CombinedGuild
|
|||||||
}
|
}
|
||||||
async fetchMessagesAfter(channelId: string, messageOrderId: string, number: number): Promise<Message[]> {
|
async fetchMessagesAfter(channelId: string, messageOrderId: string, number: number): Promise<Message[]> {
|
||||||
Util.failSometimes(0.75); // for testing
|
Util.failSometimes(0.75); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch messages after`);
|
||||||
const members = await this.grabRAMMembersMap();
|
const members = await this.grabRAMMembersMap();
|
||||||
const channels = await this.grabRAMChannelsMap();
|
const channels = await this.grabRAMChannelsMap();
|
||||||
const messages = await this.fetchable.fetchMessagesAfter(channelId, messageOrderId, number);
|
const messages = await this.fetchable.fetchMessagesAfter(channelId, messageOrderId, number);
|
||||||
@ -397,10 +403,12 @@ export default class CombinedGuild
|
|||||||
}
|
}
|
||||||
async fetchResource(resourceId: string): Promise<Resource> {
|
async fetchResource(resourceId: string): Promise<Resource> {
|
||||||
// xUtil.failSometimes(0.05); // for testing
|
// xUtil.failSometimes(0.05); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch resource`);
|
||||||
return await this.fetchable.fetchResource(resourceId);
|
return await this.fetchable.fetchResource(resourceId);
|
||||||
}
|
}
|
||||||
async fetchTokens(): Promise<Token[]> {
|
async fetchTokens(): Promise<Token[]> {
|
||||||
// xUtil.failSometimes(0.05); // for testing
|
// xUtil.failSometimes(0.05); // for testing
|
||||||
|
LOG.debug(`g#${this.id}: fetch tokens`);
|
||||||
const members = await this.grabRAMMembersMap();
|
const members = await this.grabRAMMembersMap();
|
||||||
const tokens = await this.fetchable.fetchTokens();
|
const tokens = await this.fetchable.fetchTokens();
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
|
Loading…
Reference in New Issue
Block a user