mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-21 00:05:13 +02:00
refactor: User and session management
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import TextField from '../TextField.svelte';
|
||||
import { appState } from '../../stores/app-state.store';
|
||||
import { user } from '../../stores/user.store';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import SelectField from '../SelectField.svelte';
|
||||
import { jellyfinApi, type JellyfinUser } from '../../apis/jellyfin/jellyfin-api';
|
||||
@@ -20,9 +20,9 @@
|
||||
let jellyfinUsers: Promise<JellyfinUser[]> | undefined = undefined;
|
||||
export let jellyfinUser: JellyfinUser | undefined;
|
||||
|
||||
appState.subscribe((appState) => {
|
||||
baseUrl = baseUrl || appState.user?.settings.jellyfin.baseUrl || '';
|
||||
apiKey = apiKey || appState.user?.settings.jellyfin.apiKey || '';
|
||||
user.subscribe((user) => {
|
||||
baseUrl = baseUrl || user?.settings.jellyfin.baseUrl || '';
|
||||
apiKey = apiKey || user?.settings.jellyfin.apiKey || '';
|
||||
|
||||
originalBaseUrl = baseUrl;
|
||||
originalApiKey = apiKey;
|
||||
@@ -35,9 +35,7 @@
|
||||
baseUrl,
|
||||
apiKey,
|
||||
stale:
|
||||
baseUrl && apiKey
|
||||
? jellyfinUser?.Id !== get(appState).user?.settings.jellyfin.userId
|
||||
: !jellyfinUser
|
||||
baseUrl && apiKey ? jellyfinUser?.Id !== get(user)?.settings.jellyfin.userId : !jellyfinUser
|
||||
});
|
||||
|
||||
function handleChange() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import TextField from '../TextField.svelte';
|
||||
import { appState } from '../../stores/app-state.store';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { radarrApi } from '../../apis/radarr/radarr-api';
|
||||
import { user } from '../../stores/user.store';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
change: { baseUrl: string; apiKey: string; stale: boolean };
|
||||
@@ -16,9 +16,9 @@
|
||||
let error = '';
|
||||
let healthCheck: Promise<boolean> | undefined;
|
||||
|
||||
appState.subscribe((appState) => {
|
||||
baseUrl = baseUrl || appState.user?.settings.radarr.baseUrl || '';
|
||||
apiKey = apiKey || appState.user?.settings.radarr.apiKey || '';
|
||||
user.subscribe((user) => {
|
||||
baseUrl = baseUrl || user?.settings.radarr.baseUrl || '';
|
||||
apiKey = apiKey || user?.settings.radarr.apiKey || '';
|
||||
|
||||
originalBaseUrl = baseUrl;
|
||||
originalApiKey = apiKey;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import TextField from '../TextField.svelte';
|
||||
import { appState } from '../../stores/app-state.store';
|
||||
import { sonarrApi } from '../../apis/sonarr/sonarr-api';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { user } from '../../stores/user.store';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
change: { baseUrl: string; apiKey: string; stale: boolean };
|
||||
@@ -16,9 +16,9 @@
|
||||
let error = '';
|
||||
let healthCheck: Promise<boolean> | undefined;
|
||||
|
||||
appState.subscribe((appState) => {
|
||||
baseUrl = baseUrl || appState.user?.settings.sonarr.baseUrl || '';
|
||||
apiKey = apiKey || appState.user?.settings.sonarr.apiKey || '';
|
||||
user.subscribe((user) => {
|
||||
baseUrl = baseUrl || user?.settings.sonarr.baseUrl || '';
|
||||
apiKey = apiKey || user?.settings.sonarr.apiKey || '';
|
||||
|
||||
originalBaseUrl = baseUrl;
|
||||
originalApiKey = apiKey;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import TextField from '../TextField.svelte';
|
||||
import { appState } from '../../stores/app-state.store';
|
||||
import { sonarrApi } from '../../apis/sonarr/sonarr-api';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { user } from '../../stores/user.store';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
change: { baseUrl: string; apiKey: string; stale: boolean };
|
||||
@@ -16,9 +16,9 @@
|
||||
let error = '';
|
||||
let healthCheck: Promise<boolean> | undefined;
|
||||
|
||||
appState.subscribe((appState) => {
|
||||
baseUrl = baseUrl || appState.user?.settings.sonarr.baseUrl || '';
|
||||
apiKey = apiKey || appState.user?.settings.sonarr.apiKey || '';
|
||||
user.subscribe((user) => {
|
||||
baseUrl = baseUrl || user?.settings.sonarr.baseUrl || '';
|
||||
apiKey = apiKey || user?.settings.sonarr.apiKey || '';
|
||||
|
||||
originalBaseUrl = baseUrl;
|
||||
originalApiKey = apiKey;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import Container from '../../../Container.svelte';
|
||||
import { appState } from '../../stores/app-state.store';
|
||||
import { tmdbApi } from '../../apis/tmdb/tmdb-api';
|
||||
import Button from '../Button.svelte';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { ExternalLink } from 'radix-icons-svelte';
|
||||
import { user } from '../../stores/user.store';
|
||||
|
||||
const dispatch = createEventDispatcher<{ connected: null }>();
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
return; // TODO add notification
|
||||
}
|
||||
|
||||
appState.updateUser((prev) => ({
|
||||
user.updateUser((prev) => ({
|
||||
...prev,
|
||||
settings: {
|
||||
...prev.settings,
|
||||
|
||||
Reference in New Issue
Block a user