fix: reduce message size for large fonts

This commit is contained in:
ThaUnknown 2024-07-11 19:11:50 +02:00
parent 96cac8180e
commit 087075a9fd
2 changed files with 5 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import { fontRx } from './util.js'
import Metadata from 'matroska-metadata'
import { arr2text } from 'uint8-util'
import { fontRx } from './util.js'
export default class Parser {
parsed = false
@ -33,7 +34,7 @@ export default class Parser {
for (const file of files) {
if (fontRx.test(file.filename) || file.mimetype?.toLowerCase().includes('font')) {
// this is cursed, but required, as capacitor-node's IPC hangs for 2mins when runnig on 32bit android when sending uint8's
this.client.dispatch('file', { data: JSON.stringify([...file.data]) })
this.client.dispatch('file', { data: arr2text(file.data) })
}
}
})

View file

@ -1,4 +1,5 @@
import JASSUB from 'jassub'
import { text2arr } from 'uint8-util'
import { toTS, subRx, videoRx } from './util.js'
import { settings } from '@/modules/settings.js'
import { client } from '@/modules/torrent.js'
@ -41,7 +42,7 @@ export default class Subtitles {
this.timeout = null
this.handleFile = ({ detail }) => {
if (this.selected) {
const uint8 = new Uint8Array(JSON.parse(detail.data))
const uint8 = text2arr(detail.data)
this.fonts.push(uint8)
this.renderer?.addFont(uint8)
}