mirror of
https://github.com/Jellify-Music/App.git
synced 2026-02-08 03:28:29 -06:00
Add Jellify Logo to Jellyfin Dashboard (#610)
* add postFullCapabilities function that will set the Jellify logo in the Dashboard * update jellyfin typescript sdk
This commit is contained in:
@@ -3,6 +3,9 @@ import { JellifyProvider, useJellifyContext } from '../../src/providers'
|
||||
import { Text, View } from 'react-native'
|
||||
import { MMKVStorageKeys } from '../../src/enums/mmkv-storage-keys'
|
||||
import { storage } from '../../src/constants/storage'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
|
||||
const queryClient = new QueryClient()
|
||||
|
||||
const JellifyConsumer = () => {
|
||||
const { server, user, library } = useJellifyContext()
|
||||
@@ -39,9 +42,12 @@ test(`${JellifyProvider.name} renders correctly`, async () => {
|
||||
)
|
||||
|
||||
render(
|
||||
<JellifyProvider>
|
||||
<JellifyConsumer />
|
||||
</JellifyProvider>,
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<JellifyProvider>
|
||||
<JellifyConsumer />
|
||||
</JellifyProvider>
|
||||
,
|
||||
</QueryClientProvider>,
|
||||
)
|
||||
|
||||
const apiBasePath = screen.getByTestId('api-base-path')
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"postinstall": "patch-package"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jellyfin/sdk": "^0.12.0",
|
||||
"@jellyfin/sdk": "0.13.0",
|
||||
"@react-native-community/cli": "20.0.0",
|
||||
"@react-native-community/netinfo": "^11.4.1",
|
||||
"@react-native-masked-view/masked-view": "^0.3.2",
|
||||
|
||||
24
src/api/mutations/session/index.ts
Normal file
24
src/api/mutations/session/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import useStreamingDeviceProfile from '../../../stores/device-profile'
|
||||
import { Api } from '@jellyfin/sdk'
|
||||
import { getSessionApi } from '@jellyfin/sdk/lib/utils/api'
|
||||
import { MONOCHROME_ICON_URL } from '../../../configs/config'
|
||||
|
||||
const usePostFullCapabilities = () => {
|
||||
const streamingDeviceProfile = useStreamingDeviceProfile()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (api: Api | undefined) => {
|
||||
if (!api) return
|
||||
|
||||
return getSessionApi(api).postFullCapabilities({
|
||||
clientCapabilitiesDto: {
|
||||
IconUrl: MONOCHROME_ICON_URL,
|
||||
DeviceProfile: streamingDeviceProfile,
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export default usePostFullCapabilities
|
||||
@@ -4,3 +4,6 @@ const OTA_UPDATE_ENABLED = Config.OTA_UPDATE_ENABLED === 'true'
|
||||
const IS_MAESTRO_BUILD = Config.IS_MAESTRO_BUILD === 'true'
|
||||
|
||||
export { OTA_UPDATE_ENABLED, IS_MAESTRO_BUILD }
|
||||
|
||||
export const MONOCHROME_ICON_URL =
|
||||
'https://raw.githubusercontent.com/Jellify-Music/App/refs/heads/main/assets/monochrome-logo.svg'
|
||||
|
||||
@@ -17,6 +17,8 @@ import { Api } from '@jellyfin/sdk/lib/api'
|
||||
import { JellyfinInfo } from '../api/info'
|
||||
import { queryClient } from '../constants/query-client'
|
||||
import AXIOS_INSTANCE from '../configs/axios.config'
|
||||
import useAppActive from '../hooks/use-app-active'
|
||||
import usePostFullCapabilities from '../api/mutations/session'
|
||||
|
||||
/**
|
||||
* The context for the Jellify provider.
|
||||
@@ -75,6 +77,8 @@ const JellifyContextInitializer = () => {
|
||||
const libraryJson = storage.getString(MMKVStorageKeys.Library)
|
||||
const apiJson = storage.getString(MMKVStorageKeys.Api)
|
||||
|
||||
const appIsActive = useAppActive()
|
||||
|
||||
const [api, setApi] = useState<Api | undefined>(apiJson ? JSON.parse(apiJson) : undefined)
|
||||
const [server, setServer] = useState<JellifyServer | undefined>(
|
||||
serverJson ? JSON.parse(serverJson) : undefined,
|
||||
@@ -88,6 +92,8 @@ const JellifyContextInitializer = () => {
|
||||
|
||||
const [loggedIn, setLoggedIn] = useState<boolean>(false)
|
||||
|
||||
const postFullCapabilities = usePostFullCapabilities()
|
||||
|
||||
const signOut = () => {
|
||||
setServer(undefined)
|
||||
setUser(undefined)
|
||||
@@ -128,6 +134,10 @@ const JellifyContextInitializer = () => {
|
||||
else storage.delete(MMKVStorageKeys.Library)
|
||||
}, [library])
|
||||
|
||||
useEffect(() => {
|
||||
if (appIsActive) postFullCapabilities.mutate(api)
|
||||
}, [appIsActive, api])
|
||||
|
||||
return {
|
||||
loggedIn,
|
||||
api,
|
||||
|
||||
@@ -1293,10 +1293,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"
|
||||
integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==
|
||||
|
||||
"@jellyfin/sdk@^0.12.0":
|
||||
version "0.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@jellyfin/sdk/-/sdk-0.12.0.tgz#39f44caae7271a6320160c46d5626f17ad5217c6"
|
||||
integrity sha512-do3cks7TD316Qw27lBMHZQ7ufaS1MC8HMsQF5rFv5/DUInuwEOqWthqVyHl3sIjThOThF1zxQyE6OdpUl0dNUg==
|
||||
"@jellyfin/sdk@0.13.0":
|
||||
version "0.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@jellyfin/sdk/-/sdk-0.13.0.tgz#8e5fe68fe6df22b287af2c65c5353cd1b7f2ced4"
|
||||
integrity sha512-oiBAOXH6s+dKdReSsYgNktBDzbxtg4JVWhEzIxZSxKcWMdSKmBtK41MhXRO7IWAC40DguKUm3nU/Z493qPAlWA==
|
||||
|
||||
"@jest/console@30.0.5":
|
||||
version "30.0.5"
|
||||
|
||||
Reference in New Issue
Block a user