diff --git a/api/client.ts b/api/client.ts index 948a1708..d15ca7d4 100644 --- a/api/client.ts +++ b/api/client.ts @@ -64,6 +64,13 @@ export default class Client { Client.instance.removeCredentials() } + public static switchUser(): void { + if (!Client.#instance) + Client.instance; + + Client.instance.removeUser(); + } + private setAndPersistUser(user: JellifyUser) { this.user = user; @@ -94,6 +101,12 @@ export default class Client { storage.delete(MMKVStorageKeys.User) } + private removeUser() { + this.user = undefined; + + storage.delete(MMKVStorageKeys.User) + } + /** * Uses the jellifyClient to create a public Jellyfin API instance. * @param serverUrl The URL of the Jellyfin server diff --git a/index.js b/index.js index 0c6395f8..e78588c2 100644 --- a/index.js +++ b/index.js @@ -4,8 +4,8 @@ import App from './App'; import {name as appName} from './app.json'; import { PlaybackService } from './player/service' import TrackPlayer from 'react-native-track-player'; -import { Client } from './api/client'; +import Client from './api/client'; -Client.instance; AppRegistry.registerComponent(appName, () => App); -TrackPlayer.registerPlaybackService(() => PlaybackService); \ No newline at end of file +TrackPlayer.registerPlaybackService(() => PlaybackService); +Client.instance; \ No newline at end of file