ConnectionInfo and the db ConnectionRow types are now completely seperate things. Started on audio fetching yay!

This commit is contained in:
Eclypsed
2024-04-05 02:00:17 -04:00
parent 952c8383f9
commit c5408d76b6
20 changed files with 220 additions and 253 deletions

View File

@@ -1,16 +1,14 @@
import { DB, type DBConnectionInfo } from './db'
import { Jellyfin, type JellyfinConnectionInfo } from './jellyfin'
import { YouTubeMusic, type YouTubeMusicConnectionInfo } from './youtube-music'
import { DB, type ConnectionRow } from './db'
import { Jellyfin } from './jellyfin'
import { YouTubeMusic } from './youtube-music'
export type ConnectionInfo = JellyfinConnectionInfo | YouTubeMusicConnectionInfo
const constructConnection = (connectionInfo: DBConnectionInfo): Connection => {
const constructConnection = (connectionInfo: ConnectionRow): Connection => {
const { id, userId, type, service, tokens } = connectionInfo
switch (type) {
case 'jellyfin':
return new Jellyfin(id, userId, service.userId, service.urlOrigin, tokens.accessToken)
return new Jellyfin(id, userId, service.userId, service.serverUrl, tokens.accessToken)
case 'youtube-music':
return new YouTubeMusic(id, userId, service.userId, tokens)
return new YouTubeMusic(id, userId, service.userId, tokens.accessToken, tokens.refreshToken, tokens.expiry)
}
}