Skip to content

Commit

Permalink
fix: Stuck in black screen after server update (#2543)
Browse files Browse the repository at this point in the history
* fix: Stuck in black screen after server update
  • Loading branch information
jeanfbrito authored Nov 10, 2022
1 parent 637c9dd commit 85c6068
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
22 changes: 19 additions & 3 deletions src/servers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { satisfies, coerce } from 'semver';
import { invoke } from '../ipc/main';
import { select, dispatch, listen } from '../store';
import { hasMeta } from '../store/fsa';
import { WEBVIEW_GIT_COMMIT_HASH_CHANGED } from '../ui/actions';
import {
WEBVIEW_GIT_COMMIT_HASH_CHANGED,
WEBVIEW_GIT_COMMIT_HASH_CHECK,
} from '../ui/actions';
import { getRootWindow } from '../ui/main/rootWindow';
import { getWebContentsByServerUrl } from '../ui/main/serverView';
import {
Expand Down Expand Up @@ -172,15 +175,28 @@ export const setupServers = async (
}
});

listen(WEBVIEW_GIT_COMMIT_HASH_CHANGED, async (action) => {
listen(WEBVIEW_GIT_COMMIT_HASH_CHECK, async (action) => {
const { url, gitCommitHash } = action.payload;

const servers = select(({ servers }) => servers);

const server = servers.find((server) => server.url === url);

if (server?.gitCommitHash !== gitCommitHash) {
if (
server?.gitCommitHash !== gitCommitHash &&
server?.gitCommitHash !== undefined
) {
dispatch({
type: WEBVIEW_GIT_COMMIT_HASH_CHANGED,
payload: {
url,
gitCommitHash,
},
});
const guestWebContents = getWebContentsByServerUrl(url);
await guestWebContents?.session.clearStorageData({
storages: ['indexdb'],
});
await guestWebContents?.session.clearCache();
guestWebContents?.reload();
}
Expand Down
5 changes: 3 additions & 2 deletions src/servers/preload/gitCommitHash.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { dispatch } from '../../store';
import { WEBVIEW_GIT_COMMIT_HASH_CHANGED } from '../../ui/actions';
import { WEBVIEW_GIT_COMMIT_HASH_CHECK } from '../../ui/actions';
import { Server } from '../common';
import { getServerUrl } from './urls';

export const setGitCommitHash = (
gitCommitHash: Server['gitCommitHash']
): void => {
console.log('setGitCommitHash', gitCommitHash);
dispatch({
type: WEBVIEW_GIT_COMMIT_HASH_CHANGED,
type: WEBVIEW_GIT_COMMIT_HASH_CHECK,
payload: {
url: getServerUrl(),
gitCommitHash,
Expand Down
5 changes: 5 additions & 0 deletions src/ui/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const WEBVIEW_SCREEN_SHARING_SOURCE_RESPONDED =
export const WEBVIEW_SIDEBAR_STYLE_CHANGED = 'webview/sidebar-style-changed';
export const WEBVIEW_GIT_COMMIT_HASH_CHANGED =
'webview/git-commit-hash-changed';
export const WEBVIEW_GIT_COMMIT_HASH_CHECK = 'webview/git-commit-hash-check';
export const WEBVIEW_TITLE_CHANGED = 'webview/title-changed';
export const WEBVIEW_UNREAD_CHANGED = 'webview/unread-changed';
export const WEBVIEW_USER_LOGGED_IN = 'webview/user-loggedin';
Expand Down Expand Up @@ -136,6 +137,10 @@ export type UiActionTypeToPayloadMap = {
url: Server['url'];
userLoggedIn: Server['userLoggedIn'];
};
[WEBVIEW_GIT_COMMIT_HASH_CHECK]: {
url: Server['url'];
gitCommitHash: Server['gitCommitHash'];
};
[WEBVIEW_GIT_COMMIT_HASH_CHANGED]: {
url: Server['url'];
gitCommitHash: Server['gitCommitHash'];
Expand Down

0 comments on commit 85c6068

Please sign in to comment.