diff --git a/src/servers/main.ts b/src/servers/main.ts index ca0b9d9e3a..8bebe1c4b4 100644 --- a/src/servers/main.ts +++ b/src/servers/main.ts @@ -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 { @@ -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(); } diff --git a/src/servers/preload/gitCommitHash.ts b/src/servers/preload/gitCommitHash.ts index 866e80c07c..dd145176dc 100644 --- a/src/servers/preload/gitCommitHash.ts +++ b/src/servers/preload/gitCommitHash.ts @@ -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, diff --git a/src/ui/actions.ts b/src/ui/actions.ts index d6230941d0..17821a0a37 100644 --- a/src/ui/actions.ts +++ b/src/ui/actions.ts @@ -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'; @@ -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'];