feat: add new server page
This commit is contained in:
13 files changed
+506
-69
No files matched your search
@@ -18,8 +18,11 @@ export const getItemQueryOptions = (
|
||||
queryOptions({
|
||||
queryKey: ["item", id],
|
||||
queryFn: async () => {
|
||||
if (!api || !userId) {
|
||||
throw Error("API or User ID is not defined");
|
||||
if (!api) {
|
||||
throw Error("API is not defined");
|
||||
}
|
||||
if (!userId) {
|
||||
throw Error("User ID is not defined");
|
||||
}
|
||||
const result = await getUserLibraryApi(api).getItem({
|
||||
userId: userId,
|
||||
@@ -42,8 +45,11 @@ export const getLatestItemsQueryOptions = (
|
||||
queryOptions({
|
||||
queryKey: ["home", "latestMedia"],
|
||||
queryFn: async () => {
|
||||
if (!api || !userId) {
|
||||
throw Error("API or User ID is not defined");
|
||||
if (!api) {
|
||||
throw Error("API is not defined");
|
||||
}
|
||||
if (!userId) {
|
||||
throw Error("User ID is not defined");
|
||||
}
|
||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||
userId: userId,
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
import { load } from "@tauri-apps/plugin-store";
|
||||
|
||||
export interface UserStore {
|
||||
user: {
|
||||
Name: string;
|
||||
AccessToken: string;
|
||||
};
|
||||
}
|
||||
user: {
|
||||
Name: string;
|
||||
AccessToken: string;
|
||||
Id: string;
|
||||
};
|
||||
}
|
||||
|
||||
const user = await load(".user.dat", { autoSave: true });
|
||||
|
||||
/**
|
||||
* Set User details to .user.dat
|
||||
*/
|
||||
const saveUser = async (userName: string, accessToken: string) => {
|
||||
const saveUser = async (
|
||||
userName: string,
|
||||
accessToken: string,
|
||||
userId: string,
|
||||
) => {
|
||||
user.set("user", {
|
||||
Name: userName,
|
||||
AccessToken: accessToken,
|
||||
Id: userId,
|
||||
});
|
||||
|
||||
await user.save();
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import React, { type ReactNode } from "react";
|
||||
import { createContext, useContext, useState } from "react";
|
||||
import { type StoreApi, createStore } from "zustand";
|
||||
import React, {
|
||||
createContext,
|
||||
type ReactNode,
|
||||
useContext,
|
||||
useState,
|
||||
} from "react";
|
||||
import { createStore, type StoreApi } from "zustand";
|
||||
import { shallow } from "zustand/shallow";
|
||||
import { useStoreWithEqualityFn } from "zustand/traditional";
|
||||
import { version } from "../../../package.json";
|
||||
import {
|
||||
type ServerInfo,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
getServer,
|
||||
type ServerInfo,
|
||||
} from "../storage/servers";
|
||||
import { getUser } from "../storage/user";
|
||||
|
||||
@@ -22,6 +26,7 @@ type CentralStore = {
|
||||
userOnDisk: () => Promise<{
|
||||
Name: string;
|
||||
AccessToken: string;
|
||||
Id: string;
|
||||
} | null>;
|
||||
clientVersion: string;
|
||||
currentUser: null | UserDto;
|
||||
|
||||
Reference in new issue
Block a user