|
2 | 2 | import { onMount, tick } from 'svelte' |
3 | 3 | import { browser, dev } from '$app/environment' |
4 | 4 | import { _ } from 'svelte-i18n' |
5 | | - import { pg } from '$lib/postguard' |
6 | | - import { IdentityMismatchError, NetworkError } from '@e4a/pg-js' |
| 5 | + import { getPostGuard } from '$lib/postguard' |
7 | 6 | import type { DecryptFileResult, FriendlySender, InspectResult } from '@e4a/pg-js' |
8 | 7 | import YiviQRCode from '$lib/components/filesharing/YiviQRCode.svelte' |
9 | 8 | import FileList from '$lib/components/filesharing/FileList.svelte' |
|
46 | 45 | async function startDownload() { |
47 | 46 | downloadState = 'Downloading' |
48 | 47 | try { |
| 48 | + const pg = await getPostGuard() |
49 | 49 | opened = pg.open({ uuid }) |
50 | 50 | const info: InspectResult = await opened.inspect() |
51 | 51 |
|
|
55 | 55 |
|
56 | 56 | checkRecipients(info.recipients) |
57 | 57 | } catch (e) { |
| 58 | + const { NetworkError } = await import('@e4a/pg-js') |
58 | 59 | if (e instanceof NetworkError && e.status >= 500) { |
59 | 60 | downloadState = 'ServerError' |
60 | 61 | } else { |
|
107 | 108 | } catch (e) { |
108 | 109 | if (dev) console.error('[download] decrypt error:', e) |
109 | 110 | err = String(e) |
| 111 | + const { IdentityMismatchError, NetworkError } = await import('@e4a/pg-js') |
110 | 112 | if (e instanceof IdentityMismatchError) { |
111 | 113 | downloadState = 'IdentityMismatch' |
112 | 114 | } else if (e instanceof NetworkError && e.status >= 500) { |
|
0 commit comments