mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2026-09-03 05:10:26 +03:00
feat: refresh user on page load
This commit is contained in:
committed by
Fernando Fernández
parent
7f180c47b6
commit
284d770e3e
@@ -1,6 +1,7 @@
|
||||
import { RemovableRef, useStorage } from '@vueuse/core';
|
||||
import { UserDto } from '@jellyfin/sdk/lib/generated-client';
|
||||
import { getSystemApi } from '@jellyfin/sdk/lib/utils/api/system-api';
|
||||
import { getUserApi } from '@jellyfin/sdk/lib/utils/api/user-api';
|
||||
import { isNil, merge } from 'lodash-es';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { AxiosError } from 'axios';
|
||||
@@ -197,6 +198,22 @@ class RemotePluginAuth {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the current user infos, to fetch a new picture for instance
|
||||
*/
|
||||
public async refreshCurrentUserInfo(): Promise<void> {
|
||||
if (!isNil(this.currentUser) && !isNil(this.currentServer)) {
|
||||
const api = useOneTimeAPI(
|
||||
this.currentServer.PublicAddress,
|
||||
this.getUserAccessToken(this.currentUser)
|
||||
);
|
||||
|
||||
state.value.users[state.value.currentUserIndex] = (
|
||||
await getUserApi(api).getCurrentUser()
|
||||
).data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the user from the server using the current base url and access token parameters.
|
||||
*
|
||||
@@ -268,6 +285,10 @@ class RemotePluginAuth {
|
||||
|
||||
state.value.servers.splice(state.value.servers.indexOf(server), 1);
|
||||
}
|
||||
|
||||
public constructor() {
|
||||
this.refreshCurrentUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
const RemotePluginAuthInstance = new RemotePluginAuth();
|
||||
|
||||
Reference in New Issue
Block a user