Skip to content

Commit d0527ed

Browse files
authored
Merge pull request #41 from whale4113/feat/lujunji/auto-scroll
fix: missing diagrams when downloading long documents fix: pictures and files still download when downloading is canceled
2 parents 1f75205 + c85b721 commit d0527ed

File tree

16 files changed

+582
-163
lines changed

16 files changed

+582
-163
lines changed

.changeset/curvy-carrots-drop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/common': minor
3+
---
4+
5+
feat: add `waitFor()` utility and `imageDataToBlob()` support `onDispose()` option

.changeset/neat-shoes-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/chrome-extension': patch
3+
---
4+
5+
fix: pictures and files still download when downloading is canceled
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/lark': minor
3+
---
4+
5+
feat: support scroll document

.changeset/ten-clocks-attend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/common': minor
3+
---
4+
5+
feat: add `waitForSelector()` utility

.changeset/warm-forks-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/chrome-extension': patch
3+
---
4+
5+
fix: the scroll position of a whiteboard's view element may not be recorded

.changeset/witty-moons-matter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/chrome-extension': patch
3+
---
4+
5+
fix: missing diagrams when downloading long documents

apps/chrome-extension/src/common/legacy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Second } from '@dolphin/common'
12
import { FirstFileSaveOptions } from 'browser-fs-access'
23

34
export const legacyFileSave = (
@@ -19,7 +20,7 @@ export const legacyFileSave = (
1920

2021
// `setTimeout()` due to
2122
// https://github.com/LLK/scratch-gui/issues/1783#issuecomment-426286393
22-
setTimeout(() => URL.revokeObjectURL(a.href), 30 * 1000)
23+
setTimeout(() => URL.revokeObjectURL(a.href), 30 * Second)
2324
},
2425
true,
2526
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
interface Ref<T> {
2+
current: T
3+
}
4+
5+
interface WithSignalOptions {
6+
signal?: AbortSignal
7+
onAbort?: () => void
8+
}
9+
10+
export const withSignal = async <T>(
11+
inner: (abortedRef: Ref<boolean>) => Promise<T> = Promise.resolve,
12+
options: WithSignalOptions = {},
13+
): Promise<T | null> => {
14+
const { signal, onAbort } = options
15+
16+
let ref: Ref<boolean> = { current: false }
17+
const handler = () => {
18+
ref.current = true
19+
20+
signal?.removeEventListener('abort', handler)
21+
22+
onAbort?.()
23+
}
24+
25+
signal?.addEventListener('abort', handler)
26+
27+
let result = null
28+
29+
try {
30+
result = await inner(ref)
31+
} catch (error) {
32+
console.error(error)
33+
}
34+
35+
signal?.removeEventListener('abort', handler)
36+
37+
// @ts-expect-error remove reference
38+
ref = null
39+
40+
return result
41+
}

0 commit comments

Comments
 (0)