fix types

pull/134/head
Alex Kern 12 months ago
parent 2dbe638387
commit cb344d153f
No known key found for this signature in database
GPG Key ID: EF051FACCACBEE25

@ -1,6 +1,6 @@
'use client' 'use client'
import React, { useState, useEffect, useContext, useRef } from 'react' import React, { useState, useEffect, useContext } from 'react'
import Loading from './Loading' import Loading from './Loading'
import Peer from 'peerjs' import Peer from 'peerjs'

@ -17,7 +17,7 @@ const readDirectoryEntries = (reader: any): Promise<any[]> =>
const scanDirectoryEntry = async (entry: any): Promise<File[]> => { const scanDirectoryEntry = async (entry: any): Promise<File[]> => {
const directoryReader = entry.createReader() const directoryReader = entry.createReader()
const result = [] const result: File[] = []
// eslint-disable-next-line no-constant-condition // eslint-disable-next-line no-constant-condition
while (true) { while (true) {
const subentries = await readDirectoryEntries(directoryReader) const subentries = await readDirectoryEntries(directoryReader)

@ -215,9 +215,7 @@ export function useDownloader(uploaderPeerID: string): {
const stopDownload = useCallback(() => { const stopDownload = useCallback(() => {
// TODO(@kern): Continue here with stop / pause logic // TODO(@kern): Continue here with stop / pause logic
if (dataConnection) { if (dataConnection) {
dataConnection.send({ type: MessageType.Pause } as z.infer< dataConnection.send({ type: MessageType.Pause })
typeof Message
>)
dataConnection.close() dataConnection.close()
} }
setIsDownloading(false) setIsDownloading(false)

@ -66,6 +66,10 @@ export const UsePasswordMessage = z.object({
password: z.string(), password: z.string(),
}) })
export const PauseMessage = z.object({
type: z.literal(MessageType.Pause),
})
export const Message = z.discriminatedUnion('type', [ export const Message = z.discriminatedUnion('type', [
RequestInfoMessage, RequestInfoMessage,
InfoMessage, InfoMessage,
@ -75,6 +79,7 @@ export const Message = z.discriminatedUnion('type', [
ErrorMessage, ErrorMessage,
PasswordRequiredMessage, PasswordRequiredMessage,
UsePasswordMessage, UsePasswordMessage,
PauseMessage,
]) ])
export type Message = z.infer<typeof Message> export type Message = z.infer<typeof Message>

Loading…
Cancel
Save