fix views no longer connected to flux store (fixes dashboard) (thanks Harley!)

pull/98/merge
dperolio 2 years ago
parent 4df26a181c
commit 04f104bd35
No known key found for this signature in database
GPG Key ID: 4191689562D51409

@ -1,5 +1,5 @@
/**
*
*
*/
import { findInReactTree, findInTree, getOwnerInstance } from '@vizality/util/react';
@ -77,8 +77,7 @@ export default class Router extends Builtin {
* @returns {Promise<void>}
*/
async patchViews () {
const FluxifiedViews = await getModuleByDisplayName('FluxContainer(ViewsWithMainInterface)', true);
const Views = FluxifiedViews?.prototype?.render?.call({ memoizedGetStateFromStores: () => ({}) })?.type;
const Views = await getModuleByDisplayName('ViewsWithMainInterface', true);
patch('vz-router-views', Views?.prototype, 'render', (_, res) => {
try {
const routes = findInTree(res, n => isArray(n) && n[0]?.key && n[0].props?.path && n[0].props.render);

@ -75,17 +75,6 @@ export default class Vizality extends Updatable {
*/
await initializeWebpackModules();
/**
* Set up a connectStoresAsync FLux method.
* @note This has to be after webpack modules have been initialized.
*/
const Flux = await getModule('Store', 'PersistedStore', true);
Flux.connectStoresAsync = (stores, fn) => Component =>
import('./components').AsyncComponent.from((async () => {
const awaitedStores = await Promise.all(stores);
return Flux.connectStores(awaitedStores, props => fn(awaitedStores, props))(Component);
})());
await this.handleConnectionOpen();
} catch (err) {
this.error(`Something went wrong while initializing webpack modules: ${err}`);
@ -99,6 +88,17 @@ export default class Vizality extends Updatable {
try {
await this.ensureWebpackModules();
/**
* Set up a connectStoresAsync Flux method.
* @note This has to be after webpack modules have been initialized.
*/
const Flux = await getModule('Store', 'PersistedStore', true);
Flux.connectStoresAsync = (stores, fn) => Component =>
import('./components').AsyncComponent.from((async () => {
const awaitedStores = await Promise.all(stores);
return Flux.connectStores(awaitedStores, props => fn(awaitedStores, props))(Component);
})());
/**
* Get rid of Discord's "Hold Up" dev tools warning.
*/

Loading…
Cancel
Save