Reverting changes

This commit is contained in:
Eclypsed
2024-02-12 18:04:30 -05:00
parent 8544f66397
commit c365bcc540
2 changed files with 5 additions and 6 deletions

6
src/app.d.ts vendored
View File

@@ -40,7 +40,7 @@ declare global {
interface Connection { interface Connection {
id: string id: string
user: User userId: string
service: Service service: Service
tokens: Tokens tokens: Tokens
} }
@@ -184,8 +184,8 @@ declare global {
} }
interface YTTokens implements Tokens { interface YTTokens implements Tokens {
accessToken: string, accessToken: string
refreshToken: string, refreshToken: string
expiry: number expiry: number
} }

View File

@@ -53,17 +53,16 @@ export class Users {
export class Connections { export class Connections {
static getConnection = (id: string): Connection => { static getConnection = (id: string): Connection => {
const { userId, service, tokens } = db.prepare('SELECT * FROM Connections WHERE id = ?').get(id) as ConnectionsTableSchema const { userId, service, tokens } = db.prepare('SELECT * FROM Connections WHERE id = ?').get(id) as ConnectionsTableSchema
const connection: Connection = { id, user: Users.getUser(userId)!, service: JSON.parse(service), tokens: JSON.parse(tokens) } const connection: Connection = { id, userId, service: JSON.parse(service), tokens: JSON.parse(tokens) }
return connection return connection
} }
static getUserConnections = (userId: string): Connection[] => { static getUserConnections = (userId: string): Connection[] => {
const connectionRows = db.prepare('SELECT * FROM Connections WHERE userId = ?').all(userId) as ConnectionsTableSchema[] const connectionRows = db.prepare('SELECT * FROM Connections WHERE userId = ?').all(userId) as ConnectionsTableSchema[]
const connections: Connection[] = [] const connections: Connection[] = []
const user = Users.getUser(userId)!
connectionRows.forEach((row) => { connectionRows.forEach((row) => {
const { id, service, tokens } = row const { id, service, tokens } = row
connections.push({ id, user, service: JSON.parse(service), tokens: JSON.parse(tokens) }) connections.push({ id, userId, service: JSON.parse(service), tokens: JSON.parse(tokens) })
}) })
return connections return connections
} }