mirror of
https://github.com/Jellify-Music/App.git
synced 2025-12-21 02:30:08 -06:00
singleton stuff
This commit is contained in:
@@ -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
|
||||
|
||||
4
index.js
4
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);
|
||||
Client.instance;
|
||||
Reference in New Issue
Block a user