Backport pull request #5636 from jellyfin-web/release-10.9.z

Clear query and view cache on user logout

Original-merge: 4129676ed8

Merged-by: thornbill <thornbill@users.noreply.github.com>

Backported-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
grafixeyehero 2024-06-01 18:42:06 -04:00 committed by Joshua M. Boniface
parent 7e0afdfd66
commit 1fc471a0ed
2 changed files with 6 additions and 6 deletions

View File

@ -6,8 +6,6 @@ import Dashboard from '../utils/dashboard';
import Events from '../utils/events.ts';
import { setUserInfo } from '../scripts/settings/userSettings';
import appSettings from '../scripts/settings/appSettings';
import viewContainer from './viewContainer';
import { queryClient } from 'utils/query/queryClient';
const normalizeImageOptions = options => {
if (!options.quality && (options.maxWidth || options.width || options.maxHeight || options.height || options.fillWidth || options.fillHeight)) {
@ -43,10 +41,6 @@ class ServerConnections extends ConnectionManager {
setUserInfo(null, null);
// Ensure the updated credentials are persisted to storage
credentialProvider.credentials(credentialProvider.credentials());
// Reset the query cache
queryClient.resetQueries();
// Reset cached views
viewContainer.reset();
if (window.NativeShell && typeof window.NativeShell.onLocalUserSignedOut === 'function') {
window.NativeShell.onLocalUserSignedOut(logoutInfo);

View File

@ -12,6 +12,8 @@ import DirectoryBrowser from '../components/directorybrowser/directorybrowser';
import dialogHelper from '../components/dialogHelper/dialogHelper';
import itemIdentifier from '../components/itemidentifier/itemidentifier';
import { getLocationSearch } from './url.ts';
import { queryClient } from './query/queryClient';
import viewContainer from 'components/viewContainer';
export function getCurrentUser() {
return window.ApiClient.getCurrentUser(false);
@ -98,6 +100,10 @@ export function onServerChanged(_userId, _accessToken, apiClient) {
export function logout() {
ServerConnections.logout().then(function () {
// Clear the query cache
queryClient.clear();
// Reset cached views
viewContainer.reset();
webSettings.getMultiServer().then(multi => {
multi ? navigate('selectserver.html') : navigate('login.html');
});