Desktop: Trying to fix white screen issue

pull/8283/head^2
Laurent Cozic 2023-06-06 16:31:31 +01:00
parent 3792a5fb94
commit 8b578c5dde
3 changed files with 26 additions and 24 deletions

View File

@ -4,6 +4,9 @@ import { defaultState, State } from '@joplin/lib/reducer';
import iterateItems from './gui/ResizableLayout/utils/iterateItems';
import { LayoutItem } from './gui/ResizableLayout/utils/types';
import validateLayout from './gui/ResizableLayout/utils/validateLayout';
import Logger from '@joplin/lib/Logger';
const logger = Logger.create('app.reducer');
export interface AppStateRoute {
type: string;
@ -171,22 +174,31 @@ export default function(state: AppState, action: any) {
case 'MAIN_LAYOUT_SET_ITEM_PROP':
{
let newLayout = produce(state.mainLayout, (draftLayout: LayoutItem) => {
iterateItems(draftLayout, (_itemIndex: number, item: LayoutItem, _parent: LayoutItem) => {
if (item.key === action.itemKey) {
(item as any)[action.propName] = action.propValue;
return false;
}
return true;
if (!state.mainLayout) {
logger.warn('MAIN_LAYOUT_SET_ITEM_PROP: Trying to set an item prop on the layout, but layout is empty: ', JSON.stringify(action));
} else {
let newLayout = produce(state.mainLayout, (draftLayout: LayoutItem) => {
iterateItems(draftLayout, (_itemIndex: number, item: LayoutItem, _parent: LayoutItem) => {
if (!item) {
logger.warn('MAIN_LAYOUT_SET_ITEM_PROP: Found an empty item in layout: ', JSON.stringify(state.mainLayout));
} else {
if (item.key === action.itemKey) {
(item as any)[action.propName] = action.propValue;
return false;
}
}
return true;
});
});
});
if (newLayout !== state.mainLayout) newLayout = validateLayout(newLayout);
if (newLayout !== state.mainLayout) newLayout = validateLayout(newLayout);
newState = {
...state,
mainLayout: newLayout,
};
newState = {
...state,
mainLayout: newLayout,
};
}
}
break;

View File

@ -557,15 +557,7 @@ class Application extends BaseApplication {
bridge().addEventListener('nativeThemeUpdated', this.bridge_nativeThemeUpdated);
// We need to delay plugin initialisation until the main screen is
// ready. Otherwise plugins might try to modify the application layout,
// which will cause an error related to an empty layout item. This in
// turns will cause the screen to go white on startup.
//
// https://discourse.joplinapp.org/t/upgrade-produces-blank-window/31138/8
eventManager.on('mainScreenReady', () => {
void this.initPluginService();
});
await this.initPluginService();
this.setupContextMenu();

View File

@ -46,7 +46,6 @@ import PromptDialog from '../PromptDialog';
import NotePropertiesDialog from '../NotePropertiesDialog';
const PluginManager = require('@joplin/lib/services/PluginManager');
const ipcRenderer = require('electron').ipcRenderer;
import eventManager from '@joplin/lib/eventManager';
interface LayerModalState {
visible: boolean;
@ -392,7 +391,6 @@ class MainScreenComponent extends React.Component<Props, State> {
public componentDidMount() {
window.addEventListener('keydown', this.layoutModeListenerKeyDown);
eventManager.emit('mainScreenReady');
}
public componentWillUnmount() {