Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cb8a27b2f | |||
| 8af501de62 | |||
| 68e56eaea0 | |||
| bb747c5f26 | |||
| 58ca227922 | |||
| af3fbcc940 | |||
| 7b8e50aeb2 | |||
| 93e0d266fb | |||
| 457b2be680 | |||
| d6e5961adf | |||
| e08bcd0228 | |||
| 87329397a4 | |||
| 99715b9a67 | |||
| ae971db765 | |||
| 83cd5033b2 | |||
| e9378654d6 | |||
| 1add59f80c | |||
| 7d39aa3422 | |||
| 701d7c4659 | |||
| f288e18baa | |||
| 076cdd650d | |||
| 56efeee5e2 | |||
| 2ffa02c82a | |||
| 35705ff8bf | |||
| 2c60c45022 | |||
| 8b793d0843 | |||
| 96e6baa47b | |||
| 5be7d72011 | |||
| 4881224d2f | |||
| c634d9b1be | |||
| 2e08b90837 | |||
| c28b858030 | |||
| bfde8e60c2 | |||
| 0a00392b65 | |||
| 0f121427fb | |||
| f32ebdec79 | |||
| 4495462f84 | |||
| 89c8e1cb70 | |||
| a086a2ebe0 | |||
| f9cf58ea44 | |||
| 8bf5696d3c | |||
| 80d09a242d | |||
| 5fabad1b5d | |||
| 89509073f5 | |||
| 67375fe2cd | |||
| 4b4f5f9c9a | |||
| e1f75c2c01 |
@@ -88,7 +88,7 @@ jobs:
|
||||
with:
|
||||
expo-token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
|
||||
- uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
@@ -195,7 +195,7 @@ jobs:
|
||||
|
||||
# bundletool needs a JRE. ubuntu-latest ships a default JDK, but pin it explicitly
|
||||
# like the build job so the toolchain is deterministic.
|
||||
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
|
||||
- uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: 🤖 Claude
|
||||
uses: anthropics/claude-code-action@459ad358ae43fea66bfefd0a1f8d840b4b9791fb # v1.0.194
|
||||
uses: anthropics/claude-code-action@e5ad3c7725bc2459721893f88879fef9dbcf97b0 # v1.0.202
|
||||
env:
|
||||
ANTHROPIC_BASE_URL: https://agentgateway.k1.prod.bsky.dev
|
||||
with:
|
||||
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: 🤖 Claude review
|
||||
uses: anthropics/claude-code-action@459ad358ae43fea66bfefd0a1f8d840b4b9791fb # v1.0.194
|
||||
uses: anthropics/claude-code-action@e5ad3c7725bc2459721893f88879fef9dbcf97b0 # v1.0.202
|
||||
env:
|
||||
ANTHROPIC_BASE_URL: https://agentgateway.k1.prod.bsky.dev
|
||||
with:
|
||||
|
||||
@@ -15,7 +15,7 @@ concurrency:
|
||||
|
||||
env:
|
||||
CI: "1"
|
||||
MAESTRO_VERSION: "2.6.1"
|
||||
MAESTRO_VERSION: "2.10.0"
|
||||
MAESTRO_DRIVER_STARTUP_TIMEOUT: "180000"
|
||||
MAESTRO_CLI_NO_ANALYTICS: "1"
|
||||
MAESTRO_CLI_ANALYSIS_NOTIFICATION_DISABLED: "true"
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
expo-token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- name: ☕️ Set up Java 17
|
||||
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "17"
|
||||
@@ -62,12 +62,12 @@ jobs:
|
||||
- name: 🔤 Compile translations
|
||||
uses: ./.github/actions/compile-i18n
|
||||
|
||||
- name: 📥 Install Maestro 2.6.1
|
||||
- name: 📥 Install Maestro 2.10.0
|
||||
run: |
|
||||
echo "Installing Maestro" > artifacts/ios/phase.txt
|
||||
curl -fsSL -o "$RUNNER_TEMP/maestro.zip" \
|
||||
"https://github.com/mobile-dev-inc/Maestro/releases/download/cli-${MAESTRO_VERSION}/maestro.zip"
|
||||
echo "3440825f514f537c6a96bcf5de995780c2a4a7f83a43208fdc95d4f1fecfad3b $RUNNER_TEMP/maestro.zip" \
|
||||
echo "29b675e10cc12080e445e9bfb2e2b4e4dfb9c0f2e30d5884120d258b5e1cd991 $RUNNER_TEMP/maestro.zip" \
|
||||
| shasum -a 256 --check
|
||||
unzip -q "$RUNNER_TEMP/maestro.zip" -d "$RUNNER_TEMP"
|
||||
echo "$RUNNER_TEMP/maestro/bin" >> "$GITHUB_PATH"
|
||||
@@ -176,7 +176,7 @@ jobs:
|
||||
expo-token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- name: ☕️ Set up Java 17
|
||||
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "17"
|
||||
@@ -187,12 +187,12 @@ jobs:
|
||||
- name: 🔤 Compile translations
|
||||
uses: ./.github/actions/compile-i18n
|
||||
|
||||
- name: 📥 Install Maestro 2.6.1
|
||||
- name: 📥 Install Maestro 2.10.0
|
||||
run: |
|
||||
echo "Installing Maestro" > artifacts/android/phase.txt
|
||||
curl -fsSL -o "$RUNNER_TEMP/maestro.zip" \
|
||||
"https://github.com/mobile-dev-inc/Maestro/releases/download/cli-${MAESTRO_VERSION}/maestro.zip"
|
||||
echo "3440825f514f537c6a96bcf5de995780c2a4a7f83a43208fdc95d4f1fecfad3b $RUNNER_TEMP/maestro.zip" \
|
||||
echo "29b675e10cc12080e445e9bfb2e2b4e4dfb9c0f2e30d5884120d258b5e1cd991 $RUNNER_TEMP/maestro.zip" \
|
||||
| shasum -a 256 --check
|
||||
unzip -q "$RUNNER_TEMP/maestro.zip" -d "$RUNNER_TEMP"
|
||||
echo "$RUNNER_TEMP/maestro/bin" >> "$GITHUB_PATH"
|
||||
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
commit_message: Nightly source-language update
|
||||
file_pattern: ./src/locale/locales/en/messages.po
|
||||
- name: 🚀 Push source lang to Crowdin
|
||||
uses: crowdin/github-action@c7af9bc98b01694653031fef2a0dc6c7888ce9bc # v2.17.0
|
||||
uses: crowdin/github-action@8f01d54f70f1713ee3f09d82c2bbb2daeac28689 # v2.17.1
|
||||
with:
|
||||
upload_sources: true
|
||||
upload_sources_args: "-b main"
|
||||
|
||||
@@ -30,6 +30,10 @@ appId: xyz.blueskyweb.app
|
||||
id: "confirmBtn"
|
||||
- tapOn:
|
||||
id: "composerPublishBtn"
|
||||
- extendedWaitUntil:
|
||||
notVisible:
|
||||
id: "composePostView"
|
||||
timeout: 30000
|
||||
- tapOn:
|
||||
id: "e2eRefreshHome"
|
||||
- assertVisible: "Adult Content"
|
||||
|
||||
@@ -60,6 +60,7 @@ appId: xyz.blueskyweb.app
|
||||
- tapOn:
|
||||
id: "onboardingContinue"
|
||||
- assertVisible: "What are your interests?"
|
||||
- tapOn: "Animals"
|
||||
- tapOn:
|
||||
id: "onboardingContinue"
|
||||
- assertVisible: "Suggested for you"
|
||||
|
||||
@@ -41,6 +41,7 @@ appId: xyz.blueskyweb.app
|
||||
- tapOn:
|
||||
id: "onboardingContinue"
|
||||
- assertVisible: "What are your interests?"
|
||||
- tapOn: "Animals"
|
||||
- tapOn:
|
||||
id: "onboardingContinue"
|
||||
- assertVisible: "Suggested for you"
|
||||
|
||||
+15
-27
@@ -3,34 +3,22 @@ appId: xyz.blueskyweb.app
|
||||
- launchApp:
|
||||
appId: "xyz.blueskyweb.app"
|
||||
clearState: true
|
||||
arguments:
|
||||
"-EXDevMenuIsOnboardingFinished": true
|
||||
- runFlow:
|
||||
when:
|
||||
platform: iOS
|
||||
commands:
|
||||
- extendedWaitUntil:
|
||||
visible: "http://localhost:8081"
|
||||
timeout: 60000
|
||||
- tapOn: "http://localhost:8081"
|
||||
- runFlow:
|
||||
when:
|
||||
platform: Android
|
||||
commands:
|
||||
- extendedWaitUntil:
|
||||
visible: "http://10.0.2.2:8081"
|
||||
timeout: 60000
|
||||
- tapOn: "http://10.0.2.2:8081"
|
||||
- extendedWaitUntil:
|
||||
visible: "Continue"
|
||||
timeout: 180000
|
||||
- tapOn: "Continue"
|
||||
- back
|
||||
- extendedWaitUntil:
|
||||
visible:
|
||||
id: e2eProxyHeaderInput
|
||||
timeout: 180000
|
||||
- tapOn:
|
||||
id: e2eProxyHeaderInput
|
||||
- inputText: ${output.result}
|
||||
- pressKey: Enter
|
||||
- extendedWaitUntil:
|
||||
visible: "Sign in"
|
||||
timeout: 180000
|
||||
- retry:
|
||||
maxRetries: 3
|
||||
commands:
|
||||
- tapOn:
|
||||
id: e2eProxyHeaderInput
|
||||
- eraseText
|
||||
- inputText: ${output.result}
|
||||
- pressKey: Enter
|
||||
- extendedWaitUntil:
|
||||
visible:
|
||||
id: e2eSignInAlice
|
||||
timeout: 10000
|
||||
|
||||
@@ -1,13 +1,58 @@
|
||||
import {getLikelyType, LikelyType} from '../../src/lib/link-meta/link-meta'
|
||||
import {
|
||||
getLikelyType,
|
||||
getLinkMeta,
|
||||
LikelyType,
|
||||
} from '../../src/lib/link-meta/link-meta'
|
||||
|
||||
describe('getLikelyType', () => {
|
||||
it('correctly handles non-parsed url', async () => {
|
||||
const output = await getLikelyType('https://example.com')
|
||||
it('correctly handles non-parsed url', () => {
|
||||
const output = getLikelyType('https://example.com')
|
||||
expect(output).toEqual(LikelyType.HTML)
|
||||
})
|
||||
|
||||
it('handles non-string urls without crashing', async () => {
|
||||
const output = await getLikelyType('123')
|
||||
it('handles non-string urls without crashing', () => {
|
||||
const output = getLikelyType('123')
|
||||
expect(output).toEqual(LikelyType.Other)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getLinkMeta', () => {
|
||||
const originalFetch = global.fetch
|
||||
|
||||
afterEach(() => {
|
||||
global.fetch = originalFetch
|
||||
})
|
||||
|
||||
it('fetches metadata for stream.place routes that look like files', async () => {
|
||||
const fetchMock = jest.fn().mockResolvedValue({
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
error: '',
|
||||
description: 'AT Protocol livestreams',
|
||||
image: 'https://stream.place/thumbnail.jpg',
|
||||
title: 'atproto.com on stream.place',
|
||||
}),
|
||||
})
|
||||
global.fetch = fetchMock
|
||||
|
||||
const output = await getLinkMeta('https://stream.place/atproto.com')
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1)
|
||||
expect(output).toMatchObject({
|
||||
description: 'AT Protocol livestreams',
|
||||
image: 'https://stream.place/thumbnail.jpg',
|
||||
likelyType: LikelyType.HTML,
|
||||
title: 'atproto.com on stream.place',
|
||||
})
|
||||
})
|
||||
|
||||
it('skips metadata fetching for direct image URLs', async () => {
|
||||
const fetchMock = jest.fn()
|
||||
global.fetch = fetchMock
|
||||
|
||||
const output = await getLinkMeta('https://example.com/image.JPEG')
|
||||
|
||||
expect(fetchMock).not.toHaveBeenCalled()
|
||||
expect(output).toMatchObject({likelyType: LikelyType.Image})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,6 +20,7 @@ module.exports = function (_config) {
|
||||
|
||||
const IS_TESTFLIGHT = process.env.EXPO_PUBLIC_ENV === 'testflight'
|
||||
const IS_PRODUCTION = process.env.EXPO_PUBLIC_ENV === 'production'
|
||||
const IS_E2E = process.env.EXPO_PUBLIC_ENV === 'e2e'
|
||||
const IS_DEV = !IS_TESTFLIGHT && !IS_PRODUCTION
|
||||
|
||||
const ASSOCIATED_DOMAINS = [
|
||||
@@ -234,6 +235,25 @@ module.exports = function (_config) {
|
||||
checkAutomatically: 'NEVER',
|
||||
},
|
||||
plugins: [
|
||||
[
|
||||
'expo-dev-client',
|
||||
{
|
||||
toolsButton: false,
|
||||
...(IS_E2E
|
||||
? {
|
||||
launchMode: 'most-recent',
|
||||
skipOnboarding: true,
|
||||
showMenuAtLaunch: false,
|
||||
ios: {
|
||||
defaultLaunchURL: 'http://localhost:8081',
|
||||
},
|
||||
android: {
|
||||
defaultLaunchURL: 'http://10.0.2.2:8081',
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
],
|
||||
'expo-video',
|
||||
'expo-localization',
|
||||
'expo-web-browser',
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" d="M20 12a8 8 0 1 0-16 0 8 8 0 0 0 16 0m2 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-10.843.256-.47-3.768a1.324 1.324 0 1 1 2.627 0l-.47 3.768a.85.85 0 0 1-1.687 0M12 17a1.2 1.2 0 1 0 0-2.4 1.2 1.2 0 0 0 0 2.4"/></svg>
|
||||
|
After Width: | Height: | Size: 334 B |
+7
-2
@@ -92,6 +92,7 @@
|
||||
"app.bsky.graph.muteActor",
|
||||
"app.bsky.graph.muteActorList",
|
||||
"app.bsky.graph.muteThread",
|
||||
"app.bsky.graph.referencelistoptout",
|
||||
"app.bsky.graph.searchStarterPacks",
|
||||
"app.bsky.graph.searchStarterPacksV2",
|
||||
"app.bsky.graph.starterpack",
|
||||
@@ -426,7 +427,7 @@
|
||||
},
|
||||
"app.bsky.embed.video": {
|
||||
"uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.embed.video",
|
||||
"cid": "bafyreiaqos23yv3t4ptrxily6s6qea5fcxfjzjlm42zq46xweby2mkgr4m"
|
||||
"cid": "bafyreihoxb7lvczityqcv2s5od3rllmkee7tn3m4qg6wn34kd6m45p6v24"
|
||||
},
|
||||
"app.bsky.feed.defs": {
|
||||
"uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.feed.defs",
|
||||
@@ -538,7 +539,7 @@
|
||||
},
|
||||
"app.bsky.graph.defs": {
|
||||
"uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.graph.defs",
|
||||
"cid": "bafyreifcipomli7yggtl46xufgxlnrw7se6xmsdxmzgfcz2tiu76ljatxm"
|
||||
"cid": "bafyreief2f7zpllyicjugbn7faohmnzwujeiytfzj76uckxmrqmtdvechy"
|
||||
},
|
||||
"app.bsky.graph.follow": {
|
||||
"uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.graph.follow",
|
||||
@@ -632,6 +633,10 @@
|
||||
"uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.graph.muteThread",
|
||||
"cid": "bafyreib6ppci3qzye6wktkm4byxtb5mnl2vg22fm7oawcdvof2tfogx4dy"
|
||||
},
|
||||
"app.bsky.graph.referencelistoptout": {
|
||||
"uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.graph.referencelistoptout",
|
||||
"cid": "bafyreifode2cfu7x7yamiorzg66u46l4zdr2yxmtuoikrup7j2dhwzxf3q"
|
||||
},
|
||||
"app.bsky.graph.searchStarterPacks": {
|
||||
"uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.graph.searchStarterPacks",
|
||||
"cid": "bafyreia446ip6mbnwpml6hlvxab7jtsud7zczde3u6zmnsa3op4bpxu7um"
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
"properties": {
|
||||
"alt": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"description": "Alt text description of the video, for accessibility.",
|
||||
"maxGraphemes": 1000
|
||||
"description": "Alt text description of the video, for accessibility."
|
||||
},
|
||||
"video": {
|
||||
"type": "blob",
|
||||
@@ -51,9 +49,7 @@
|
||||
],
|
||||
"properties": {
|
||||
"alt": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"maxGraphemes": 1000
|
||||
"type": "string"
|
||||
},
|
||||
"cid": {
|
||||
"type": "string",
|
||||
|
||||
@@ -169,6 +169,28 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"knownLikers": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"count",
|
||||
"actors"
|
||||
],
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"actors": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"ref": "app.bsky.actor.defs#profileViewBasic",
|
||||
"type": "ref"
|
||||
},
|
||||
"maxLength": 5,
|
||||
"minLength": 0
|
||||
}
|
||||
},
|
||||
"description": "The post's likers whom you also follow"
|
||||
},
|
||||
"requestLess": {
|
||||
"type": "token",
|
||||
"description": "Request that less content like the given feed item be shown in the feed"
|
||||
@@ -194,6 +216,11 @@
|
||||
"bookmarked": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"knownLikers": {
|
||||
"ref": "#knownLikers",
|
||||
"type": "ref",
|
||||
"description": "This property is present only in selected cases, as an optimization."
|
||||
},
|
||||
"threadMuted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -202,37 +229,10 @@
|
||||
},
|
||||
"embeddingDisabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"knownLikers": {
|
||||
"description": "This property is present only in selected cases, as an optimization.",
|
||||
"type": "ref",
|
||||
"ref": "#knownLikers"
|
||||
}
|
||||
},
|
||||
"description": "Metadata about the requesting account's relationship with the subject content. Only has meaningful content for authed requests."
|
||||
},
|
||||
"knownLikers": {
|
||||
"type": "object",
|
||||
"description": "The post's likers whom you also follow",
|
||||
"required": [
|
||||
"count",
|
||||
"actors"
|
||||
],
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"actors": {
|
||||
"type": "array",
|
||||
"minLength": 0,
|
||||
"maxLength": 5,
|
||||
"items": {
|
||||
"type": "ref",
|
||||
"ref": "app.bsky.actor.defs#profileViewBasic"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"feedViewPost": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
@@ -100,6 +100,11 @@
|
||||
"subject": {
|
||||
"ref": "app.bsky.actor.defs#profileView",
|
||||
"type": "ref"
|
||||
},
|
||||
"subjectOptedOut": {
|
||||
"type": "boolean",
|
||||
"const": true,
|
||||
"description": "Set to true when the subject has opted out of appearing in the reference list. Only set when the viewer owns the list."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -228,6 +233,11 @@
|
||||
"blocked": {
|
||||
"type": "string",
|
||||
"format": "at-uri"
|
||||
},
|
||||
"referenceListOptOut": {
|
||||
"type": "string",
|
||||
"format": "at-uri",
|
||||
"description": "The authenticated viewer's app.bsky.graph.referencelistoptout record URI for this reference list. Only set for reference lists. A client can delete this record to undo the opt-out."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"id": "app.bsky.graph.referencelistoptout",
|
||||
"defs": {
|
||||
"main": {
|
||||
"key": "tid",
|
||||
"type": "record",
|
||||
"record": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"subject",
|
||||
"createdAt"
|
||||
],
|
||||
"properties": {
|
||||
"subject": {
|
||||
"type": "string",
|
||||
"format": "at-uri",
|
||||
"description": "Canonical, DID-based AT URI of the app.bsky.graph.list record from which the author requests omission."
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string",
|
||||
"format": "datetime"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Record requesting that its author be omitted from the public presentation of a reference list. This record is only enforced when the subject list's current purpose is app.bsky.graph.defs#referencelist. AppView indexes at most one record per actor and list pair, and ignores duplicate records."
|
||||
}
|
||||
},
|
||||
"$type": "com.atproto.lexicon.schema",
|
||||
"lexicon": 1
|
||||
}
|
||||
@@ -61,7 +61,8 @@ The component uses a class-based approach to expose imperative methods (`present
|
||||
- Preserves status/nav bar appearance from host activity
|
||||
- **DialogRootViewGroup.kt**: Custom ViewGroup acting as RootView for the dialog
|
||||
- Forwards touch events to React Native event system
|
||||
- Updates shadow node size to match window dimensions
|
||||
- Reports its measured width to `BottomSheetView` so the content canvas can follow it
|
||||
- Also carries the legacy `UIManagerModule.updateNodeSize()` shadow node sizing, which only runs on the old architecture
|
||||
- Based on React Native's ReactModalHostView pattern
|
||||
- **SheetManager.kt**: Singleton for tracking sheets (same pattern as iOS)
|
||||
|
||||
@@ -74,6 +75,24 @@ Both platforms detect content height changes natively without JS bridge round-tr
|
||||
|
||||
This eliminates layout jank when content changes (e.g., keyboard appearance, dynamic content loading).
|
||||
|
||||
### Content Canvas Sizing
|
||||
|
||||
The "canvas" is the size the sheet content is laid out on by Yoga. **On Android the native side owns it**; on iOS it is still sized from JS.
|
||||
|
||||
- **Android**: JS renders unsized `flex: 1` content and `BottomSheetView` pushes the canvas size into the Fabric shadow tree through `ExpoView`'s `setViewSize` state channel (`shadowNodeProxy.setViewSize()`). Only native knows the real sheet frame - Material caps the frame at 640dp on tablets and centers it, and it changes on rotation.
|
||||
- **iOS**: `BottomSheetNativeComponent` sets `height: screenHeight - insets.top` and `width: '100%'` on the native view. Moving iOS onto the same state channel is deferred: it needs on-device iteration on iOS 26 sheet geometry (large-detent and floating-card metrics, where the visible sheet is shorter than the window minus the top inset).
|
||||
|
||||
How the Android path works:
|
||||
|
||||
- The JS style on the native view **must not set `width` or `height`** on Android. `ExpoViewComponentDescriptor::adopt()` only applies the state size on an axis where the style leaves that dimension undefined, so a style dimension would silently win.
|
||||
- The two axes come from different places, and the distinction is load-bearing:
|
||||
- **Width** is authoritatively the dialog container's measured width, reported through `DialogRootViewGroup`'s size-change listener - that is the real sheet width, with the horizontal window insets and Material's 640dp cap already applied. It is seeded from `min(window width, material_bottom_sheet_max_width)` on the first `onLayout` so content has something to lay out in before the dialog exists.
|
||||
- **Height** is always computed natively as `screenHeight - statusBarHeight` (matching the behavior's `expandedOffset`) - the whole expanded frame, **never** the dialog's measured height. The canvas has to be room for the content to grow *into*, because the content's height is what drives the snap points. Sizing it from the dialog's own height is circular: `BottomSheetBehavior` measures the container against the sheet, so the canvas collapses onto the content height and the content is then pinned - extra `ScrollView` padding (the Android keyboard path) or a longer list becomes scroll extent instead of a height change, `OnLayoutChangeListener` never fires, and the sheet stops responding to its content.
|
||||
- Seeding runs once per open cycle - re-seeding would fight the width the dialog reported and the two would push each other back and forth.
|
||||
- Because the content measures 0x0 until that first state commit lands, `present()` bails out early when the content height is still zero. The commit resizes the native view, which re-fires `onLayout`, which re-enters `present()` - so presentation self-retries rather than needing an explicit callback. Full-height sheets skip the check, since they don't need a content measurement.
|
||||
- Rotation is handled by the container push: the RN activity handles configuration changes itself, so the view is never recreated. `screenHeight` is read per access so the computed height follows the rotation, and the container reports the new width (plus a deferred `updateLayout()` to reposition the sheet).
|
||||
- On the **old architecture** there is no state channel (`stateWrapper` is null, so `setViewSize` no-ops) and Android falls back to `DialogRootViewGroup`'s legacy `UIManagerModule.updateNodeSize()` path. The `present()` gate is skipped there for the same reason - nothing would ever resize the view.
|
||||
|
||||
## Props
|
||||
|
||||
```typescript
|
||||
@@ -213,6 +232,10 @@ BottomSheetNativeComponent.dismissAll()
|
||||
|
||||
4. **Layout Updates During Gestures**: Content height changes are deferred during drag gestures to prevent fighting the user's input.
|
||||
|
||||
5. **Tablet Width**: Material caps the sheet frame at 640dp (`material_bottom_sheet_max_width`, the `android:maxWidth` on `Widget.MaterialComponents.BottomSheet`) and centers it horizontally, so on tablets the sheet is narrower than the screen. `BottomSheetView` reads that cap from resources when seeding the canvas width, and the dialog container's measured width then corrects it - see [Content Canvas Sizing](#content-canvas-sizing).
|
||||
|
||||
6. **Rotation**: The RN activity handles configuration changes itself, so a rotation resizes the display without recreating `BottomSheetView`. Screen height is therefore read per access rather than cached, and `maxHeight` is stored unclamped and clamped against the current screen at use time.
|
||||
|
||||
### Platform Differences
|
||||
|
||||
- **cornerRadius**: Applied to sheet on iOS, to content wrapper on Android (Android clips with `overflow: hidden`)
|
||||
|
||||
+158
-24
@@ -21,6 +21,12 @@ import expo.modules.kotlin.AppContext
|
||||
import expo.modules.kotlin.viewevent.EventDispatcher
|
||||
import expo.modules.kotlin.views.ExpoView
|
||||
|
||||
/**
|
||||
* Fallback for Material's `material_bottom_sheet_max_width` dimen (in dp), used only
|
||||
* if the resource lookup fails. 640dp is the value Material ships.
|
||||
*/
|
||||
private const val FALLBACK_MAX_SHEET_WIDTH_DP = 640f
|
||||
|
||||
class BottomSheetView(
|
||||
context: Context,
|
||||
appContext: AppContext,
|
||||
@@ -38,26 +44,30 @@ class BottomSheetView(
|
||||
private var lastObservedContentHeight: Float = 0f
|
||||
private var pendingLayoutUpdate: Boolean = false
|
||||
|
||||
private val screenHeight: Float =
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
// API 35+: edge-to-edge is mandatory, heightPixels is the full display
|
||||
context.resources.displayMetrics.heightPixels
|
||||
.toFloat()
|
||||
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
||||
// API 30-34: heightPixels may exclude nav bar, use currentWindowMetrics
|
||||
val wm = context.getSystemService(Context.WINDOW_SERVICE) as android.view.WindowManager
|
||||
wm.currentWindowMetrics.bounds
|
||||
.height()
|
||||
.toFloat()
|
||||
} else {
|
||||
// API < 30: currentWindowMetrics not available, use getRealSize
|
||||
// which includes system bars (heightPixels may exclude them)
|
||||
val wm = context.getSystemService(Context.WINDOW_SERVICE) as android.view.WindowManager
|
||||
val size = android.graphics.Point()
|
||||
@Suppress("DEPRECATION")
|
||||
wm.defaultDisplay.getRealSize(size)
|
||||
size.y.toFloat()
|
||||
}
|
||||
// Computed per read rather than cached at construction: the RN activity handles
|
||||
// configuration changes itself, so a rotation resizes the display without
|
||||
// recreating this view and a cached value would stay stale for the sheet's life.
|
||||
private val screenHeight: Float
|
||||
get() =
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
// API 35+: edge-to-edge is mandatory, heightPixels is the full display
|
||||
context.resources.displayMetrics.heightPixels
|
||||
.toFloat()
|
||||
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
||||
// API 30-34: heightPixels may exclude nav bar, use currentWindowMetrics
|
||||
val wm = context.getSystemService(Context.WINDOW_SERVICE) as android.view.WindowManager
|
||||
wm.currentWindowMetrics.bounds
|
||||
.height()
|
||||
.toFloat()
|
||||
} else {
|
||||
// API < 30: currentWindowMetrics not available, use getRealSize
|
||||
// which includes system bars (heightPixels may exclude them)
|
||||
val wm = context.getSystemService(Context.WINDOW_SERVICE) as android.view.WindowManager
|
||||
val size = android.graphics.Point()
|
||||
@Suppress("DEPRECATION")
|
||||
wm.defaultDisplay.getRealSize(size)
|
||||
size.y.toFloat()
|
||||
}
|
||||
|
||||
private fun getNavigationBarHeight(): Int {
|
||||
val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
|
||||
@@ -73,6 +83,11 @@ class BottomSheetView(
|
||||
private val onSnapPointChange by EventDispatcher()
|
||||
private val onStateChange by EventDispatcher()
|
||||
|
||||
// Last canvas size (in dp) pushed into the shadow tree, so repeated layout
|
||||
// passes don't spam state updates
|
||||
private var lastPushedCanvasWidth: Float = -1f
|
||||
private var lastPushedCanvasHeight: Float = -1f
|
||||
|
||||
var disableDrag = false
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -99,10 +114,11 @@ class BottomSheetView(
|
||||
field = if (value < 0) 0f else dpToPx(value)
|
||||
}
|
||||
|
||||
var maxHeight = this.screenHeight
|
||||
// Stored unclamped (in px) because screenHeight can change under us on rotation.
|
||||
// The clamp against the screen happens at use time, in getTargetHeight().
|
||||
var maxHeight = Float.MAX_VALUE
|
||||
set(value) {
|
||||
val px = dpToPx(value)
|
||||
field = if (px > this.screenHeight) this.screenHeight else px
|
||||
field = dpToPx(value)
|
||||
}
|
||||
|
||||
private var isOpen: Boolean = false
|
||||
@@ -140,6 +156,38 @@ class BottomSheetView(
|
||||
this.eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(it, this.id)
|
||||
this.dialogRootViewGroup = DialogRootViewGroup(context)
|
||||
this.dialogRootViewGroup.eventDispatcher = this.eventDispatcher
|
||||
|
||||
// The dialog container's measured WIDTH is the authoritative canvas width: it
|
||||
// already accounts for the window's horizontal insets, Material's max-width cap on
|
||||
// tablets and the current rotation. DialogRootViewGroup's own updateNodeSize() path
|
||||
// is a no-op on the new architecture (getNativeModule(UIManagerModule) returns null
|
||||
// under Fabric), so this state channel is what actually gets the width across there.
|
||||
//
|
||||
// Its measured HEIGHT is deliberately ignored - see canvasHeight.
|
||||
this.dialogRootViewGroup.setOnSizeChangeListener(
|
||||
object : DialogRootViewGroup.OnSizeChangeListener {
|
||||
override fun onSizeChange(
|
||||
width: Int,
|
||||
height: Int,
|
||||
) {
|
||||
val density = context.resources.displayMetrics.density
|
||||
pushCanvasSize(width / density, canvasHeight / density)
|
||||
|
||||
// onSizeChanged fires from inside a layout pass, so defer the reposition:
|
||||
// updateLayout() reads child heights that aren't final yet. This is what
|
||||
// makes the sheet settle back into place after a rotation. It no-ops for
|
||||
// fullHeight sheets, which is correct - those are pinned to the expanded
|
||||
// offset either way.
|
||||
if ((isOpen || isOpening) && !isClosing) {
|
||||
post {
|
||||
if ((isOpen || isOpening) && !isClosing) {
|
||||
updateLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
SheetManager.add(this)
|
||||
}
|
||||
@@ -151,9 +199,84 @@ class BottomSheetView(
|
||||
r: Int,
|
||||
b: Int,
|
||||
) {
|
||||
this.seedCanvasSize()
|
||||
this.present()
|
||||
}
|
||||
|
||||
/**
|
||||
* The height, in px, of the canvas the sheet content is laid out on. This is the whole
|
||||
* expanded frame (the behavior's expandedOffset is the status bar height), NOT the
|
||||
* sheet's current height.
|
||||
*
|
||||
* That distinction is the whole ballgame. The content's height is what drives the snap
|
||||
* points, so the canvas has to be room to grow *into*. Sizing the canvas from the
|
||||
* dialog's own measured height is circular - BottomSheetBehavior measures the dialog
|
||||
* container against the sheet, so the canvas collapses onto the content height, and from
|
||||
* then on the content is pinned: extra ScrollView padding (the Android keyboard path) or
|
||||
* a longer list just becomes scroll extent instead of a height change, the
|
||||
* OnLayoutChangeListener never fires, and the sheet stops responding to its content.
|
||||
*/
|
||||
private val canvasHeight: Float
|
||||
get() = screenHeight - getStatusBarHeight()
|
||||
|
||||
/**
|
||||
* JS renders the sheet content unsized, so before the first state commit it measures
|
||||
* 0x0 and present() has no content height to derive snap points from. Seed the canvas
|
||||
* here to kick that off - the dialog container reports the authoritative width later,
|
||||
* via its OnSizeChangeListener.
|
||||
*
|
||||
* Runs at most once per open cycle. It has to: each state commit re-fires onLayout, so
|
||||
* re-seeding would fight the width the dialog reported and the two would push each other
|
||||
* back and forth forever.
|
||||
*
|
||||
* stateWrapper is assigned while Fabric mounts the view, before the first layout pass,
|
||||
* so setViewSize() should already reach the shadow tree from here. On the old
|
||||
* architecture it is null and this no-ops, which is fine: DialogRootViewGroup's legacy
|
||||
* updateNodeSize() path still sizes the content there.
|
||||
*/
|
||||
private fun seedCanvasSize() {
|
||||
if (lastPushedCanvasWidth > 0f) return
|
||||
val density = context.resources.displayMetrics.density
|
||||
val widthPx =
|
||||
minOf(
|
||||
context.resources.displayMetrics.widthPixels
|
||||
.toFloat(),
|
||||
getMaxSheetWidth(),
|
||||
)
|
||||
this.pushCanvasSize(widthPx / density, canvasHeight / density)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of this view's shadow node, which is the canvas the sheet content is
|
||||
* laid out on. Deduped because both onLayout and the dialog container's size changes
|
||||
* can re-report an unchanged size.
|
||||
*/
|
||||
private fun pushCanvasSize(
|
||||
widthDp: Float,
|
||||
heightDp: Float,
|
||||
) {
|
||||
if (widthDp <= 0f || heightDp <= 0f) return
|
||||
if (widthDp == lastPushedCanvasWidth && heightDp == lastPushedCanvasHeight) return
|
||||
lastPushedCanvasWidth = widthDp
|
||||
lastPushedCanvasHeight = heightDp
|
||||
this.shadowNodeProxy.setViewSize(widthDp.toDouble(), heightDp.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Material caps the sheet frame at `material_bottom_sheet_max_width` (the
|
||||
* `android:maxWidth` on `Widget.MaterialComponents.BottomSheet`, which our dialog theme
|
||||
* inherits from) and centers it horizontally, so on tablets the sheet is narrower than
|
||||
* the display. Returns the cap in px.
|
||||
*/
|
||||
private fun getMaxSheetWidth(): Float =
|
||||
try {
|
||||
resources
|
||||
.getDimensionPixelSize(com.google.android.material.R.dimen.material_bottom_sheet_max_width)
|
||||
.toFloat()
|
||||
} catch (e: android.content.res.Resources.NotFoundException) {
|
||||
FALLBACK_MAX_SHEET_WIDTH_DP * context.resources.displayMetrics.density
|
||||
}
|
||||
|
||||
private fun destroy() {
|
||||
this.stopObservingContentHeight()
|
||||
this.isClosing = false
|
||||
@@ -178,6 +301,15 @@ class BottomSheetView(
|
||||
|
||||
val contentHeight = this.getContentHeight()
|
||||
|
||||
// The content is unsized until the canvas size we pushed lands in the shadow tree,
|
||||
// so bail and let this retry itself: the state commit resizes this view, that
|
||||
// re-fires onLayout, and onLayout re-enters present(). Full-height sheets don't
|
||||
// need a content measurement, so they can go ahead immediately.
|
||||
//
|
||||
// Only gate when there is a state channel to wait on. Without one (old architecture)
|
||||
// nothing would ever resize this view, and the sheet would never present.
|
||||
if (stateWrapper != null && !fullHeight && contentHeight <= 0f) return
|
||||
|
||||
var activityWindow: Window? = null
|
||||
var currentContext = context
|
||||
while (currentContext != null) {
|
||||
@@ -425,8 +557,10 @@ class BottomSheetView(
|
||||
|
||||
private fun getTargetHeight(): Float {
|
||||
val contentHeight = this.getContentHeight()
|
||||
// maxHeight is stored unclamped, so clamp it against the current screen here
|
||||
val effectiveMaxHeight = minOf(this.maxHeight, this.screenHeight)
|
||||
return when {
|
||||
contentHeight > maxHeight -> maxHeight
|
||||
contentHeight > effectiveMaxHeight -> effectiveMaxHeight
|
||||
contentHeight < minHeight -> minHeight
|
||||
else -> contentHeight
|
||||
}
|
||||
|
||||
@@ -34,10 +34,6 @@ const IS_IOS15 =
|
||||
Platform.OS === 'ios' &&
|
||||
// semvar - can be 3 segments, so can't use Number(Platform.Version)
|
||||
Number(Platform.Version.split('.').at(0)) < 16
|
||||
// older android versions (15 and below) aren't naturally edge-to-edge
|
||||
// and behave a little differently
|
||||
const IS_NON_E2E_ANDROID =
|
||||
Platform.OS === 'android' && Number(Platform.Version) < 35
|
||||
|
||||
export class BottomSheetNativeComponent extends Component<
|
||||
BottomSheetViewProps,
|
||||
@@ -148,24 +144,35 @@ function BottomSheetNativeComponentInner({
|
||||
const {height: screenHeight} = useWindowDimensions()
|
||||
const isHeightConstrained = maxHeight != null || rest.fullHeight === true
|
||||
|
||||
// sigh... on older Android versions, screenHeight does not include safe area insets
|
||||
// on newer Androids + iOS, it does. we need to find the inner bit + the bottom inset
|
||||
// for the sheet content
|
||||
const sheetHeight = IS_NON_E2E_ANDROID
|
||||
? screenHeight + insets.bottom
|
||||
: screenHeight - insets.top
|
||||
|
||||
return (
|
||||
<NativeView
|
||||
{...rest}
|
||||
maxHeight={maxHeight}
|
||||
onStateChange={onStateChange}
|
||||
ref={nativeViewRef}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
height: sheetHeight,
|
||||
width: '100%',
|
||||
}}
|
||||
/*
|
||||
* On Android the native side owns this view's size - the canvas the sheet
|
||||
* content is laid out on - and pushes it into the Fabric shadow tree through
|
||||
* ExpoView's `setViewSize` state channel. It knows the real sheet frame
|
||||
* (window insets, Material's max-width cap on tablets, rotation), which JS
|
||||
* can only guess at. `width` and `height` must stay unset there:
|
||||
* `ExpoViewComponentDescriptor::adopt()` only applies the state size on an
|
||||
* axis where the style leaves that dimension undefined, so a style dimension
|
||||
* would silently win and clip the content again.
|
||||
*
|
||||
* iOS still sizes the canvas from JS. Moving it onto the same state channel
|
||||
* needs on-device iteration on iOS 26 sheet geometry (large-detent and
|
||||
* floating-card metrics), so it is deferred.
|
||||
*/
|
||||
style={
|
||||
Platform.OS === 'ios'
|
||||
? {
|
||||
position: 'absolute',
|
||||
height: screenHeight - insets.top,
|
||||
width: '100%',
|
||||
}
|
||||
: {position: 'absolute'}
|
||||
}
|
||||
containerBackgroundColor={backgroundColor}>
|
||||
<View
|
||||
style={[
|
||||
|
||||
@@ -317,14 +317,6 @@
|
||||
"count": 4
|
||||
}
|
||||
},
|
||||
"src/components/StarterPack/ShareDialog.tsx": {
|
||||
"typescript/no-floating-promises": {
|
||||
"count": 1
|
||||
},
|
||||
"typescript/require-await": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/components/StarterPack/Wizard/WizardEditListDialog.tsx": {
|
||||
"typescript/no-explicit-any": {
|
||||
"count": 1
|
||||
@@ -557,11 +549,6 @@
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/lib/async/until.ts": {
|
||||
"typescript/no-explicit-any": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/lib/broadcast/stub.ts": {
|
||||
"typescript/no-explicit-any": {
|
||||
"count": 1
|
||||
@@ -1318,11 +1305,6 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/com/composer/drafts/DraftsButton.tsx": {
|
||||
"typescript/no-misused-promises": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/com/composer/drafts/state/queries.ts": {
|
||||
"typescript/no-explicit-any": {
|
||||
"count": 2
|
||||
@@ -1533,11 +1515,6 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/screens/Home.tsx": {
|
||||
"typescript/no-floating-promises": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/screens/ModerationBlockedAccounts.tsx": {
|
||||
"typescript/no-misused-promises": {
|
||||
"count": 3
|
||||
|
||||
+3
-3
@@ -112,7 +112,7 @@
|
||||
"@bsky.app/expo-scroll-edge-effect": "^0.1.9",
|
||||
"@bsky.app/expo-translate-text": "^0.2.9",
|
||||
"@bsky.app/peek-menu": "^0.3.2",
|
||||
"@bsky.app/react-native-uitextview": "^2.7.0",
|
||||
"@bsky.app/react-native-uitextview": "^2.7.1",
|
||||
"@bsky.app/sift": "^0.3.9",
|
||||
"@bsky.app/tapper": "^0.6.1",
|
||||
"@bsky.app/video": "0.3.6",
|
||||
@@ -240,7 +240,7 @@
|
||||
"react-native-pager-view": "6.8.0",
|
||||
"react-native-progress": "^5.0.1",
|
||||
"react-native-qrcode-styled": "^0.3.3",
|
||||
"react-native-reanimated": "~4.5.3",
|
||||
"react-native-reanimated": "~4.6.0",
|
||||
"react-native-safe-area-context": "~5.7.0",
|
||||
"react-native-screens": "4.26.2",
|
||||
"react-native-scroll-forwarder": "link:./modules/react-native-scroll-forwarder",
|
||||
@@ -250,7 +250,7 @@
|
||||
"react-native-web": "^0.21.0",
|
||||
"react-native-web-webview": "^1.0.2",
|
||||
"react-native-webview": "^13.16.1",
|
||||
"react-native-worklets": "0.11.3",
|
||||
"react-native-worklets": "0.12.1",
|
||||
"react-remove-scroll-bar": "^2.3.8",
|
||||
"react-responsive": "^10.0.1",
|
||||
"react-textarea-autosize": "^8.5.3",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 12101e1b954e1a8c7bf7887bef4f4e08fb06a8be..51d7af352a8a222c5320426f376d51c5a173300b 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -170,6 +170,13 @@ var BigDecimal = class BigDecimal {
|
||||
times(y) {
|
||||
const other = BigDecimal._coerce(y);
|
||||
if (this._special || other._special) return this._specialArith(other, "times");
|
||||
+ // Fast path: multiplying by exactly 1 is an identity operation. ECMA-402's
|
||||
+ // ToRawFixed multiplies by roundingIncrement, which defaults to 1, on every
|
||||
+ // format call - without this check that is a full BigInt multiply followed
|
||||
+ // by a trailing-zero strip. BigDecimal is immutable, so returning the
|
||||
+ // existing instance is safe.
|
||||
+ if (other._mantissa === 1n && other._exponent === 0) return this;
|
||||
+ if (this._mantissa === 1n && this._exponent === 0) return other;
|
||||
if (this._mantissa === 0n || other._mantissa === 0n) {
|
||||
const negZero = this._isSignNegative() ? !other._isSignNegative() : other._isSignNegative();
|
||||
return BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
|
||||
@@ -189,6 +196,11 @@ var BigDecimal = class BigDecimal {
|
||||
const negZero = this._isSignNegative() !== other._isSignNegative();
|
||||
return BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
|
||||
}
|
||||
+ // Fast path: dividing by exactly 1 is an identity operation. ECMA-402's
|
||||
+ // ToRawFixed divides by roundingIncrement, which defaults to 1, on every
|
||||
+ // format call - without this check that is a 10^DIV_PRECISION BigInt
|
||||
+ // scale-up, a division, and a trailing-zero strip that undoes the scaling.
|
||||
+ if (other._mantissa === 1n && other._exponent === 0) return this;
|
||||
const [nm, ne] = removeTrailingZeros(this._mantissa * bigintPow10(DIV_PRECISION) / other._mantissa, this._exponent - other._exponent - DIV_PRECISION);
|
||||
return BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
||||
}
|
||||
@@ -1,3 +1,19 @@
|
||||
diff --git a/android/src/main/cpp/worklets/WorkletJSCallInvoker.cpp b/android/src/main/cpp/worklets/WorkletJSCallInvoker.cpp
|
||||
index a2d707ce76ceb35456eb075d06473ac98ad8b5eb..be2e3d66031d2bbd6208a7cdc1700a9daefb1267 100644
|
||||
--- a/android/src/main/cpp/worklets/WorkletJSCallInvoker.cpp
|
||||
+++ b/android/src/main/cpp/worklets/WorkletJSCallInvoker.cpp
|
||||
@@ -24,10 +24,7 @@ namespace expo {
|
||||
return;
|
||||
}
|
||||
|
||||
- workletRuntime->executeSync([func = std::move(func)](jsi::Runtime &rt) -> jsi::Value {
|
||||
- func(rt);
|
||||
- return jsi::Value::undefined();
|
||||
- });
|
||||
+ workletRuntime->runSync(func);
|
||||
}
|
||||
} // namespace expo
|
||||
|
||||
diff --git a/android/src/main/java/expo/modules/kotlin/devtools/ExpoNetworkInspectOkHttpInterceptors.kt b/android/src/main/java/expo/modules/kotlin/devtools/ExpoNetworkInspectOkHttpInterceptors.kt
|
||||
index 47c4d15f6b10bbd77858cfff425cda9a618735b9..afe138d22d566244482498a7be0e14b8454eab96 100644
|
||||
--- a/android/src/main/java/expo/modules/kotlin/devtools/ExpoNetworkInspectOkHttpInterceptors.kt
|
||||
@@ -13,3 +29,16 @@ index 47c4d15f6b10bbd77858cfff425cda9a618735b9..afe138d22d566244482498a7be0e14b8
|
||||
// Check for Content-Type
|
||||
val skipContentTypes = listOf(
|
||||
"text/event-stream", // Server Sent Events
|
||||
diff --git a/ios/WorkletsAdapter/ExpoWorkletsBridgeProvider.mm b/ios/WorkletsAdapter/ExpoWorkletsBridgeProvider.mm
|
||||
index 126545fae12dc3af71e0ea382b976ef430e62d17..d97163a2e9a9db09f43786bc919f2fa229f21901 100644
|
||||
--- a/ios/WorkletsAdapter/ExpoWorkletsBridgeProvider.mm
|
||||
+++ b/ios/WorkletsAdapter/ExpoWorkletsBridgeProvider.mm
|
||||
@@ -233,7 +233,7 @@ - (void)executeWorkletWithRuntimeHandle:(id)runtimeHandle
|
||||
return;
|
||||
}
|
||||
|
||||
- workletRuntime->executeSync([worklet, arguments](jsi::Runtime &rt) -> jsi::Value {
|
||||
+ workletRuntime->runSync([worklet, arguments](jsi::Runtime &rt) -> jsi::Value {
|
||||
return callWorklet(rt, worklet, arguments);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,3 +3,15 @@
|
||||
### Android: bitdrift interceptor
|
||||
|
||||
Fixes an issue where bitdrift's API stream gets blocked by the Expo interceptor used to power the devtools.
|
||||
|
||||
### iOS + Android: worklets `runSync` migration
|
||||
|
||||
Backport of https://github.com/expo/expo/pull/49366 ("[sdk-57] Backport
|
||||
WorkletRuntime runSync migration"). react-native-worklets 0.12 removed the
|
||||
deprecated `WorkletRuntime::executeSync`, so the worklets adapters in
|
||||
`ios/WorkletsAdapter/ExpoWorkletsBridgeProvider.mm` and
|
||||
`android/src/main/cpp/worklets/WorkletJSCallInvoker.cpp` fail to compile
|
||||
against it. The patch swaps both call sites to `runSync` (available since
|
||||
worklets 0.7.0). Required for the react-native-reanimated 4.6.0 /
|
||||
react-native-worklets 0.12.1 upgrade; drop once expo-modules-core ships a
|
||||
version containing that PR.
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
|
||||
index 8603591..20d042b 100644
|
||||
--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
|
||||
+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
|
||||
@@ -62,11 +62,11 @@ class LayoutAnimationsProxyCommon : public facebook::react::MountingOverrideDele
|
||||
const SharedComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const std::shared_ptr<const ContextContainer> &contextContainer,
|
||||
jsi::Runtime &uiRuntime,
|
||||
- const std::shared_ptr<UIScheduler> &uiScheduler
|
||||
+ const std::shared_ptr<UIScheduler> &uiScheduler,
|
||||
+ const std::shared_ptr<facebook::react::UIManager> &uiManager
|
||||
#ifdef ANDROID
|
||||
,
|
||||
const PreserveMountedTagsFunction &filterUnmountedTagsFunction,
|
||||
- const std::shared_ptr<facebook::react::UIManager> &uiManager,
|
||||
const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker
|
||||
#endif
|
||||
)
|
||||
@@ -74,11 +74,11 @@ class LayoutAnimationsProxyCommon : public facebook::react::MountingOverrideDele
|
||||
contextContainer_(contextContainer),
|
||||
componentDescriptorRegistry_(componentDescriptorRegistry),
|
||||
uiRuntime_(uiRuntime),
|
||||
- uiScheduler_(uiScheduler)
|
||||
+ uiScheduler_(uiScheduler),
|
||||
+ uiManager_(uiManager)
|
||||
#ifdef ANDROID
|
||||
,
|
||||
preserveMountedTags_(filterUnmountedTagsFunction),
|
||||
- uiManager_(uiManager),
|
||||
jsInvoker_(jsInvoker)
|
||||
#endif
|
||||
{
|
||||
@@ -98,10 +98,10 @@ class LayoutAnimationsProxyCommon : public facebook::react::MountingOverrideDele
|
||||
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
||||
jsi::Runtime &uiRuntime_;
|
||||
const std::shared_ptr<UIScheduler> uiScheduler_;
|
||||
+ std::shared_ptr<facebook::react::UIManager> uiManager_;
|
||||
PreserveMountedTagsFunction preserveMountedTags_;
|
||||
|
||||
#ifdef ANDROID
|
||||
- std::shared_ptr<facebook::react::UIManager> uiManager_;
|
||||
std::shared_ptr<facebook::react::CallInvoker> jsInvoker_;
|
||||
|
||||
void restoreOpacityInCaseOfFlakyEnteringAnimation(SurfaceId surfaceId) const;
|
||||
diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h
|
||||
index fcc677f..115971a 100644
|
||||
--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h
|
||||
+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h
|
||||
@@ -67,11 +67,11 @@ struct LayoutAnimationsProxy_Experimental : public LayoutAnimationsProxyCommon,
|
||||
const SharedComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const std::shared_ptr<const ContextContainer> &contextContainer,
|
||||
jsi::Runtime &uiRuntime,
|
||||
- const std::shared_ptr<UIScheduler> &uiScheduler
|
||||
+ const std::shared_ptr<UIScheduler> &uiScheduler,
|
||||
+ const std::shared_ptr<UIManager> &uiManager
|
||||
#ifdef ANDROID
|
||||
,
|
||||
const PreserveMountedTagsFunction &filterUnmountedTagsFunction,
|
||||
- const std::shared_ptr<UIManager> &uiManager,
|
||||
const std::shared_ptr<CallInvoker> &jsInvoker
|
||||
#endif
|
||||
)
|
||||
@@ -80,11 +80,11 @@ struct LayoutAnimationsProxy_Experimental : public LayoutAnimationsProxyCommon,
|
||||
componentDescriptorRegistry,
|
||||
contextContainer,
|
||||
uiRuntime,
|
||||
- uiScheduler
|
||||
+ uiScheduler,
|
||||
+ uiManager
|
||||
#ifdef ANDROID
|
||||
,
|
||||
filterUnmountedTagsFunction,
|
||||
- uiManager,
|
||||
jsInvoker
|
||||
#endif
|
||||
),
|
||||
diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
|
||||
index df53d8d..735f138 100644
|
||||
--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
|
||||
+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
+#include <react/renderer/mounting/ShadowTree.h>
|
||||
#include <react/renderer/mounting/ShadowViewMutation.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -60,14 +61,37 @@ std::optional<MountingTransaction> LayoutAnimationsProxy_Legacy::pullTransaction
|
||||
|
||||
parseRemoveMutations(movedViews, mutations, roots);
|
||||
|
||||
- auto shouldAnimate = !surfacesToRemove_.contains(surfaceId);
|
||||
- surfacesToRemove_.erase(surfaceId);
|
||||
+ // Consume the teardown mark only on the transaction that actually clears
|
||||
+ // the root — pulls emitted for animation frames must not eat it early.
|
||||
+ auto shouldAnimate = true;
|
||||
+ const auto removesRootChildren = std::ranges::any_of(mutations, [surfaceId](const auto &mutation) {
|
||||
+ return mutation.type == ShadowViewMutation::Remove && mutation.parentTag == surfaceId;
|
||||
+ });
|
||||
+ if (removesRootChildren) {
|
||||
+ shouldAnimate = surfacesToRemove_.erase(surfaceId) == 0;
|
||||
+ }
|
||||
handleRemovals(filteredMutations, roots, deadNodes, shouldAnimate);
|
||||
|
||||
handleUpdatesAndEnterings(filteredMutations, movedViews, mutations, propsParserContext, surfaceId);
|
||||
|
||||
addOngoingAnimations(surfaceId, filteredMutations);
|
||||
|
||||
+ // The LayoutAnimationDriver can emit a final keyframe update in the same
|
||||
+ // transaction as the deferred Remove/Delete it withheld for a delete
|
||||
+ // animation. We emit removals before updates, so such an update would
|
||||
+ // otherwise reach the mounting layer after its view was deleted.
|
||||
+ std::unordered_set<Tag> deletedTags;
|
||||
+ for (const auto &mutation : filteredMutations) {
|
||||
+ if (mutation.type == ShadowViewMutation::Delete) {
|
||||
+ deletedTags.insert(mutation.oldChildShadowView.tag);
|
||||
+ }
|
||||
+ }
|
||||
+ if (!deletedTags.empty()) {
|
||||
+ std::erase_if(filteredMutations, [&deletedTags](const auto &mutation) {
|
||||
+ return mutation.type == ShadowViewMutation::Update && deletedTags.contains(mutation.newChildShadowView.tag);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
return MountingTransaction{surfaceId, transactionNumber, std::move(filteredMutations), telemetry};
|
||||
}
|
||||
|
||||
@@ -998,23 +1022,22 @@ inline bool MutationNode::isMutationNode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
-// UIManagerAnimationDelegate
|
||||
-
|
||||
-void LayoutAnimationsProxy_Legacy::uiManagerDidConfigureNextLayoutAnimation(
|
||||
- jsi::Runtime &runtime,
|
||||
- const RawValue &config,
|
||||
- const jsi::Value &successCallbackValue,
|
||||
- const jsi::Value &failureCallbackValue) const {}
|
||||
+// UIManagerCommitHook
|
||||
|
||||
-void LayoutAnimationsProxy_Legacy::setComponentDescriptorRegistry(
|
||||
- const SharedComponentDescriptorRegistry &componentDescriptorRegistry) {}
|
||||
-
|
||||
-bool LayoutAnimationsProxy_Legacy::shouldAnimateFrame() const {
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
-void LayoutAnimationsProxy_Legacy::stopSurface(SurfaceId surfaceId) {
|
||||
- surfacesToRemove_.insert(surfaceId);
|
||||
+// Surface teardown commits an empty root (SurfaceHandler::stop) before the
|
||||
+// teardown transaction is pulled — mark it so pullTransaction skips exit
|
||||
+// animations. Reading the ShadowTreeRegistry here instead would deadlock (#8579).
|
||||
+RootShadowNode::Unshared LayoutAnimationsProxy_Legacy::shadowTreeWillCommit(
|
||||
+ const ShadowTree &shadowTree,
|
||||
+ const RootShadowNode::Shared & /*oldRootShadowNode*/,
|
||||
+ const RootShadowNode::Unshared &newRootShadowNode) noexcept {
|
||||
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
||||
+ if (newRootShadowNode->getChildren().empty()) {
|
||||
+ surfacesToRemove_.insert(shadowTree.getSurfaceId());
|
||||
+ } else {
|
||||
+ surfacesToRemove_.erase(shadowTree.getSurfaceId());
|
||||
+ }
|
||||
+ return newRootShadowNode;
|
||||
}
|
||||
|
||||
} // namespace reanimated
|
||||
diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h
|
||||
index 57cc134..1a2966c 100644
|
||||
--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h
|
||||
+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
|
||||
#include <react/renderer/mounting/MountingOverrideDelegate.h>
|
||||
#include <react/renderer/scheduler/Scheduler.h>
|
||||
-#include <react/renderer/uimanager/UIManagerAnimationDelegate.h>
|
||||
#include <react/renderer/uimanager/UIManagerBinding.h>
|
||||
+#include <react/renderer/uimanager/UIManagerCommitHook.h>
|
||||
#include <reanimated/Compat/WorkletsApi.h>
|
||||
#include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
|
||||
#include <reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h>
|
||||
@@ -102,7 +102,7 @@ struct SurfaceContext {
|
||||
};
|
||||
|
||||
struct LayoutAnimationsProxy_Legacy : public LayoutAnimationsProxyCommon,
|
||||
- public UIManagerAnimationDelegate,
|
||||
+ public UIManagerCommitHook,
|
||||
public std::enable_shared_from_this<LayoutAnimationsProxy_Legacy> {
|
||||
mutable std::unordered_map<Tag, std::shared_ptr<Node>> nodeForTag_;
|
||||
mutable std::recursive_mutex mutex;
|
||||
@@ -116,11 +116,11 @@ struct LayoutAnimationsProxy_Legacy : public LayoutAnimationsProxyCommon,
|
||||
const SharedComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const std::shared_ptr<const ContextContainer> &contextContainer,
|
||||
jsi::Runtime &uiRuntime,
|
||||
- const std::shared_ptr<UIScheduler> &uiScheduler
|
||||
+ const std::shared_ptr<UIScheduler> &uiScheduler,
|
||||
+ const std::shared_ptr<UIManager> &uiManager
|
||||
#ifdef ANDROID
|
||||
,
|
||||
const PreserveMountedTagsFunction &filterUnmountedTagsFunction,
|
||||
- const std::shared_ptr<UIManager> &uiManager,
|
||||
const std::shared_ptr<CallInvoker> &jsInvoker
|
||||
#endif
|
||||
)
|
||||
@@ -129,14 +129,19 @@ struct LayoutAnimationsProxy_Legacy : public LayoutAnimationsProxyCommon,
|
||||
componentDescriptorRegistry,
|
||||
contextContainer,
|
||||
uiRuntime,
|
||||
- uiScheduler
|
||||
+ uiScheduler,
|
||||
+ uiManager
|
||||
#ifdef ANDROID
|
||||
,
|
||||
filterUnmountedTagsFunction,
|
||||
- uiManager,
|
||||
jsInvoker
|
||||
#endif
|
||||
) {
|
||||
+ uiManager->registerCommitHook(*this);
|
||||
+ }
|
||||
+
|
||||
+ ~LayoutAnimationsProxy_Legacy() override {
|
||||
+ uiManager_->unregisterCommitHook(*this);
|
||||
}
|
||||
|
||||
void startEnteringAnimation(const int tag, ShadowViewMutation &mutation) const;
|
||||
@@ -206,19 +211,15 @@ struct LayoutAnimationsProxy_Legacy : public LayoutAnimationsProxyCommon,
|
||||
const TransactionTelemetry &telemetry,
|
||||
ShadowViewMutationList mutations) const override;
|
||||
|
||||
- // UIManagerAnimationDelegate
|
||||
-
|
||||
- void uiManagerDidConfigureNextLayoutAnimation(
|
||||
- jsi::Runtime &runtime,
|
||||
- const RawValue &config,
|
||||
- const jsi::Value &successCallbackValue,
|
||||
- const jsi::Value &failureCallbackValue) const override;
|
||||
-
|
||||
- void setComponentDescriptorRegistry(const SharedComponentDescriptorRegistry &componentDescriptorRegistry) override;
|
||||
+ // UIManagerCommitHook
|
||||
|
||||
- bool shouldAnimateFrame() const override;
|
||||
+ void commitHookWasRegistered(const UIManager &uiManager) noexcept override {}
|
||||
+ void commitHookWasUnregistered(const UIManager &uiManager) noexcept override {}
|
||||
|
||||
- void stopSurface(SurfaceId surfaceId) override;
|
||||
+ RootShadowNode::Unshared shadowTreeWillCommit(
|
||||
+ const ShadowTree &shadowTree,
|
||||
+ const RootShadowNode::Shared &oldRootShadowNode,
|
||||
+ const RootShadowNode::Unshared &newRootShadowNode) noexcept override;
|
||||
};
|
||||
|
||||
} // namespace reanimated
|
||||
diff --git a/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp b/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp
|
||||
index 2b68ff7..d08b1ae 100644
|
||||
--- a/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp
|
||||
+++ b/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp
|
||||
@@ -1235,22 +1235,19 @@ void ReanimatedModuleProxy::initializeLayoutAnimationsProxy() {
|
||||
#endif
|
||||
layoutAnimationsProxy_ = std::move(layoutAnimationsProxyExperimental);
|
||||
} else {
|
||||
- auto layoutAnimationsProxyLegacy = std::make_shared<LayoutAnimationsProxy_Legacy>(
|
||||
+ layoutAnimationsProxy_ = std::make_shared<LayoutAnimationsProxy_Legacy>(
|
||||
layoutAnimationsManager_,
|
||||
componentDescriptorRegistry,
|
||||
scheduler->getContextContainer(),
|
||||
getJSIRuntimeFromWorkletRuntime(uiRuntime_),
|
||||
- uiScheduler_
|
||||
+ uiScheduler_,
|
||||
+ uiManager_
|
||||
#ifdef ANDROID
|
||||
,
|
||||
filterUnmountedTagsFunction_,
|
||||
- uiManager_,
|
||||
jsInvoker_
|
||||
#endif
|
||||
);
|
||||
- // TODO (future): support in experimental
|
||||
- uiManager_->setAnimationDelegate(layoutAnimationsProxyLegacy.get());
|
||||
- layoutAnimationsProxy_ = std::move(layoutAnimationsProxyLegacy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
# react-native-reanimated@4.5.3.patch
|
||||
|
||||
Backport of https://github.com/software-mansion/react-native-reanimated/pull/9901
|
||||
("refactor(LayoutAnimations): stop taking over UIManagerAnimationDelegate").
|
||||
|
||||
Reanimated's legacy `LayoutAnimationsProxy_Legacy` registered itself as the
|
||||
`UIManagerAnimationDelegate` only to receive `stopSurface`. Occupying that slot
|
||||
overwrites the `LayoutAnimationDriver` that React Native installs there, which
|
||||
silently breaks `LayoutAnimation.configureNext` for the whole app.
|
||||
|
||||
The patch makes the proxy detect surface teardown itself via a
|
||||
`UIManagerCommitHook` (a commit with an empty root marks the surface in
|
||||
`surfacesToRemove_`), frees the animation-delegate slot, and drops final
|
||||
keyframe `Update` mutations for views deleted in the same transaction (a
|
||||
deterministic `configureNext` delete-animation crash found in this app).
|
||||
`uiManager` moves from Android-only to shared constructor args since the hook
|
||||
registration needs it on both platforms.
|
||||
|
||||
Only the `packages/react-native-reanimated` part of the PR is included (the
|
||||
`apps/fabric-example` hunk is not part of the published package), and the hunks
|
||||
were rebased onto the 4.5.3 release sources.
|
||||
|
||||
Note that upstream's own `pullTransaction` rework in 4.5.3 (the new
|
||||
`reconcileContradictedRemovals`) covers a different case - a `Create`/`Insert`
|
||||
contradicting a *withheld* exit removal - and does not subsume the deleted-tag
|
||||
`Update` filter here, which guards against the `LayoutAnimationDriver` final
|
||||
keyframe. That driver only runs at all once this patch frees the delegate slot.
|
||||
@@ -1,88 +0,0 @@
|
||||
diff --git a/lib/module/threads.js b/lib/module/threads.js
|
||||
index c17e314..71f3cf7 100644
|
||||
--- a/lib/module/threads.js
|
||||
+++ b/lib/module/threads.js
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import { IS_JEST } from './platformChecker';
|
||||
-import { mockedRequestAnimationFrame } from "./runLoop/uiRuntime/mockedRequestAnimationFrame.js";
|
||||
export function scheduleOnUI(worklet, ...args) {
|
||||
enqueueUI(worklet, args);
|
||||
}
|
||||
@@ -23,38 +22,50 @@ export function scheduleOnRN(fun, ...args) {
|
||||
queueMicrotask(args.length ? () => fun(...args) : fun);
|
||||
}
|
||||
export function runOnUIAsync(worklet, ...args) {
|
||||
- return new Promise(resolve => {
|
||||
- enqueueUI(worklet, args, resolve);
|
||||
+ return new Promise((resolve, reject) => {
|
||||
+ enqueueUI(worklet, args, resolve, reject);
|
||||
});
|
||||
}
|
||||
let runOnUIQueue = [];
|
||||
-function enqueueUI(worklet, args, resolve) {
|
||||
- if (IS_JEST) {
|
||||
- mockedRequestAnimationFrame(() => {
|
||||
- const result = worklet(...args);
|
||||
- resolve?.(result);
|
||||
- });
|
||||
- } else {
|
||||
- const job = [worklet, args, resolve];
|
||||
- runOnUIQueue.push(job);
|
||||
- if (runOnUIQueue.length === 1) {
|
||||
+function enqueueUI(worklet, args, resolve, reject) {
|
||||
+ const job = [worklet, args, resolve, reject];
|
||||
+ runOnUIQueue.push(job);
|
||||
+ if (runOnUIQueue.length === 1) {
|
||||
+ if (IS_JEST) {
|
||||
flushUIQueue();
|
||||
+ } else {
|
||||
+ queueMicrotask(flushUIQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
+let offset = 0;
|
||||
function flushUIQueue() {
|
||||
- queueMicrotask(() => {
|
||||
- const queue = runOnUIQueue;
|
||||
- runOnUIQueue = [];
|
||||
- requestAnimationFrameImpl(() => {
|
||||
- queue.forEach(([workletFunction, workletArgs, jobResolve]) => {
|
||||
- const result = workletFunction(...workletArgs);
|
||||
- if (jobResolve) {
|
||||
- jobResolve(result);
|
||||
+ const queue = runOnUIQueue;
|
||||
+ runOnUIQueue = [];
|
||||
+ requestAnimationFrame(() => {
|
||||
+ offset = 0;
|
||||
+ while (queue.length > offset) {
|
||||
+ try {
|
||||
+ drainUIQueue(queue);
|
||||
+ } catch (e) {
|
||||
+ const [, , , jobReject] = queue[offset - 1];
|
||||
+ if (jobReject) {
|
||||
+ jobReject(e);
|
||||
+ } else {
|
||||
+ console.error(e);
|
||||
}
|
||||
- });
|
||||
- });
|
||||
+ }
|
||||
+ }
|
||||
});
|
||||
}
|
||||
-const requestAnimationFrameImpl = !globalThis.requestAnimationFrame ? mockedRequestAnimationFrame : globalThis.requestAnimationFrame;
|
||||
-//# sourceMappingURL=threads.js.map
|
||||
\ No newline at end of file
|
||||
+function drainUIQueue(queue) {
|
||||
+ while (queue.length > offset) {
|
||||
+ const [workletFunction, workletArgs, jobResolve] = queue[offset];
|
||||
+ offset++;
|
||||
+ const result = workletFunction(...workletArgs);
|
||||
+ if (jobResolve) {
|
||||
+ jobResolve(result);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+//# sourceMappingURL=threads.js.map
|
||||
@@ -1,37 +0,0 @@
|
||||
# react-native-worklets@0.11.3.patch
|
||||
|
||||
Backport of https://github.com/software-mansion/react-native-reanimated/pull/10167
|
||||
("fix(Worklets): web scheduleOnUI implementation on errors").
|
||||
|
||||
## The bug
|
||||
|
||||
On web, `scheduleOnUI`/`runOnUI` batch their callbacks per animation frame and
|
||||
run them with `queue.forEach(...)`. If any callback in the batch throws,
|
||||
`forEach` aborts immediately and every callback still queued after it is
|
||||
silently dropped - it never runs, and any `runOnUIAsync` promise for it never
|
||||
resolves or rejects.
|
||||
|
||||
Reanimated's own internals rely on those callbacks running in order (e.g. to
|
||||
populate `frameCallbackRegistry`), so a single throwing worklet in a batch can
|
||||
leave later, unrelated frame callbacks referencing state that was never set
|
||||
up, surfacing as:
|
||||
|
||||
```
|
||||
TypeError: can't access property "startTime", this.frameCallbackRegistry.get(...) is undefined
|
||||
```
|
||||
|
||||
## The fix
|
||||
|
||||
Replace the `forEach` batch runner with a `while` loop (`drainUIQueue`) that
|
||||
tracks its position via an `offset`, wrapped in a `try`/`catch`. A throw now
|
||||
only aborts the *current* callback: the loop resumes at the next queued job
|
||||
instead of abandoning the rest of the batch. Errors are routed to the
|
||||
matching `runOnUIAsync` promise's `reject` (a new second argument threaded
|
||||
through `enqueueUI`) if there is one, or `console.error`-ed otherwise, rather
|
||||
than crashing the whole frame.
|
||||
|
||||
Only `lib/module/threads.js` (the compiled web entry point actually loaded by
|
||||
the app's webpack build) is patched - `src/threads.ts` is unused here since
|
||||
this repo's web build resolves the package's `module` field, and native
|
||||
platforms use the separate `threads.native.ts` implementation untouched by
|
||||
this PR.
|
||||
+175
-174
@@ -23,180 +23,6 @@ index 1b02e8b2d39672063551411d5c403a69b671a869..b3481c1b98b45dea769035140dc2fd8d
|
||||
- (void)setFrame:(CGRect)frame
|
||||
{
|
||||
[super setFrame:frame];
|
||||
diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
|
||||
index a087536f3af0d33b13fe38d8abd1bc6d7935def2..01f5c884ea4772350c0ebe6263723d97632f2b74 100644
|
||||
--- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
|
||||
+++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
|
||||
@@ -396,7 +396,15 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
|
||||
|
||||
MAP_SCROLL_VIEW_PROP(zoomScale);
|
||||
|
||||
- if (oldScrollViewProps.contentInset != newScrollViewProps.contentInset) {
|
||||
+ // When disabling centerContent, reset inset to prop value
|
||||
+ // (enabling is handled automatically by the setCenterContent: setter)
|
||||
+ if (oldScrollViewProps.centerContent && !newScrollViewProps.centerContent) {
|
||||
+ _scrollView.contentInset = RCTUIEdgeInsetsFromEdgeInsets(newScrollViewProps.contentInset);
|
||||
+ }
|
||||
+
|
||||
+ // Only apply contentInset from props if centerContent is disabled
|
||||
+ // When centerContent is enabled, the inset is calculated by centerContentIfNeeded
|
||||
+ if (oldScrollViewProps.contentInset != newScrollViewProps.contentInset && !newScrollViewProps.centerContent) {
|
||||
_scrollView.contentInset = RCTUIEdgeInsetsFromEdgeInsets(newScrollViewProps.contentInset);
|
||||
}
|
||||
|
||||
@@ -523,7 +531,7 @@ - (UIView *)betterHitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
}
|
||||
}
|
||||
|
||||
- return isPointInside ? self : nil;
|
||||
+ return isPointInside ? _scrollView : nil;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1133,6 +1141,11 @@ - (RCTVirtualViewContainerState *)virtualViewContainerState
|
||||
return _virtualViewContainerState;
|
||||
}
|
||||
|
||||
++ (BOOL)shouldBeRecycled
|
||||
+{
|
||||
+ return NO;
|
||||
+}
|
||||
+
|
||||
@end
|
||||
|
||||
Class<RCTComponentViewProtocol> RCTScrollViewCls(void)
|
||||
diff --git a/React/Views/RefreshControl/RCTRefreshControl.h b/React/Views/RefreshControl/RCTRefreshControl.h
|
||||
index ed306d7cadbf36a2fed79be8bd9d68b5dca135bd..d447dad534fefa9fcbdbbde6dcbbdcddadd5a824 100644
|
||||
--- a/React/Views/RefreshControl/RCTRefreshControl.h
|
||||
+++ b/React/Views/RefreshControl/RCTRefreshControl.h
|
||||
@@ -18,6 +18,7 @@ __attribute__((deprecated("This API will be removed along with the legacy archit
|
||||
@property (nonatomic, copy) NSString *title;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onRefresh;
|
||||
@property (nonatomic, weak) UIScrollView *scrollView;
|
||||
+@property (nonatomic, copy) UIColor *customTintColor;
|
||||
|
||||
@end
|
||||
|
||||
diff --git a/React/Views/RefreshControl/RCTRefreshControl.m b/React/Views/RefreshControl/RCTRefreshControl.m
|
||||
index 2dc86e464264c9450eef18d7b153d35bf6a5cc55..6661dc69a04766afa0284d6e83839b219e98cf57 100644
|
||||
--- a/React/Views/RefreshControl/RCTRefreshControl.m
|
||||
+++ b/React/Views/RefreshControl/RCTRefreshControl.m
|
||||
@@ -25,6 +25,7 @@ @implementation RCTRefreshControl {
|
||||
UIColor *_titleColor;
|
||||
CGFloat _progressViewOffset;
|
||||
BOOL _hasMovedToWindow;
|
||||
+ UIColor *_customTintColor;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
@@ -60,6 +61,12 @@ - (void)layoutSubviews
|
||||
_isInitialRender = false;
|
||||
}
|
||||
|
||||
+- (void)didMoveToSuperview
|
||||
+{
|
||||
+ [super didMoveToSuperview];
|
||||
+ [self setTintColor:_customTintColor];
|
||||
+}
|
||||
+
|
||||
- (void)didMoveToWindow
|
||||
{
|
||||
[super didMoveToWindow];
|
||||
@@ -225,6 +232,18 @@ - (void)refreshControlValueChanged
|
||||
}
|
||||
}
|
||||
|
||||
+// Fix for https://github.com/facebook/react-native/issues/43388
|
||||
+// A bug in iOS 17.4 causes the haptic to not play when refreshing if the tintColor
|
||||
+// is set before the refresh control gets added to the scrollview. We'll call this
|
||||
+// function whenever the superview changes. We'll also call it if the value of customTintColor
|
||||
+// changes.
|
||||
+- (void)setTintColor:(UIColor *)tintColor
|
||||
+{
|
||||
+ if ([self.superview isKindOfClass:[UIScrollView class]] && self.tintColor != tintColor) {
|
||||
+ [super setTintColor:tintColor];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
@end
|
||||
|
||||
#endif // RCT_REMOVE_LEGACY_ARCH
|
||||
diff --git a/React/Views/RefreshControl/RCTRefreshControlManager.m b/React/Views/RefreshControl/RCTRefreshControlManager.m
|
||||
index 1e9ff527f4e6691d716da624031113a397876981..44329c5422c6f24d8a437fa35c6f2bad6bf8622b 100644
|
||||
--- a/React/Views/RefreshControl/RCTRefreshControlManager.m
|
||||
+++ b/React/Views/RefreshControl/RCTRefreshControlManager.m
|
||||
@@ -24,11 +24,12 @@ - (UIView *)view
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(onRefresh, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(refreshing, BOOL)
|
||||
-RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
|
||||
RCT_EXPORT_VIEW_PROPERTY(title, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(titleColor, UIColor)
|
||||
RCT_EXPORT_VIEW_PROPERTY(progressViewOffset, CGFloat)
|
||||
|
||||
+RCT_REMAP_VIEW_PROPERTY(tintColor, customTintColor, UIColor)
|
||||
+
|
||||
RCT_EXPORT_METHOD(setNativeRefreshing : (nonnull NSNumber *)viewTag toRefreshing : (BOOL)refreshing)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt
|
||||
index 59775241c80bec99ad3ec080f2425aacc8900c24..426de3aa77cda2032d7b0991e2ca3f8482a438d3 100644
|
||||
--- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt
|
||||
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt
|
||||
@@ -459,6 +459,13 @@ public open class ReactViewGroup public constructor(context: Context?) :
|
||||
inSubviewClippingLoop = true
|
||||
var clippedSoFar = 0
|
||||
for (i in 0..<allChildrenCount) {
|
||||
+ // Reentrant child removal during this loop can compact allChildren and leave a null at
|
||||
+ // an index below allChildrenCount. A null entry means the view is already detached, so
|
||||
+ // treat it as clipped instead of crashing.
|
||||
+ if (childArray[i] == null) {
|
||||
+ clippedSoFar++
|
||||
+ continue
|
||||
+ }
|
||||
try {
|
||||
updateSubviewClipStatus(clippingRect, i, clippedSoFar, excludedViewsSet)
|
||||
} catch (ex: IndexOutOfBoundsException) {
|
||||
@@ -496,7 +503,9 @@ public open class ReactViewGroup public constructor(context: Context?) :
|
||||
) {
|
||||
assertOnUiThread()
|
||||
|
||||
- val child = checkNotNull(allChildren?.get(idx))
|
||||
+ // allChildren can be mutated reentrantly while a clipping pass is running, so a stale
|
||||
+ // index can point at a null slot. Skip it instead of crashing.
|
||||
+ val child = allChildren?.get(idx) ?: return
|
||||
val intersects = clippingRect.intersects(child.left, child.top, child.right, child.bottom)
|
||||
var needUpdateClippingRecursive = false
|
||||
|
||||
diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm
|
||||
index 9b04cadc22f5ae7b105f9f9875a242b53188cf03..b2b27626edc46625ac2372a13977d700948835b6 100644
|
||||
--- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm
|
||||
+++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm
|
||||
@@ -361,7 +361,7 @@ static UIFontDescriptorSystemDesign RCTGetFontDescriptorSystemDesign(NSString *f
|
||||
font = [UIFont fontWithName:fontProperties.family size:effectiveFontSize];
|
||||
if (font != nullptr) {
|
||||
fontNames = [UIFont fontNamesForFamilyName:font.familyName];
|
||||
- fontWeight = (fontWeight != 0.0) ?: RCTGetFontWeight(font);
|
||||
+ fontWeight = (fontWeight != 0.0) ? fontWeight : RCTGetFontWeight(font);
|
||||
} else {
|
||||
// Failback to system font.
|
||||
font = RCTDefaultFontWithFontProperties(fontProperties);
|
||||
diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
|
||||
index ac553045a9c0ce77e288277912538d9e131ebc01..d99c8f4db5a07f1e4ffe7e03ff23adce9c63137b 100644
|
||||
--- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
|
||||
+++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
|
||||
@@ -389,8 +389,9 @@ - (TextMeasurement)_measureTextStorage:(NSTextStorage *)textStorage
|
||||
size.height = enumeratedLinesHeight;
|
||||
}
|
||||
|
||||
- size = (CGSize){ceil(size.width * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor,
|
||||
- ceil(size.height * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor};
|
||||
+ CGFloat epsilon = 0.001;
|
||||
+ size = (CGSize){ceil((size.width + epsilon) * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor,
|
||||
+ ceil((size.height + epsilon) * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor};
|
||||
|
||||
NSRange visibleGlyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
|
||||
|
||||
diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm
|
||||
index 60160efb163d91813fa2ca7ca758b51afcf261e1..fb646fe945ffe4aa4a386f80a1e42a90180691f1 100644
|
||||
--- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm
|
||||
@@ -371,3 +197,178 @@ index 60160efb163d91813fa2ca7ca758b51afcf261e1..fb646fe945ffe4aa4a386f80a1e42a90
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
|
||||
index a087536f3af0d33b13fe38d8abd1bc6d7935def2..01f5c884ea4772350c0ebe6263723d97632f2b74 100644
|
||||
--- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
|
||||
+++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
|
||||
@@ -396,7 +396,15 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
|
||||
|
||||
MAP_SCROLL_VIEW_PROP(zoomScale);
|
||||
|
||||
- if (oldScrollViewProps.contentInset != newScrollViewProps.contentInset) {
|
||||
+ // When disabling centerContent, reset inset to prop value
|
||||
+ // (enabling is handled automatically by the setCenterContent: setter)
|
||||
+ if (oldScrollViewProps.centerContent && !newScrollViewProps.centerContent) {
|
||||
+ _scrollView.contentInset = RCTUIEdgeInsetsFromEdgeInsets(newScrollViewProps.contentInset);
|
||||
+ }
|
||||
+
|
||||
+ // Only apply contentInset from props if centerContent is disabled
|
||||
+ // When centerContent is enabled, the inset is calculated by centerContentIfNeeded
|
||||
+ if (oldScrollViewProps.contentInset != newScrollViewProps.contentInset && !newScrollViewProps.centerContent) {
|
||||
_scrollView.contentInset = RCTUIEdgeInsetsFromEdgeInsets(newScrollViewProps.contentInset);
|
||||
}
|
||||
|
||||
@@ -523,7 +531,7 @@ - (UIView *)betterHitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
}
|
||||
}
|
||||
|
||||
- return isPointInside ? self : nil;
|
||||
+ return isPointInside ? _scrollView : nil;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1133,6 +1141,11 @@ - (RCTVirtualViewContainerState *)virtualViewContainerState
|
||||
return _virtualViewContainerState;
|
||||
}
|
||||
|
||||
++ (BOOL)shouldBeRecycled
|
||||
+{
|
||||
+ return NO;
|
||||
+}
|
||||
+
|
||||
@end
|
||||
|
||||
Class<RCTComponentViewProtocol> RCTScrollViewCls(void)
|
||||
diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
|
||||
index b033b7c71914d287470b7b86bd6bf39d311294ba..7e10dc929147fa4474ca9f955f5cd85d27aea935 100644
|
||||
--- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
|
||||
+++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
|
||||
@@ -827,9 +827,17 @@ static void RCTAddContourEffectToLayer(
|
||||
} else {
|
||||
CGSize imageSize = image.size;
|
||||
UIEdgeInsets imageCapInsets = image.capInsets;
|
||||
+ // The stretchable middle is whatever lies between the cap insets. The image
|
||||
+ // may be larger than capInsets + 1 (its size is ceil'd to whole points), so
|
||||
+ // deriving the middle from the caps rather than assuming a 1pt band keeps
|
||||
+ // the bottom/right caps at their true size. A phantom cap here makes the
|
||||
+ // caps overflow sub-pixel-sized layers (e.g. hairline borders), and the
|
||||
+ // squeezed mesh + nearest-neighbor filtering drops the stroke entirely.
|
||||
CGRect contentsCenter = CGRect{
|
||||
CGPoint{imageCapInsets.left / imageSize.width, imageCapInsets.top / imageSize.height},
|
||||
- CGSize{(CGFloat)1.0 / imageSize.width, (CGFloat)1.0 / imageSize.height}};
|
||||
+ CGSize{
|
||||
+ (imageSize.width - imageCapInsets.left - imageCapInsets.right) / imageSize.width,
|
||||
+ (imageSize.height - imageCapInsets.top - imageCapInsets.bottom) / imageSize.height}};
|
||||
layer.contents = (id)image.CGImage;
|
||||
layer.contentsScale = image.scale;
|
||||
|
||||
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt
|
||||
index 59775241c80bec99ad3ec080f2425aacc8900c24..426de3aa77cda2032d7b0991e2ca3f8482a438d3 100644
|
||||
--- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt
|
||||
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt
|
||||
@@ -459,6 +459,13 @@ public open class ReactViewGroup public constructor(context: Context?) :
|
||||
inSubviewClippingLoop = true
|
||||
var clippedSoFar = 0
|
||||
for (i in 0..<allChildrenCount) {
|
||||
+ // Reentrant child removal during this loop can compact allChildren and leave a null at
|
||||
+ // an index below allChildrenCount. A null entry means the view is already detached, so
|
||||
+ // treat it as clipped instead of crashing.
|
||||
+ if (childArray[i] == null) {
|
||||
+ clippedSoFar++
|
||||
+ continue
|
||||
+ }
|
||||
try {
|
||||
updateSubviewClipStatus(clippingRect, i, clippedSoFar, excludedViewsSet)
|
||||
} catch (ex: IndexOutOfBoundsException) {
|
||||
@@ -496,7 +503,9 @@ public open class ReactViewGroup public constructor(context: Context?) :
|
||||
) {
|
||||
assertOnUiThread()
|
||||
|
||||
- val child = checkNotNull(allChildren?.get(idx))
|
||||
+ // allChildren can be mutated reentrantly while a clipping pass is running, so a stale
|
||||
+ // index can point at a null slot. Skip it instead of crashing.
|
||||
+ val child = allChildren?.get(idx) ?: return
|
||||
val intersects = clippingRect.intersects(child.left, child.top, child.right, child.bottom)
|
||||
var needUpdateClippingRecursive = false
|
||||
|
||||
diff --git a/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSStable.h b/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSStable.h
|
||||
index fdabd7bab1f03966dc04ba9a462465daeccf8ae3..ef70011ee5c270fb2cac52f3a7408d1e87334145 100644
|
||||
--- a/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSStable.h
|
||||
+++ b/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSStable.h
|
||||
@@ -21,6 +21,10 @@ class ReactNativeFeatureFlagsOverridesOSSStable : public ReactNativeFeatureFlags
|
||||
{
|
||||
return true;
|
||||
}
|
||||
+ bool enableSchedulerDelegateInvalidation() override
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
bool useTurboModules() override
|
||||
{
|
||||
return true;
|
||||
diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm
|
||||
index 9b04cadc22f5ae7b105f9f9875a242b53188cf03..b2b27626edc46625ac2372a13977d700948835b6 100644
|
||||
--- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm
|
||||
+++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm
|
||||
@@ -361,7 +361,7 @@ static UIFontDescriptorSystemDesign RCTGetFontDescriptorSystemDesign(NSString *f
|
||||
font = [UIFont fontWithName:fontProperties.family size:effectiveFontSize];
|
||||
if (font != nullptr) {
|
||||
fontNames = [UIFont fontNamesForFamilyName:font.familyName];
|
||||
- fontWeight = (fontWeight != 0.0) ?: RCTGetFontWeight(font);
|
||||
+ fontWeight = (fontWeight != 0.0) ? fontWeight : RCTGetFontWeight(font);
|
||||
} else {
|
||||
// Failback to system font.
|
||||
font = RCTDefaultFontWithFontProperties(fontProperties);
|
||||
diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
|
||||
index ac553045a9c0ce77e288277912538d9e131ebc01..d99c8f4db5a07f1e4ffe7e03ff23adce9c63137b 100644
|
||||
--- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
|
||||
+++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
|
||||
@@ -389,8 +389,9 @@ - (TextMeasurement)_measureTextStorage:(NSTextStorage *)textStorage
|
||||
size.height = enumeratedLinesHeight;
|
||||
}
|
||||
|
||||
- size = (CGSize){ceil(size.width * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor,
|
||||
- ceil(size.height * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor};
|
||||
+ CGFloat epsilon = 0.001;
|
||||
+ size = (CGSize){ceil((size.width + epsilon) * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor,
|
||||
+ ceil((size.height + epsilon) * layoutContext.pointScaleFactor) / layoutContext.pointScaleFactor};
|
||||
|
||||
NSRange visibleGlyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
|
||||
|
||||
diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp
|
||||
index 3e48dabc6fffc246fd0517ef5f3f2b7721115511..ea4ba5fdf359c513a5ca4f0e94492facf4ead221 100644
|
||||
--- a/ReactCommon/react/renderer/uimanager/UIManager.cpp
|
||||
+++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp
|
||||
@@ -530,30 +530,8 @@ std::shared_ptr<const ShadowNode> UIManager::findShadowNodeByTag_DEPRECATED(
|
||||
auto shadowNode = std::shared_ptr<const ShadowNode>{};
|
||||
|
||||
shadowTreeRegistry_.enumerate([&](const ShadowTree& shadowTree, bool& stop) {
|
||||
- // Obtain a pointer to the root node. The flag-gated path uses
|
||||
- // getCurrentRevision() which keeps the root alive via shared_ptr for
|
||||
- // the entire traversal, fixing a use-after-free race condition.
|
||||
- RootShadowNode::Shared rootShadowNodeHolder;
|
||||
- const RootShadowNode* rootShadowNode = nullptr;
|
||||
- if (ReactNativeFeatureFlags::fixFindShadowNodeByTagRaceCondition()) {
|
||||
- rootShadowNodeHolder = shadowTree.getCurrentRevision().rootShadowNode;
|
||||
- rootShadowNode = rootShadowNodeHolder.get();
|
||||
- } else {
|
||||
- // TODO(T257154369): Remove after flag rollout.
|
||||
- // The public interface of `ShadowTree` discourages accessing a stored
|
||||
- // pointer to a root node because of the possible data race.
|
||||
- // To work around this, we ask for a commit and immediately cancel it
|
||||
- // returning `nullptr` instead of a new shadow tree.
|
||||
- // We don't want to add a way to access a stored pointer to a root
|
||||
- // node because this `findShadowNodeByTag` is deprecated. It is only
|
||||
- // added to make migration to the new architecture easier.
|
||||
- shadowTree.tryCommit(
|
||||
- [&](const RootShadowNode& oldRootShadowNode) {
|
||||
- rootShadowNode = &oldRootShadowNode;
|
||||
- return nullptr;
|
||||
- },
|
||||
- {/* default commit options */});
|
||||
- }
|
||||
+ auto rootShadowNodeHolder = shadowTree.getCurrentRevision().rootShadowNode;
|
||||
+ const auto* rootShadowNode = rootShadowNodeHolder.get();
|
||||
|
||||
if (rootShadowNode != nullptr) {
|
||||
const auto& children = rootShadowNode->getChildren();
|
||||
|
||||
@@ -1,10 +1,35 @@
|
||||
# ***This second part of this patch is load bearing, do not remove.***
|
||||
# React Native 0.86 patch notes
|
||||
|
||||
## RefreshControl Patch - iOS 17.4 Haptic Regression
|
||||
## Scheduler delegate invalidation - iOS use-after-free
|
||||
|
||||
Patching `RCTRefreshControl.mm` temporarily to play an impact haptic on refresh when using iOS 17.4 or higher. Since
|
||||
17.4, there has been a regression somewhere causing haptics to not play on iOS on refresh. Should monitor for an update
|
||||
in the RN repo: https://github.com/facebook/react-native/issues/43388
|
||||
Fixes Sentry issue APP-T28X: an `EXC_BAD_ACCESS` in
|
||||
`Scheduler::uiManagerDidFinishTransaction` or
|
||||
`Scheduler::uiManagerDidDispatchCommand` after a queued rendering update
|
||||
outlives its captured raw `SchedulerDelegate` pointer.
|
||||
|
||||
React Native 0.86 contains the invalidation-token guard from
|
||||
facebook/react-native#56680, but `enableSchedulerDelegateInvalidation` is false
|
||||
for the stable release level used by Expo. Override only this flag in
|
||||
`ReactNativeFeatureFlagsOverridesOSSStable` instead of opting the app into all
|
||||
experimental React Native flags.
|
||||
|
||||
**TODO: Remove after upgrading to a React Native release that closes the
|
||||
queued Scheduler delegate lifetime race by default.**
|
||||
|
||||
## UIManager.cpp Patch - Fabric focus navigation use-after-free
|
||||
|
||||
Fixes Sentry issue APP-T4H9: a SIGSEGV in
|
||||
`FabricUIManagerBinding::findNextFocusableElement` during focus navigation.
|
||||
|
||||
React Native 0.86 contains the safe implementation behind
|
||||
`fixFindShadowNodeByTagRaceCondition`, but the public default is false. The
|
||||
fallback captures a raw root shadow-node pointer in `tryCommit` and dereferences
|
||||
it after the lock is released, allowing a concurrent commit or surface stop to
|
||||
free the node first. This backports the final upstream implementation, which
|
||||
holds the current revision's `shared_ptr` for the entire traversal.
|
||||
|
||||
**TODO: Remove after bumping React Native to a release containing
|
||||
facebook/react-native#56850.**
|
||||
|
||||
## RCTPullToRefreshViewComponentView.mm Patch - iOS 17.4+ haptic regression and iOS 26 progressViewOffset cancellation on New Arch
|
||||
|
||||
@@ -30,11 +55,10 @@ home header (home is the only screen passing a non-zero offset). Stock RN appear
|
||||
by accident: its own pre-attach `tintColor` write materialized the content view at origin 0
|
||||
*before* the offset write. Possibly related upstream: react-native#54183.
|
||||
|
||||
**2. Haptic (react-native#43388).** The Paper fix above does not cover Fabric: `updateProps`
|
||||
writes `tintColor` pre-attach, and a tint write on a detached control materializes the content
|
||||
view outside the scroll view, permanently suppressing the trigger haptic on iOS 17.4+ (the
|
||||
creation-time-state story likely explains this too, though the haptic wiring itself is not
|
||||
observable in logs).
|
||||
**2. Haptic (react-native#43388).** Fabric's `updateProps` writes `tintColor` pre-attach. A tint
|
||||
write on a detached control materializes the content view outside the scroll view, permanently
|
||||
suppressing the trigger haptic on iOS 17.4+ (the creation-time-state story likely explains this
|
||||
too, though the haptic wiring itself is not observable in logs).
|
||||
|
||||
**The fix**: both `tintColor` and `progressViewOffset` are parked in the component view
|
||||
(`_pendingTintColor` / `_pendingProgressViewOffset`, no `UIRefreshControl` subclass) and applied
|
||||
@@ -103,6 +127,15 @@ content-less area are attributed to the `UIScrollView`.
|
||||
Issue: https://github.com/facebook/react-native/issues/54123
|
||||
PR: https://github.com/react/react-native/pull/56747
|
||||
|
||||
## RCTScrollViewComponentView.mm Patch - Disable ScrollView component-view recycling on New Arch
|
||||
|
||||
Fabric ScrollView component-view recycling is disabled by returning `NO` from
|
||||
`shouldBeRecycled`. This was added in social-app#8295 to prevent a recycled ScrollView from
|
||||
carrying `contentInset` mutations, such as those made by Reanimated, into the next rendered
|
||||
ScrollView. The original patch also reset the inset in `prepareForRecycle`; that reset no longer
|
||||
survives, leaving the recycling override as the remaining protection. Re-evaluate this hunk when
|
||||
upgrading React Native rather than assuming it belongs to either ScrollView fix above.
|
||||
|
||||
## ReactViewGroup.kt Patch - Fatal "Required value was null" during subview clipping on Android
|
||||
|
||||
Fixes Sentry issue APP-T20Q: `IllegalStateException: Required value was null` thrown by
|
||||
@@ -144,3 +177,22 @@ PR: https://github.com/facebook/react-native/pull/57483
|
||||
|
||||
Issue: https://github.com/react/react-native/issues/53450#issuecomment-3298157830
|
||||
Bandaid fix taken from: https://github.com/react/react-native/commit/581d643a9e59fd88f93757f80194e1efd11bd0e5
|
||||
|
||||
## RCTViewComponentView.mm Patch - Hairline border strokes dropped at certain subpixel Y offsets on New Arch
|
||||
|
||||
Symptom: dividers built as `borderTopWidth: hairlineWidth` vanish on some screens and not
|
||||
others, deterministically by the view's absolute subpixel Y. A background fill of the same
|
||||
geometry always renders.
|
||||
|
||||
Cause: Fabric draws borders as a stretched 9-slice image. The consumer
|
||||
(`RCTAddContourEffectToLayer`) hardcodes the stretchable middle as a 1pt band, which matched
|
||||
the image the producer built until RN 0.81. facebook/react-native#54237 changed the image
|
||||
size to `ceil(insets) + 1 + ceil(insets)` without updating that formula, so for fractional
|
||||
(hairline) insets the labels no longer match the image: transparent filler is treated as a
|
||||
rigid cap, and when squeezed into a one-pixel-tall layer the sampling can land on it instead
|
||||
of the stroke - no line.
|
||||
|
||||
Fix: compute the middle from the cap insets (`size - caps`) instead of assuming 1pt.
|
||||
|
||||
Upstream issue: https://github.com/react/react-native/issues/58054 (repro:
|
||||
https://github.com/abulenok/HairlineBorderRepro, fails identically on 0.86.0 and 0.87.0).
|
||||
|
||||
Generated
+351
-352
File diff suppressed because it is too large
Load Diff
+3
-4
@@ -17,8 +17,8 @@ overrides:
|
||||
'@react-native/normalize-colors': '0.86.0'
|
||||
'@expo/image-utils': '0.8.12'
|
||||
'@types/estree': '1.0.6'
|
||||
'react-native-reanimated': '4.5.3'
|
||||
'react-native-worklets': '0.11.3'
|
||||
'react-native-reanimated': '4.6.0'
|
||||
'react-native-worklets': '0.12.1'
|
||||
'psl': '1.9.0'
|
||||
'@types/psl': '1.1.1'
|
||||
'react-native-screens': '4.26.2'
|
||||
@@ -29,6 +29,7 @@ allowBuilds:
|
||||
'esbuild': false
|
||||
'unrs-resolver': true
|
||||
patchedDependencies:
|
||||
'@formatjs/bigdecimal@0.2.5': patches/@formatjs__bigdecimal@0.2.5.patch
|
||||
'@sentry/expo-upload-sourcemaps@8.18.0': patches/@sentry__expo-upload-sourcemaps@8.18.0.patch
|
||||
'expo-age-range@57.0.2': patches/expo-age-range@57.0.2.patch
|
||||
'expo-haptics@57.0.1': patches/expo-haptics@57.0.1.patch
|
||||
@@ -42,10 +43,8 @@ patchedDependencies:
|
||||
'react-native-drawer-layout@4.2.3': patches/react-native-drawer-layout@4.2.3.patch
|
||||
'react-native-keyboard-controller@1.21.9': patches/react-native-keyboard-controller@1.21.9.patch
|
||||
'react-native-pager-view@6.8.0': patches/react-native-pager-view@6.8.0.patch
|
||||
'react-native-reanimated@4.5.3': patches/react-native-reanimated@4.5.3.patch
|
||||
'react-native-screens@4.26.2': patches/react-native-screens@4.26.2.patch
|
||||
'react-native-svg@15.15.4': patches/react-native-svg@15.15.4.patch
|
||||
react-native-worklets@0.11.3: patches/react-native-worklets@0.11.3.patch
|
||||
'react-native@0.86.0': patches/react-native@0.86.0.patch
|
||||
minimumReleaseAgeExclude:
|
||||
- '@atproto/*'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import {useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {useSessionApi} from '#/state/session'
|
||||
import {Error} from '#/components/Error'
|
||||
import {EmojiSad_Stroke2_Corner0_Rounded as EmojiSadIcon} from '#/components/icons/Emoji'
|
||||
import {useOtherRequiredDataQuery} from '#/ageAssurance/data'
|
||||
import {IS_WEB} from '#/env'
|
||||
|
||||
export function DataUnavailableScreen() {
|
||||
const {t: l} = useLingui()
|
||||
const {logoutCurrentAccount} = useSessionApi()
|
||||
const {isFetching, refetch} = useOtherRequiredDataQuery()
|
||||
|
||||
return (
|
||||
<Error
|
||||
icon={EmojiSadIcon}
|
||||
title={l`Unable to load your account`}
|
||||
message={l`We couldn't load your account settings. Check your internet connection and try again.`}
|
||||
onRetry={() => void refetch()}
|
||||
isRetrying={isFetching}
|
||||
secondaryAction={{
|
||||
label: l`Sign out`,
|
||||
onPress: () => {
|
||||
if (IS_WEB) history.pushState(null, '', '/')
|
||||
logoutCurrentAccount('AgeAssuranceDataUnavailableScreen')
|
||||
},
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {useCallback, useEffect} from 'react'
|
||||
import {useCallback, useEffect, useEffectEvent} from 'react'
|
||||
import {ScrollView, View} from 'react-native'
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
@@ -76,7 +76,7 @@ export function NoAccessScreen() {
|
||||
const geolocationString = createGeolocationString(geolocation, i18n.locale)
|
||||
const isUsingGPS = !!geolocation.deviceGeolocation?.countryCode && IS_NATIVE
|
||||
|
||||
useEffect(() => {
|
||||
const onShown = useEffectEvent(() => {
|
||||
// just counting overall hits here
|
||||
ax.metric(`blockedGeoOverlay:shown`, {})
|
||||
ax.metric(`ageAssurance:noAccessScreen:shown`, {
|
||||
@@ -85,8 +85,10 @@ export function NoAccessScreen() {
|
||||
hasDeclaredAge,
|
||||
canUpdateBirthday,
|
||||
})
|
||||
// TODO This can be cleaned up with useEffectEvent once we're on 19.2
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
onShown()
|
||||
}, [])
|
||||
|
||||
const onPressLogout = useCallback(() => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {focusManager, QueryClient, useQuery} from '@tanstack/react-query'
|
||||
import {persistQueryClient} from '@tanstack/react-query-persist-client'
|
||||
import debounce from 'lodash.debounce'
|
||||
|
||||
import {networkRetry} from '#/lib/async/retry'
|
||||
import {isRetryableRequestError, networkRetry} from '#/lib/async/retry'
|
||||
import {createPersistedQueryStorage} from '#/lib/persisted-query-storage'
|
||||
import {getAge} from '#/lib/strings/time'
|
||||
import {
|
||||
@@ -347,9 +347,15 @@ export type OtherRequiredData = {
|
||||
birthdate: string | undefined
|
||||
actorDeclaration?: chat.bsky.actor.declaration.Main
|
||||
}
|
||||
export type OtherRequiredDataStatus = 'pending' | 'error' | 'success'
|
||||
const otherRequiredDataRetryOptions = {
|
||||
retry: (failureCount: number, error: unknown) =>
|
||||
failureCount < 2 && isRetryableRequestError(error),
|
||||
}
|
||||
export function createOtherRequiredDataQueryKey({did}: {did: string}) {
|
||||
return ['otherRequiredData', did]
|
||||
}
|
||||
|
||||
async function getOtherRequiredData({
|
||||
accountClient,
|
||||
}: {
|
||||
@@ -455,10 +461,11 @@ export async function prefetchOtherRequiredData({
|
||||
|
||||
try {
|
||||
logger.debug(`prefetchOtherRequiredData: resolving...`)
|
||||
const res = await networkRetry(3, () =>
|
||||
getOtherRequiredData({accountClient}),
|
||||
)
|
||||
qc.setQueryData<OtherRequiredData>(qk, res)
|
||||
await qc.fetchQuery({
|
||||
...otherRequiredDataRetryOptions,
|
||||
queryKey: qk,
|
||||
queryFn: () => getOtherRequiredData({accountClient}),
|
||||
})
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
logger.warn(`prefetchOtherRequiredData: failed`, {
|
||||
@@ -490,12 +497,14 @@ export function useOtherRequiredDataQuery() {
|
||||
const did = accountClient.did
|
||||
return useQuery(
|
||||
{
|
||||
...otherRequiredDataRetryOptions,
|
||||
enabled: !!did,
|
||||
initialData: () => {
|
||||
if (!did) return
|
||||
return getOtherRequiredDataFromCache({did})
|
||||
},
|
||||
queryKey: createOtherRequiredDataQueryKey({did: did!}),
|
||||
retryOnMount: false,
|
||||
async queryFn() {
|
||||
return getOtherRequiredData({accountClient})
|
||||
},
|
||||
@@ -722,6 +731,11 @@ export type AgeAssuranceServerData = {
|
||||
*/
|
||||
state: app.bsky.ageassurance.defs.State | undefined
|
||||
metadata: AgeAssuranceMetadata | undefined
|
||||
/**
|
||||
* Whether the account data needed to compute age assurance is available.
|
||||
* A successful response without a birthdate is still `success`.
|
||||
*/
|
||||
otherRequiredDataStatus: OtherRequiredDataStatus
|
||||
/**
|
||||
* The native on-device age signals for the region the user is currently in,
|
||||
* if they've granted access there. Already resolved from the region-keyed
|
||||
@@ -739,6 +753,7 @@ const AgeAssuranceServerDataContext = createContext<AgeAssuranceServerData>({
|
||||
declaredAge: undefined,
|
||||
birthdate: undefined,
|
||||
},
|
||||
otherRequiredDataStatus: 'pending',
|
||||
deviceSignals: undefined,
|
||||
})
|
||||
export function useAgeAssuranceServerDataContext() {
|
||||
@@ -752,7 +767,18 @@ export function AgeAssuranceServerDataProvider({
|
||||
const {data: config} = useConfigQuery()
|
||||
const serverState = useServerStateQuery()
|
||||
const {state, metadata} = serverState.data || {}
|
||||
const {data} = useOtherRequiredDataQuery()
|
||||
const {data, errorUpdatedAt, status} = useOtherRequiredDataQuery()
|
||||
/*
|
||||
* A data-less query returns to `pending` and clears `error` while refetching,
|
||||
* but retains `errorUpdatedAt`. Keep the error screen mounted until data
|
||||
* loads successfully.
|
||||
*/
|
||||
const otherRequiredDataStatus: OtherRequiredDataStatus =
|
||||
data !== undefined
|
||||
? 'success'
|
||||
: status === 'error' || errorUpdatedAt > 0
|
||||
? 'error'
|
||||
: 'pending'
|
||||
// `select` resolves the cached region-keyed map to the current region.
|
||||
const {data: deviceSignals} = useDeviceSignalsQuery()
|
||||
const ctx = useMemo(
|
||||
@@ -767,9 +793,10 @@ export function AgeAssuranceServerDataProvider({
|
||||
: undefined,
|
||||
birthdate: data?.birthdate,
|
||||
},
|
||||
otherRequiredDataStatus,
|
||||
deviceSignals,
|
||||
}),
|
||||
[config, state, data, metadata, deviceSignals],
|
||||
[config, state, data, metadata, otherRequiredDataStatus, deviceSignals],
|
||||
)
|
||||
return (
|
||||
<AgeAssuranceServerDataContext.Provider value={ctx}>
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import {computeAgeAssuranceState} from '#/ageAssurance/state'
|
||||
import {AgeAssuranceAccess, AgeAssuranceStatus} from '#/ageAssurance/types'
|
||||
|
||||
jest.mock('#/ageAssurance/data', () => ({}))
|
||||
jest.mock('#/ageAssurance/logger', () => ({
|
||||
logger: {
|
||||
debug: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
},
|
||||
}))
|
||||
jest.mock('#/state/session', () => ({}))
|
||||
|
||||
const geolocation = {
|
||||
countryCode: undefined,
|
||||
regionCode: undefined,
|
||||
}
|
||||
|
||||
describe('computeAgeAssuranceState', () => {
|
||||
it('computes access while required account data is pending', () => {
|
||||
expect(
|
||||
computeAgeAssuranceState({
|
||||
hasSession: true,
|
||||
geolocation,
|
||||
config: {regions: []},
|
||||
otherRequiredDataStatus: 'pending',
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: AgeAssuranceStatus.Unknown,
|
||||
access: AgeAssuranceAccess.None,
|
||||
})
|
||||
})
|
||||
|
||||
it('denies access when required account data fails', () => {
|
||||
expect(
|
||||
computeAgeAssuranceState({
|
||||
hasSession: true,
|
||||
geolocation,
|
||||
config: {regions: []},
|
||||
otherRequiredDataStatus: 'error',
|
||||
}),
|
||||
).toEqual({
|
||||
status: AgeAssuranceStatus.Unknown,
|
||||
access: AgeAssuranceAccess.None,
|
||||
error: 'account-data',
|
||||
})
|
||||
})
|
||||
|
||||
it('computes access after a successful response without a birthdate', () => {
|
||||
expect(
|
||||
computeAgeAssuranceState({
|
||||
hasSession: true,
|
||||
geolocation,
|
||||
config: {regions: []},
|
||||
metadata: {birthdate: undefined},
|
||||
otherRequiredDataStatus: 'success',
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: AgeAssuranceStatus.Unknown,
|
||||
access: AgeAssuranceAccess.None,
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves authoritative terminal server state without account data', () => {
|
||||
expect(
|
||||
computeAgeAssuranceState({
|
||||
hasSession: true,
|
||||
geolocation: {countryCode: 'AA', regionCode: undefined},
|
||||
config: {
|
||||
regions: [
|
||||
{
|
||||
countryCode: 'AA',
|
||||
minAccessAge: 13,
|
||||
rules: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
state: {status: 'blocked', access: 'none'},
|
||||
otherRequiredDataStatus: 'error',
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: AgeAssuranceStatus.Blocked,
|
||||
access: AgeAssuranceAccess.None,
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
getDeviceSignalsFromCacheForRegion,
|
||||
getOtherRequiredDataFromCache,
|
||||
getServerStateFromCache,
|
||||
type OtherRequiredDataStatus,
|
||||
useAgeAssuranceServerDataContext,
|
||||
} from '#/ageAssurance/data'
|
||||
import {logger} from '#/ageAssurance/logger'
|
||||
@@ -35,12 +36,13 @@ import {device} from '#/storage'
|
||||
* server state before computing access based on AA config from the server +
|
||||
* geolocation and other data.
|
||||
*/
|
||||
function computeAgeAssuranceState({
|
||||
export function computeAgeAssuranceState({
|
||||
hasSession,
|
||||
geolocation,
|
||||
config,
|
||||
state,
|
||||
metadata,
|
||||
otherRequiredDataStatus,
|
||||
deviceSignals,
|
||||
}: {
|
||||
hasSession: boolean
|
||||
@@ -48,6 +50,7 @@ function computeAgeAssuranceState({
|
||||
config?: app.bsky.ageassurance.defs.Config
|
||||
state?: app.bsky.ageassurance.defs.State
|
||||
metadata?: AgeAssuranceMetadata
|
||||
otherRequiredDataStatus: OtherRequiredDataStatus
|
||||
deviceSignals?: AgeRange.AgeRangeResponse
|
||||
}) {
|
||||
/**
|
||||
@@ -93,6 +96,14 @@ function computeAgeAssuranceState({
|
||||
}
|
||||
}
|
||||
|
||||
if (otherRequiredDataStatus === 'error') {
|
||||
return {
|
||||
status: AgeAssuranceStatus.Unknown,
|
||||
access: AgeAssuranceAccess.None,
|
||||
error: 'account-data' as const,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, we need to compute the access based on the latest data. For
|
||||
* accounts with an accurate birthdate, our default fallback rules should
|
||||
@@ -177,6 +188,7 @@ export function unsafeGetAndComputeAgeAssurance({did}: {did: string}) {
|
||||
geolocation,
|
||||
state: state.state,
|
||||
metadata,
|
||||
otherRequiredDataStatus: 'success',
|
||||
deviceSignals,
|
||||
})
|
||||
|
||||
@@ -194,7 +206,7 @@ export function unsafeGetAndComputeAgeAssurance({did}: {did: string}) {
|
||||
export function useAgeAssuranceState(): AgeAssuranceState {
|
||||
const {hasSession} = useSession()
|
||||
const geolocation = useGeolocation()
|
||||
const {config, state, metadata, deviceSignals} =
|
||||
const {config, state, metadata, otherRequiredDataStatus, deviceSignals} =
|
||||
useAgeAssuranceServerDataContext()
|
||||
|
||||
return useMemo(
|
||||
@@ -205,9 +217,18 @@ export function useAgeAssuranceState(): AgeAssuranceState {
|
||||
geolocation,
|
||||
state,
|
||||
metadata,
|
||||
otherRequiredDataStatus,
|
||||
deviceSignals,
|
||||
}),
|
||||
[hasSession, geolocation, config, state, metadata, deviceSignals],
|
||||
[
|
||||
hasSession,
|
||||
geolocation,
|
||||
config,
|
||||
state,
|
||||
metadata,
|
||||
otherRequiredDataStatus,
|
||||
deviceSignals,
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ export type AgeAssuranceState = {
|
||||
lastInitiatedAt?: string
|
||||
status: AgeAssuranceStatus
|
||||
access: AgeAssuranceAccess
|
||||
error?: 'config' // maybe other specific cases in the future
|
||||
isLoading?: boolean
|
||||
error?: 'config' | 'account-data'
|
||||
}
|
||||
|
||||
export type AgeAssuranceFlags = {
|
||||
|
||||
+15
-14
@@ -1,5 +1,3 @@
|
||||
import {useMemo} from 'react'
|
||||
|
||||
import {type Breakpoint, useBreakpoints} from '#/alf/breakpoints'
|
||||
import * as tokens from '#/alf/tokens'
|
||||
|
||||
@@ -44,23 +42,26 @@ export function useGutters([top, right, bottom, left]: [
|
||||
Gutter,
|
||||
Gutter,
|
||||
]): Gutters
|
||||
export function useGutters([top, right, bottom, left]: Gutter[]) {
|
||||
export function useGutters(gutter: Gutter[]) {
|
||||
const {activeBreakpoint} = useBreakpoints()
|
||||
/*
|
||||
* Destructured in the body rather than the parameter list: these are
|
||||
* reassigned below to fill in the CSS-shorthand forms, and React Compiler
|
||||
* cannot lower a reassigned destructured parameter.
|
||||
*/
|
||||
let [top, right, bottom, left] = gutter
|
||||
if (right === undefined) {
|
||||
right = bottom = left = top
|
||||
} else if (bottom === undefined) {
|
||||
bottom = top
|
||||
left = right
|
||||
}
|
||||
return useMemo(() => {
|
||||
return {
|
||||
paddingTop: top === 0 ? 0 : gutters[top][activeBreakpoint || 'default'],
|
||||
paddingRight:
|
||||
right === 0 ? 0 : gutters[right][activeBreakpoint || 'default'],
|
||||
paddingBottom:
|
||||
bottom === 0 ? 0 : gutters[bottom][activeBreakpoint || 'default'],
|
||||
paddingLeft:
|
||||
left === 0 ? 0 : gutters[left][activeBreakpoint || 'default'],
|
||||
}
|
||||
}, [activeBreakpoint, top, right, bottom, left])
|
||||
return {
|
||||
paddingTop: top === 0 ? 0 : gutters[top][activeBreakpoint || 'default'],
|
||||
paddingRight:
|
||||
right === 0 ? 0 : gutters[right][activeBreakpoint || 'default'],
|
||||
paddingBottom:
|
||||
bottom === 0 ? 0 : gutters[bottom][activeBreakpoint || 'default'],
|
||||
paddingLeft: left === 0 ? 0 : gutters[left][activeBreakpoint || 'default'],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,21 +77,19 @@ export function getFeatures() {
|
||||
|
||||
export function getFeatureDescription(feature: Features, i18n: I18n) {
|
||||
switch (feature) {
|
||||
case Features.CanonicalPostNumberingEnable:
|
||||
case Features.PostFeedKnownLikersEnable:
|
||||
return {
|
||||
key: feature,
|
||||
name: i18n._(
|
||||
msg({
|
||||
message: 'Thread numbering',
|
||||
comment:
|
||||
'Name for a feature flag (See numbered badges (1/3, 2/3, etc.) on posts in a thread by the same author.)',
|
||||
message: 'Social proofing on posts',
|
||||
comment: 'Name for a feature flag',
|
||||
}),
|
||||
),
|
||||
description: i18n._(
|
||||
msg({
|
||||
message:
|
||||
'See numbered badges (1/3, 2/3, etc.) on posts in a thread by the same author.',
|
||||
comment: 'Description of a feature flag (Thread numbering)',
|
||||
message: 'Spot posts your friends and follows have liked.',
|
||||
comment: 'Description of a feature flag (Social proofing on posts)',
|
||||
}),
|
||||
),
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ export enum Features {
|
||||
GroupChatsDisable = 'group_chats:disable',
|
||||
ComposerLanguageDetectionEnable = 'composer:language_detection:enable',
|
||||
PostGalleryEmbedEnable = 'post_gallery_embed:enable',
|
||||
PostFeedKnownLikersEnable = 'post_feed:known_likers:enable',
|
||||
PostThreadKnownLikersEnable = 'post_thread:known_likers:enable',
|
||||
CustomLogoJapanEnable = 'custom_logo:japan:enable',
|
||||
SearchStarterPacksV2Enable = 'search_starter_packs_v2:enable',
|
||||
FollowSortEnable = 'follow_sort:enable',
|
||||
OnboardingInterestsRequiredEnable = 'onboarding:interests:required:enable',
|
||||
CanonicalPostNumberingEnable = 'canonical_post_numbering:enable',
|
||||
ContentVisibilitySettingsEnable = 'content_visibility_settings:enable',
|
||||
ModerationInboxEnable = 'moderation_inbox:enable',
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ const Context = createContext<AnalyticsBaseContextType>({
|
||||
geolocation: device.get(['geolocationServiceResponse']) || {
|
||||
countryCode: '',
|
||||
regionCode: '',
|
||||
city: '',
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -181,6 +182,7 @@ export function AnalyticsContext({
|
||||
}
|
||||
const deviceId = useDeviceId() ?? 'unknown'
|
||||
const sessionId = useSessionId()
|
||||
// only IP based, never GPS
|
||||
const geolocation = useGeolocationServiceResponse()
|
||||
const parentContext = useContext(Context)
|
||||
/*
|
||||
|
||||
@@ -44,6 +44,7 @@ export type Events = {
|
||||
| 'SignupQueued'
|
||||
| 'Deactivated'
|
||||
| 'Takendown'
|
||||
| 'AgeAssuranceDataUnavailableScreen'
|
||||
| 'AgeAssuranceNoAccessScreen'
|
||||
scope: 'current' | 'every'
|
||||
}
|
||||
@@ -450,6 +451,7 @@ export type Events = {
|
||||
'post:view': {
|
||||
uri: string
|
||||
authorDid: string
|
||||
isReply: boolean
|
||||
logContext:
|
||||
| 'FeedItem'
|
||||
| 'PostThreadItem'
|
||||
@@ -703,6 +705,7 @@ export type Events = {
|
||||
}
|
||||
'starterPack:removeUser': {
|
||||
starterPack?: string
|
||||
context?: 'opt-out'
|
||||
}
|
||||
'starterPack:share': {
|
||||
starterPack: string
|
||||
@@ -715,6 +718,10 @@ export type Events = {
|
||||
count: number
|
||||
}
|
||||
'starterPack:delete': {}
|
||||
'starterPack:optOut': {
|
||||
starterPack: string
|
||||
action: 'optOut' | 'undo'
|
||||
}
|
||||
'starterPack:create': {
|
||||
setName: boolean
|
||||
setDescription: boolean
|
||||
@@ -1396,6 +1403,41 @@ export type Events = {
|
||||
playlist: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The playable video was meaningfully visible. This is an exposure event,
|
||||
* not proof that playback started. Fires once per mounted video item.
|
||||
*/
|
||||
'video:impression': {
|
||||
postUri?: string
|
||||
postAuthorDid?: string
|
||||
context: 'embed' | 'immersiveFeed'
|
||||
presentation: 'video' | 'gif'
|
||||
}
|
||||
/**
|
||||
* Playback advanced far enough to render the first frame. Preloading and
|
||||
* merely becoming active do not count. Fires once per mounted video item;
|
||||
* automatic loops do not produce another event.
|
||||
*/
|
||||
'video:playback:start': {
|
||||
postUri?: string
|
||||
postAuthorDid?: string
|
||||
context: 'embed' | 'immersiveFeed'
|
||||
presentation: 'video' | 'gif'
|
||||
autoplay: boolean
|
||||
}
|
||||
/**
|
||||
* The user activated a third-party media player. Cross-origin players do
|
||||
* not expose confirmed playback consistently, so this must not be treated
|
||||
* as equivalent to video:playback:start without an explicit methodology.
|
||||
*/
|
||||
'externalEmbed:playerActivated': {
|
||||
postUri?: string
|
||||
postAuthorDid?: string
|
||||
source: string
|
||||
playerType: string
|
||||
mediaType: 'video' | 'audio' | 'gif' | 'other'
|
||||
}
|
||||
|
||||
// === Video upload funnel (Frontend Spec section D) ===
|
||||
// Every event carries uploadId (client-generated UUID, ties one upload
|
||||
// session end-to-end) + engine (compression engine id, e.g.
|
||||
|
||||
@@ -11,14 +11,18 @@ import {
|
||||
* Thin `useMemo` wrapper that marks the metadata as memoized and provides a
|
||||
* type guard.
|
||||
*/
|
||||
export function useMeta(metadata?: MergeableMetadata) {
|
||||
const m = useMemo(() => metadata, [metadata])
|
||||
if (!m) return
|
||||
function markMemoized<T extends MergeableMetadata>(m: T): T {
|
||||
// @ts-expect-error
|
||||
m.__meta = true
|
||||
return m
|
||||
}
|
||||
|
||||
export function useMeta(metadata?: MergeableMetadata) {
|
||||
const m = useMemo(() => metadata, [metadata])
|
||||
if (!m) return
|
||||
return markMemoized(m)
|
||||
}
|
||||
|
||||
export function accountToSessionMetadata(
|
||||
account: SessionAccount | undefined,
|
||||
): SessionMetadata | undefined {
|
||||
|
||||
@@ -13,13 +13,17 @@ export function AvatarStack({
|
||||
size = 26,
|
||||
numPending,
|
||||
backgroundColor,
|
||||
borderWidth = 1,
|
||||
overlap,
|
||||
}: {
|
||||
profiles: bsky.profile.AnyProfileView[]
|
||||
size?: number
|
||||
numPending?: number
|
||||
backgroundColor?: string
|
||||
borderWidth?: number
|
||||
overlap?: number
|
||||
}) {
|
||||
const translation = size / 3 // overlap by 1/3
|
||||
const translation = overlap ?? size / 3
|
||||
const t = useTheme()
|
||||
const moderationOpts = useModerationOpts()
|
||||
|
||||
@@ -55,7 +59,7 @@ export function AvatarStack({
|
||||
width: size,
|
||||
height: size,
|
||||
left: i * -translation,
|
||||
borderWidth: 1,
|
||||
borderWidth,
|
||||
borderColor: backgroundColor ?? t.atoms.bg.backgroundColor,
|
||||
borderRadius: 999,
|
||||
zIndex: 3 - i,
|
||||
@@ -63,7 +67,7 @@ export function AvatarStack({
|
||||
]}>
|
||||
{item.profile && (
|
||||
<UserAvatar
|
||||
size={size - 2}
|
||||
size={size - borderWidth * 2}
|
||||
avatar={item.profile.avatar}
|
||||
type={item.profile.associated?.labeler ? 'labeler' : 'user'}
|
||||
moderation={item.moderation.ui('avatar')}
|
||||
|
||||
@@ -362,9 +362,9 @@ export function Composer({
|
||||
onKeyPress={IS_WEB ? onKeyPressWeb : undefined}
|
||||
onScroll={e => {
|
||||
if (IS_WEB) {
|
||||
inputScrollSharedValue.value = (e.target as any).scrollTop
|
||||
inputScrollSharedValue.set((e.target as any).scrollTop)
|
||||
} else {
|
||||
inputScrollSharedValue.value = e.nativeEvent.contentOffset.y
|
||||
inputScrollSharedValue.set(e.nativeEvent.contentOffset.y)
|
||||
}
|
||||
}}
|
||||
// @ts-expect-error web only
|
||||
|
||||
@@ -42,7 +42,6 @@ export function useDialogControl(): DialogOuterProps['control'] {
|
||||
useEffect(() => {
|
||||
activeDialogs.current.set(id, control)
|
||||
return () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
activeDialogs.current.delete(id)
|
||||
}
|
||||
}, [id, activeDialogs])
|
||||
|
||||
@@ -73,12 +73,18 @@ export function Outer({
|
||||
setIsOpen(false)
|
||||
|
||||
try {
|
||||
if (cb && typeof cb === 'function') {
|
||||
// This timeout ensures that the callback runs at the same time as it would on native. I.e.
|
||||
// console.log('Step 1') -> close(() => console.log('Step 3')) -> console.log('Step 2')
|
||||
// This should always output 'Step 1', 'Step 2', 'Step 3', but without the timeout it would output
|
||||
// 'Step 1', 'Step 3', 'Step 2'.
|
||||
setTimeout(cb)
|
||||
/*
|
||||
* Nested rather than `&&`: React Compiler cannot lower a logical
|
||||
* expression in a test position inside a `try`.
|
||||
*/
|
||||
if (cb) {
|
||||
if (typeof cb === 'function') {
|
||||
// This timeout ensures that the callback runs at the same time as it would on native. I.e.
|
||||
// console.log('Step 1') -> close(() => console.log('Step 3')) -> console.log('Step 2')
|
||||
// This should always output 'Step 1', 'Step 2', 'Step 3', but without the timeout it would output
|
||||
// 'Step 1', 'Step 3', 'Step 2'.
|
||||
setTimeout(cb)
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
logger.error(`Dialog closeCallback failed`, {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {useCallback} from 'react'
|
||||
import {init} from 'emoji-mart'
|
||||
|
||||
/**
|
||||
@@ -16,15 +15,16 @@ let loadRequested = false
|
||||
*
|
||||
* @see {@link https://github.com/missive/emoji-mart/blob/16978d04a766eec6455e2e8bb21cd8dc0b3c7436/README.md?plain=1#L194 | emoji-mart preloading docs}
|
||||
*/
|
||||
export function useWebPreloadEmoji({immediate}: {immediate?: boolean} = {}) {
|
||||
const preload = useCallback(async () => {
|
||||
if (loadRequested) return
|
||||
loadRequested = true
|
||||
try {
|
||||
const data = (await import('@emoji-mart/data')).default
|
||||
init({data})
|
||||
} catch (e) {}
|
||||
}, [])
|
||||
if (immediate) preload()
|
||||
return preload
|
||||
async function loadEmojiData() {
|
||||
if (loadRequested) return
|
||||
loadRequested = true
|
||||
try {
|
||||
const data = (await import('@emoji-mart/data')).default
|
||||
init({data})
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
export function useWebPreloadEmoji({immediate}: {immediate?: boolean} = {}) {
|
||||
if (immediate) loadEmojiData()
|
||||
return loadEmojiData
|
||||
}
|
||||
|
||||
+59
-13
@@ -3,27 +3,38 @@ import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {useGoBack} from '#/lib/hooks/useGoBack'
|
||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||
import {Button, ButtonText} from '#/components/Button'
|
||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
import {type Props as SVGIconProps} from '#/components/icons/common'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import {Text} from '#/components/Typography'
|
||||
|
||||
export function Error({
|
||||
icon: Icon,
|
||||
title,
|
||||
message,
|
||||
onRetry,
|
||||
onGoBack,
|
||||
hideBackButton,
|
||||
secondaryAction,
|
||||
isRetrying,
|
||||
}: {
|
||||
icon?: React.ComponentType<SVGIconProps>
|
||||
title?: string
|
||||
message?: string
|
||||
onRetry?: () => unknown
|
||||
onGoBack?: () => unknown
|
||||
hideBackButton?: boolean
|
||||
isRetrying?: boolean
|
||||
secondaryAction?: {
|
||||
label: string
|
||||
accessibilityLabel?: string
|
||||
onPress: () => unknown
|
||||
}
|
||||
}) {
|
||||
const {t: l} = useLingui()
|
||||
const t = useTheme()
|
||||
const {gtMobile} = useBreakpoints()
|
||||
const goBack = useGoBack(onGoBack)
|
||||
|
||||
return (
|
||||
<Layout.Center
|
||||
@@ -35,8 +46,11 @@ export function Error({
|
||||
t.atoms.border_contrast_low,
|
||||
{paddingTop: 175, paddingBottom: 110},
|
||||
]}>
|
||||
<View style={[a.w_full, a.align_center, a.gap_lg]}>
|
||||
<Text style={[a.font_semi_bold, a.text_3xl]}>{title}</Text>
|
||||
<View style={[a.w_full, a.align_center, a.gap_lg, a.px_md]}>
|
||||
{Icon && <Icon size="4xl" fill={t.atoms.text_contrast_medium.color} />}
|
||||
<Text style={[a.font_semi_bold, a.text_3xl, a.text_center]}>
|
||||
{title}
|
||||
</Text>
|
||||
<Text
|
||||
style={[
|
||||
a.text_md,
|
||||
@@ -51,29 +65,61 @@ export function Error({
|
||||
<View style={[a.gap_md, gtMobile ? {width: 350} : [a.w_full, a.px_lg]]}>
|
||||
{onRetry && (
|
||||
<Button
|
||||
variant="solid"
|
||||
color="primary"
|
||||
label={l`Press to retry`}
|
||||
onPress={onRetry}
|
||||
disabled={isRetrying}
|
||||
size="large">
|
||||
<ButtonText>
|
||||
<Trans>Retry</Trans>
|
||||
</ButtonText>
|
||||
{isRetrying && <ButtonIcon icon={Loader} />}
|
||||
</Button>
|
||||
)}
|
||||
{!hideBackButton && (
|
||||
{!hideBackButton && secondaryAction ? (
|
||||
<Button
|
||||
variant="solid"
|
||||
color={onRetry ? 'secondary' : 'primary'}
|
||||
label={l`Return to previous page`}
|
||||
onPress={goBack}
|
||||
label={secondaryAction.accessibilityLabel ?? secondaryAction.label}
|
||||
onPress={secondaryAction.onPress}
|
||||
disabled={isRetrying}
|
||||
size="large">
|
||||
<ButtonText>
|
||||
<Trans>Go Back</Trans>
|
||||
</ButtonText>
|
||||
<ButtonText>{secondaryAction.label}</ButtonText>
|
||||
</Button>
|
||||
)}
|
||||
) : !hideBackButton ? (
|
||||
<GoBackButton
|
||||
hasRetry={Boolean(onRetry)}
|
||||
isRetrying={isRetrying}
|
||||
onGoBack={onGoBack}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</Layout.Center>
|
||||
)
|
||||
}
|
||||
|
||||
function GoBackButton({
|
||||
hasRetry,
|
||||
isRetrying,
|
||||
onGoBack,
|
||||
}: {
|
||||
hasRetry: boolean
|
||||
isRetrying?: boolean
|
||||
onGoBack?: () => unknown
|
||||
}) {
|
||||
const {t: l} = useLingui()
|
||||
const goBack = useGoBack(onGoBack)
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="solid"
|
||||
color={hasRetry ? 'secondary' : 'primary'}
|
||||
label={l`Return to previous page`}
|
||||
onPress={goBack}
|
||||
disabled={isRetrying}
|
||||
size="large">
|
||||
<ButtonText>
|
||||
<Trans>Go Back</Trans>
|
||||
</ButtonText>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -295,6 +295,8 @@ function SaveButtonInner({
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
const pinned = pin || false
|
||||
|
||||
try {
|
||||
if (savedFeedConfig) {
|
||||
await removeFeed(savedFeedConfig)
|
||||
@@ -303,7 +305,7 @@ function SaveButtonInner({
|
||||
{
|
||||
type,
|
||||
value: uri,
|
||||
pinned: pin || false,
|
||||
pinned,
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
@@ -54,6 +54,16 @@ export function InterestTabs({
|
||||
const pendingTabOffsets = useRef<{x: number; width: number}[]>([])
|
||||
const [tabOffsets, setTabOffsets] = useState<{x: number; width: number}[]>([])
|
||||
|
||||
function scrollIntoViewIfNeeded(index: number) {
|
||||
const btnLayout = tabOffsets[index]
|
||||
if (!btnLayout) return
|
||||
listRef.current?.scrollTo({
|
||||
// centered
|
||||
x: btnLayout.x - (totalWidth / 2 - btnLayout.width / 2),
|
||||
animated: true,
|
||||
})
|
||||
}
|
||||
|
||||
const onInitialLayout = useNonReactiveCallback(() => {
|
||||
const index = interests.indexOf(selectedInterest)
|
||||
scrollIntoViewIfNeeded(index)
|
||||
@@ -65,16 +75,6 @@ export function InterestTabs({
|
||||
}
|
||||
}, [tabOffsets, onInitialLayout])
|
||||
|
||||
function scrollIntoViewIfNeeded(index: number) {
|
||||
const btnLayout = tabOffsets[index]
|
||||
if (!btnLayout) return
|
||||
listRef.current?.scrollTo({
|
||||
// centered
|
||||
x: btnLayout.x - (totalWidth / 2 - btnLayout.width / 2),
|
||||
animated: true,
|
||||
})
|
||||
}
|
||||
|
||||
function handleSelectTab(index: number) {
|
||||
const tab = interests[index]
|
||||
onSelectTab(tab)
|
||||
|
||||
@@ -5,13 +5,15 @@ import {sanitizeAppLanguageSetting} from '#/locale/helpers'
|
||||
import {APP_LANGUAGES} from '#/locale/languages'
|
||||
import * as Select from '#/components/Select'
|
||||
|
||||
const DEFAULT_ITEMS = APP_LANGUAGES.map(l => ({
|
||||
label: l.name,
|
||||
value: l.code2,
|
||||
}))
|
||||
|
||||
export function LanguageSelect({
|
||||
value,
|
||||
onChange,
|
||||
items = APP_LANGUAGES.map(l => ({
|
||||
label: l.name,
|
||||
value: l.code2,
|
||||
})),
|
||||
items = DEFAULT_ITEMS,
|
||||
label,
|
||||
disabledBlueskySupportedLanguageSanitization = false,
|
||||
}: {
|
||||
|
||||
@@ -219,7 +219,7 @@ export function SubtitleText({children}: {children: React.ReactNode}) {
|
||||
IS_IOS && align === 'platform' && a.text_center,
|
||||
t.atoms.text_contrast_medium,
|
||||
]}
|
||||
numberOfLines={2}>
|
||||
numberOfLines={1}>
|
||||
{children}
|
||||
</Text>
|
||||
)
|
||||
|
||||
@@ -79,6 +79,11 @@ const ImageItem = ({
|
||||
|
||||
// Keep track of when we're entering or leaving scaled rendering.
|
||||
// Note: DO NOT move any logic reading animated values outside this function.
|
||||
function handleZoom(nextIsScaled: boolean) {
|
||||
setIsScaled(nextIsScaled)
|
||||
onZoom(nextIsScaled)
|
||||
}
|
||||
|
||||
useAnimatedReaction(
|
||||
() => {
|
||||
if (pinchScale.get() !== 1) {
|
||||
@@ -100,11 +105,6 @@ const ImageItem = ({
|
||||
},
|
||||
)
|
||||
|
||||
function handleZoom(nextIsScaled: boolean) {
|
||||
setIsScaled(nextIsScaled)
|
||||
onZoom(nextIsScaled)
|
||||
}
|
||||
|
||||
// On Android, stock apps prevent going "out of bounds" on pan or pinch. You should "bump" into edges.
|
||||
// If the user tried to pan too hard, this function will provide the negative panning to stay in bounds.
|
||||
function getExtraTranslationToStayInBounds(
|
||||
|
||||
@@ -22,6 +22,7 @@ import {useNavigation} from '@react-navigation/native'
|
||||
import {type NavigationProp} from '#/lib/routes/types'
|
||||
import {
|
||||
type EmbedPlayerParams,
|
||||
getEmbedPlayerMediaType,
|
||||
getPlayerAspect,
|
||||
} from '#/lib/strings/embed-player'
|
||||
import {useExternalEmbedsPrefs} from '#/state/preferences'
|
||||
@@ -32,6 +33,7 @@ import {EmbedConsentDialog} from '#/components/dialogs/EmbedConsent'
|
||||
import {Fill} from '#/components/Fill'
|
||||
import {KeepAwake} from '#/components/KeepAwake'
|
||||
import {PlayButtonIcon} from '#/components/video/PlayButtonIcon'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
@@ -121,9 +123,11 @@ function Player({
|
||||
export function ExternalPlayer({
|
||||
link,
|
||||
params,
|
||||
post,
|
||||
}: {
|
||||
link: app.bsky.embed.external.ViewExternal
|
||||
params: EmbedPlayerParams
|
||||
post?: app.bsky.feed.defs.PostView
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
@@ -131,10 +135,31 @@ export function ExternalPlayer({
|
||||
const windowDims = useWindowDimensions()
|
||||
const externalEmbedsPrefs = useExternalEmbedsPrefs()
|
||||
const consentDialogControl = useDialogControl()
|
||||
const ax = useAnalytics()
|
||||
|
||||
const [isPlayerActive, setIsPlayerActive] = useState(false)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
|
||||
const activatePlayer = useCallback(() => {
|
||||
if (!isPlayerActive) {
|
||||
ax.metric('externalEmbed:playerActivated', {
|
||||
postUri: post?.uri,
|
||||
postAuthorDid: post?.author.did,
|
||||
source: params.source,
|
||||
playerType: params.type,
|
||||
mediaType: getEmbedPlayerMediaType(params.type),
|
||||
})
|
||||
}
|
||||
setIsPlayerActive(true)
|
||||
}, [
|
||||
ax,
|
||||
isPlayerActive,
|
||||
params.source,
|
||||
params.type,
|
||||
post?.author.did,
|
||||
post?.uri,
|
||||
])
|
||||
|
||||
const aspect = useMemo(() => {
|
||||
return getPlayerAspect({
|
||||
type: params.type,
|
||||
@@ -202,14 +227,14 @@ export function ExternalPlayer({
|
||||
return
|
||||
}
|
||||
|
||||
setIsPlayerActive(true)
|
||||
activatePlayer()
|
||||
},
|
||||
[externalEmbedsPrefs, consentDialogControl, params.source],
|
||||
[externalEmbedsPrefs, consentDialogControl, params.source, activatePlayer],
|
||||
)
|
||||
|
||||
const onAcceptConsent = useCallback(() => {
|
||||
setIsPlayerActive(true)
|
||||
}, [])
|
||||
activatePlayer()
|
||||
}, [activatePlayer])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -27,11 +27,13 @@ import {GifEmbed} from './Gif'
|
||||
export const ExternalEmbed = ({
|
||||
link,
|
||||
onOpen,
|
||||
post,
|
||||
style,
|
||||
hideAlt,
|
||||
}: {
|
||||
link: app.bsky.embed.external.ViewExternal
|
||||
onOpen?: () => void
|
||||
post?: app.bsky.feed.defs.PostView
|
||||
style?: StyleProp<ViewStyle>
|
||||
hideAlt?: boolean
|
||||
}) => {
|
||||
@@ -120,7 +122,11 @@ export const ExternalEmbed = ({
|
||||
{embedPlayerParams?.isGif ? (
|
||||
<ExternalGif link={link} params={embedPlayerParams} />
|
||||
) : embedPlayerParams ? (
|
||||
<ExternalPlayer link={link} params={embedPlayerParams} />
|
||||
<ExternalPlayer
|
||||
link={link}
|
||||
params={embedPlayerParams}
|
||||
post={post}
|
||||
/>
|
||||
) : undefined}
|
||||
|
||||
<View
|
||||
|
||||
@@ -4,6 +4,7 @@ import {BlueskyVideoView} from '@bsky.app/video'
|
||||
import {useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {HITSLOP_30} from '#/lib/constants'
|
||||
import {hasPlaybackStarted} from '#/lib/media/video/analytics'
|
||||
import {useAutoplayDisabled} from '#/state/preferences'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {AltBadgeWithDialog} from '#/components/AltBadgeWithDialog'
|
||||
@@ -26,6 +27,7 @@ export function VideoEmbedInnerNative({
|
||||
setStatus,
|
||||
setIsLoading,
|
||||
setIsActive,
|
||||
onPlaybackStart,
|
||||
onError,
|
||||
}: {
|
||||
ref: React.Ref<{togglePlayback: () => void}>
|
||||
@@ -33,6 +35,7 @@ export function VideoEmbedInnerNative({
|
||||
setStatus: (status: 'playing' | 'paused') => void
|
||||
setIsLoading: (isLoading: boolean) => void
|
||||
setIsActive: (isActive: boolean) => void
|
||||
onPlaybackStart: (autoplay: boolean) => void
|
||||
/**
|
||||
* Called with the native error message before the component throws to the
|
||||
* surrounding error boundary.
|
||||
@@ -46,6 +49,7 @@ export function VideoEmbedInnerNative({
|
||||
const [muted, setMuted] = useVideoMuteState()
|
||||
const reportDialogMetadata = useReportDialogMetadataContext()
|
||||
const maxTimeRemainingSeconds = useRef(0)
|
||||
const playbackStartTrackedRef = useRef(false)
|
||||
|
||||
const [isPlaying, setIsPlaying] = useState(false)
|
||||
const [timeRemaining, setTimeRemaining] = useState(0)
|
||||
@@ -62,12 +66,13 @@ export function VideoEmbedInnerNative({
|
||||
}
|
||||
|
||||
const isGif = embed.presentation === 'gif'
|
||||
const autoplay = !autoplayDisabled && !isWithinMessage
|
||||
|
||||
return (
|
||||
<View style={[a.flex_1, a.relative]}>
|
||||
<BlueskyVideoView
|
||||
url={embed.playlist}
|
||||
autoplay={!autoplayDisabled && !isWithinMessage}
|
||||
autoplay={autoplay}
|
||||
beginMuted={isGif || (autoplayDisabled ? false : muted)}
|
||||
style={[a.rounded_sm]}
|
||||
onActiveChange={e => {
|
||||
@@ -88,20 +93,26 @@ export function VideoEmbedInnerNative({
|
||||
onTimeRemainingChange={e => {
|
||||
const {timeRemaining} = e.nativeEvent
|
||||
setTimeRemaining(timeRemaining)
|
||||
if (
|
||||
!isGif &&
|
||||
reportDialogMetadata &&
|
||||
Number.isFinite(timeRemaining) &&
|
||||
timeRemaining >= 0
|
||||
) {
|
||||
if (Number.isFinite(timeRemaining) && timeRemaining >= 0) {
|
||||
maxTimeRemainingSeconds.current = Math.max(
|
||||
maxTimeRemainingSeconds.current,
|
||||
timeRemaining,
|
||||
)
|
||||
reportDialogMetadata.current.videoTimestampSeconds = Math.max(
|
||||
0,
|
||||
maxTimeRemainingSeconds.current - timeRemaining,
|
||||
)
|
||||
if (
|
||||
!playbackStartTrackedRef.current &&
|
||||
hasPlaybackStarted(
|
||||
maxTimeRemainingSeconds.current - timeRemaining,
|
||||
)
|
||||
) {
|
||||
playbackStartTrackedRef.current = true
|
||||
onPlaybackStart(autoplay)
|
||||
}
|
||||
if (!isGif && reportDialogMetadata) {
|
||||
reportDialogMetadata.current.videoTimestampSeconds = Math.max(
|
||||
0,
|
||||
maxTimeRemainingSeconds.current - timeRemaining,
|
||||
)
|
||||
}
|
||||
}
|
||||
}}
|
||||
onError={e => {
|
||||
|
||||
@@ -6,6 +6,7 @@ export type VideoEmbedInnerWebProps = {
|
||||
setActive: () => void
|
||||
onScreen: boolean
|
||||
lastKnownTime: React.RefObject<number | undefined>
|
||||
onPlaybackStart: (autoplay: boolean) => void
|
||||
}
|
||||
|
||||
export class HLSUnsupportedError extends Error {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {useLingui} from '@lingui/react/macro'
|
||||
import type * as HlsTypes from 'hls.js'
|
||||
|
||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||
import {hasPlaybackStarted} from '#/lib/media/video/analytics'
|
||||
import {atoms as a} from '#/alf'
|
||||
import {AltBadgeWithDialog} from '#/components/AltBadgeWithDialog'
|
||||
import {useFullscreen} from '#/components/hooks/useFullscreen'
|
||||
@@ -29,6 +30,7 @@ export function VideoEmbedInnerWeb({
|
||||
setActive,
|
||||
onScreen,
|
||||
lastKnownTime,
|
||||
onPlaybackStart,
|
||||
}: VideoEmbedInnerWebProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const videoRef = useRef<HTMLVideoElement>(null)
|
||||
@@ -40,6 +42,7 @@ export function VideoEmbedInnerWeb({
|
||||
const [isFullscreen] = useFullscreen(containerRef)
|
||||
const isGif = embed.presentation === 'gif'
|
||||
const reportDialogMetadata = useReportDialogMetadataContext()
|
||||
const playbackStartTrackedRef = useRef(false)
|
||||
|
||||
// send error up to error boundary
|
||||
const [error, setError] = useState<Error | null>(null)
|
||||
@@ -79,6 +82,13 @@ export function VideoEmbedInnerWeb({
|
||||
onTimeUpdate={e => {
|
||||
const currentTime = e.currentTarget.currentTime
|
||||
lastKnownTime.current = currentTime
|
||||
if (
|
||||
!playbackStartTrackedRef.current &&
|
||||
hasPlaybackStarted(currentTime)
|
||||
) {
|
||||
playbackStartTrackedRef.current = true
|
||||
onPlaybackStart(!focused)
|
||||
}
|
||||
if (
|
||||
!isGif &&
|
||||
reportDialogMetadata &&
|
||||
|
||||
@@ -23,9 +23,10 @@ import * as VideoFallback from './VideoEmbedInner/VideoFallback'
|
||||
|
||||
interface Props {
|
||||
embed: app.bsky.embed.video.View
|
||||
post?: app.bsky.feed.defs.PostView
|
||||
}
|
||||
|
||||
export function VideoEmbed({embed}: Props) {
|
||||
export function VideoEmbed({embed, post}: Props) {
|
||||
const [key, setKey] = useState(0)
|
||||
|
||||
const renderError = useCallback(
|
||||
@@ -52,7 +53,7 @@ export function VideoEmbed({embed}: Props) {
|
||||
|
||||
const contents = (
|
||||
<ErrorBoundary renderError={renderError} key={key}>
|
||||
<InnerWrapper embed={embed} />
|
||||
<InnerWrapper embed={embed} post={post} />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
|
||||
@@ -69,7 +70,7 @@ export function VideoEmbed({embed}: Props) {
|
||||
)
|
||||
}
|
||||
|
||||
function InnerWrapper({embed}: Props) {
|
||||
function InnerWrapper({embed, post}: Props) {
|
||||
const {_} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
const ref = useRef<{togglePlayback: () => void}>(null)
|
||||
@@ -86,6 +87,8 @@ function InnerWrapper({embed}: Props) {
|
||||
* the active position cost nothing.
|
||||
*/
|
||||
const telemetryRef = useRef<PlaybackTelemetry | null>(null)
|
||||
const impressionTrackedRef = useRef(false)
|
||||
const playbackStartTrackedRef = useRef(false)
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
telemetryRef.current?.deactivated()
|
||||
@@ -121,15 +124,37 @@ function InnerWrapper({embed}: Props) {
|
||||
setIsActive={active => {
|
||||
setIsActive(active)
|
||||
if (active) {
|
||||
telemetryRef.current ??= createPlaybackTelemetry({
|
||||
surface: 'feed',
|
||||
presentation: embed.presentation === 'gif' ? 'gif' : 'video',
|
||||
})
|
||||
if (!impressionTrackedRef.current) {
|
||||
impressionTrackedRef.current = true
|
||||
ax.metric('video:impression', {
|
||||
postUri: post?.uri,
|
||||
postAuthorDid: post?.author.did,
|
||||
context: 'embed',
|
||||
presentation: embed.presentation === 'gif' ? 'gif' : 'video',
|
||||
})
|
||||
}
|
||||
if (telemetryRef.current == null) {
|
||||
telemetryRef.current = createPlaybackTelemetry({
|
||||
surface: 'feed',
|
||||
presentation: embed.presentation === 'gif' ? 'gif' : 'video',
|
||||
})
|
||||
}
|
||||
telemetryRef.current.activated()
|
||||
} else {
|
||||
telemetryRef.current?.deactivated()
|
||||
}
|
||||
}}
|
||||
onPlaybackStart={autoplay => {
|
||||
if (playbackStartTrackedRef.current) return
|
||||
playbackStartTrackedRef.current = true
|
||||
ax.metric('video:playback:start', {
|
||||
postUri: post?.uri,
|
||||
postAuthorDid: post?.author.did,
|
||||
context: 'embed',
|
||||
presentation: embed.presentation === 'gif' ? 'gif' : 'video',
|
||||
autoplay,
|
||||
})
|
||||
}}
|
||||
onError={error => {
|
||||
telemetryRef.current?.error(error)
|
||||
ax.metric('video:playback:failed', {
|
||||
|
||||
@@ -37,7 +37,13 @@ const noop = () => {}
|
||||
*/
|
||||
const MIN_CARD_WIDTH = 280
|
||||
|
||||
export function VideoEmbed({embed}: {embed: app.bsky.embed.video.View}) {
|
||||
export function VideoEmbed({
|
||||
embed,
|
||||
post,
|
||||
}: {
|
||||
embed: app.bsky.embed.video.View
|
||||
post?: app.bsky.feed.defs.PostView
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const {
|
||||
@@ -47,13 +53,28 @@ export function VideoEmbed({embed}: {embed: app.bsky.embed.video.View}) {
|
||||
currentActiveView,
|
||||
} = useActiveVideoWeb()
|
||||
const [onScreen, setOnScreen] = useState(false)
|
||||
const [meaningfullyVisible, setMeaningfullyVisible] = useState(false)
|
||||
const [isFullscreen] = useFullscreen()
|
||||
const lastKnownTime = useRef<number | undefined>(undefined)
|
||||
const impressionTrackedRef = useRef(false)
|
||||
const playbackStartTrackedRef = useRef(false)
|
||||
const ax = useAnalytics()
|
||||
|
||||
const isGif = embed.presentation === 'gif'
|
||||
// GIFs don't participate in the "one video at a time" system
|
||||
const active = isGif || activeFromContext
|
||||
|
||||
useEffect(() => {
|
||||
if (!meaningfullyVisible || impressionTrackedRef.current) return
|
||||
impressionTrackedRef.current = true
|
||||
ax.metric('video:impression', {
|
||||
postUri: post?.uri,
|
||||
postAuthorDid: post?.author.did,
|
||||
context: 'embed',
|
||||
presentation: isGif ? 'gif' : 'video',
|
||||
})
|
||||
}, [ax, isGif, meaningfullyVisible, post?.author.did, post?.uri])
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current) return
|
||||
if (isFullscreen && !IS_WEB_FIREFOX) return
|
||||
@@ -62,6 +83,9 @@ export function VideoEmbed({embed}: {embed: app.bsky.embed.video.View}) {
|
||||
const entry = entries[0]
|
||||
if (!entry) return
|
||||
setOnScreen(entry.isIntersecting)
|
||||
setMeaningfullyVisible(
|
||||
entry.isIntersecting && entry.intersectionRatio >= 0.5,
|
||||
)
|
||||
// GIFs don't send position - they don't compete to be the active video
|
||||
if (!isGif) {
|
||||
sendPosition(
|
||||
@@ -179,6 +203,17 @@ export function VideoEmbed({embed}: {embed: app.bsky.embed.video.View}) {
|
||||
setActive={setActive}
|
||||
onScreen={onScreen}
|
||||
lastKnownTime={lastKnownTime}
|
||||
onPlaybackStart={autoplay => {
|
||||
if (playbackStartTrackedRef.current) return
|
||||
playbackStartTrackedRef.current = true
|
||||
ax.metric('video:playback:start', {
|
||||
postUri: post?.uri,
|
||||
postAuthorDid: post?.author.did,
|
||||
context: 'embed',
|
||||
presentation: isGif ? 'gif' : 'video',
|
||||
autoplay,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</OnlyNearScreen>
|
||||
</ErrorBoundary>
|
||||
|
||||
@@ -134,6 +134,7 @@ function MediaEmbed({
|
||||
<ExternalEmbed
|
||||
link={embed.view.external}
|
||||
onOpen={rest.onOpen}
|
||||
post={rest.post}
|
||||
style={[a.mt_sm, rest.style]}
|
||||
/>
|
||||
</ContentHider>
|
||||
@@ -144,7 +145,7 @@ function MediaEmbed({
|
||||
<ContentHider
|
||||
modui={rest.moderation?.ui('contentMedia')}
|
||||
activeStyle={[a.mt_sm]}>
|
||||
<VideoEmbed embed={embed.view} />
|
||||
<VideoEmbed embed={embed.view} post={rest.post} />
|
||||
</ContentHider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import {View} from 'react-native'
|
||||
import {AtUri} from '@atproto/syntax'
|
||||
import {moderateProfile} from '@bsky/sdk/moderation'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {makeProfileLink} from '#/lib/routes/links'
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {AvatarStack} from '#/components/AvatarStack'
|
||||
import {InlineLinkText, Link} from '#/components/Link'
|
||||
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {type Features, useAnalytics} from '#/analytics'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
/**
|
||||
* Social proof for a post. When the viewer follows some of the post's recent
|
||||
* likers, renders a face pile plus "Liked by A and B". Renders nothing when
|
||||
* the feature is disabled or no visible known likers are available.
|
||||
*/
|
||||
export function KnownLikers({
|
||||
post,
|
||||
feature,
|
||||
variant = 'thread',
|
||||
}: {
|
||||
post: app.bsky.feed.defs.PostView
|
||||
feature: Features
|
||||
variant?: 'feed' | 'thread'
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
const moderationOpts = useModerationOpts()
|
||||
const ax = useAnalytics()
|
||||
|
||||
const knownLikersAndModeration = moderationOpts
|
||||
? (post.viewer?.knownLikers?.actors ?? [])
|
||||
.map(actor => ({
|
||||
actor,
|
||||
moderation: moderateProfile(actor, moderationOpts),
|
||||
}))
|
||||
.filter(({moderation}) => !moderation.ui('profileList').filter)
|
||||
: []
|
||||
|
||||
if (knownLikersAndModeration.length === 0 || !ax.features.enabled(feature)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const urip = new AtUri(post.uri)
|
||||
const likesHref = makeProfileLink(post.author, 'post', urip.rkey, 'liked-by')
|
||||
const aviStackProfiles = knownLikersAndModeration
|
||||
.slice(0, 3)
|
||||
.map(({actor}) => actor)
|
||||
const names = knownLikersAndModeration
|
||||
.slice(0, 2)
|
||||
.map(({actor, moderation}) => ({
|
||||
did: actor.did,
|
||||
href: makeProfileLink(actor),
|
||||
displayName: sanitizeDisplayName(
|
||||
actor.displayName || actor.handle,
|
||||
moderation.ui('displayName'),
|
||||
),
|
||||
}))
|
||||
const isFeed = variant === 'feed'
|
||||
const rowLabel =
|
||||
names.length >= 2
|
||||
? l`Liked by ${names[0].displayName} and ${names[1].displayName}`
|
||||
: l`Liked by ${names[0].displayName}`
|
||||
const textStyle = [a.text_sm, t.atoms.text_contrast_medium]
|
||||
const nameStyle = [a.text_sm, a.font_medium, t.atoms.text_contrast_medium]
|
||||
|
||||
const nameLink = (name: (typeof names)[number]) => (
|
||||
<ProfileHoverCard key={name.did} did={name.did} inline>
|
||||
<InlineLinkText
|
||||
to={name.href}
|
||||
label={l`Go to ${name.displayName}'s profile`}
|
||||
disableMismatchWarning
|
||||
emoji
|
||||
style={nameStyle}>
|
||||
{name.displayName}
|
||||
</InlineLinkText>
|
||||
</ProfileHoverCard>
|
||||
)
|
||||
|
||||
return (
|
||||
<View style={[a.w_full, a.flex_row, isFeed && a.mt_sm]}>
|
||||
<Link
|
||||
to={likesHref}
|
||||
label={rowLabel}
|
||||
style={[a.flex_row, a.align_center, a.gap_xs, a.flex_shrink]}
|
||||
onPress={() => ax.metric('post:likedBy:click', {})}>
|
||||
<AvatarStack
|
||||
profiles={aviStackProfiles}
|
||||
size={16}
|
||||
overlap={4}
|
||||
borderWidth={0.5}
|
||||
backgroundColor={t.atoms.bg_contrast_25.backgroundColor}
|
||||
/>
|
||||
<Text testID="knownLikersStat" style={[a.flex_shrink, textStyle]}>
|
||||
{names.length >= 2 ? (
|
||||
<Trans comment="Social proof below a post; the bolded names are people the viewer follows who liked the post">
|
||||
Liked by {nameLink(names[0])} and {nameLink(names[1])}
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans comment="Social proof below a post; the bolded name is a person the viewer follows who liked the post">
|
||||
Liked by {nameLink(names[0])}
|
||||
</Trans>
|
||||
)}
|
||||
</Text>
|
||||
</Link>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -107,9 +107,10 @@ let PostControls = ({
|
||||
return
|
||||
}
|
||||
|
||||
const existingLike = post.viewer?.like
|
||||
try {
|
||||
setHasLikeIconBeenToggled(true)
|
||||
if (!post.viewer?.like) {
|
||||
if (!existingLike) {
|
||||
sendInteraction({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#interactionLike',
|
||||
@@ -137,8 +138,9 @@ let PostControls = ({
|
||||
return
|
||||
}
|
||||
|
||||
const existingRepost = post.viewer?.repost
|
||||
try {
|
||||
if (!post.viewer?.repost) {
|
||||
if (!existingRepost) {
|
||||
sendInteraction({
|
||||
item: post.uri,
|
||||
event: 'app.bsky.feed.defs#interactionRepost',
|
||||
|
||||
@@ -86,17 +86,20 @@ export function ProfileBadges({
|
||||
|
||||
const gap = isOnTheSmallSide ? a.gap_2xs : a.gap_xs
|
||||
const padding = gap.gap / 2
|
||||
const hitSlops = []
|
||||
let visibleBadgeIndex = 0
|
||||
const hitSlops = badgeVisibility.map(isVisible => {
|
||||
if (!isVisible) return HITSLOP_20
|
||||
|
||||
for (const isVisible of badgeVisibility) {
|
||||
if (!isVisible) {
|
||||
hitSlops.push(HITSLOP_20)
|
||||
continue
|
||||
}
|
||||
const index = visibleBadgeIndex++
|
||||
return {
|
||||
hitSlops.push({
|
||||
...HITSLOP_20,
|
||||
left: index === 0 ? HITSLOP_20.left : padding,
|
||||
right: index === badgeCount - 1 ? HITSLOP_20.right : padding,
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[a.flex_row, a.align_center, gap, style]}>
|
||||
|
||||
@@ -491,16 +491,21 @@ export function FollowButtonInner({
|
||||
const onPressFollow = async (e: GestureResponderEvent) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const displayNameOrHandle = profile.displayName || profile.handle
|
||||
try {
|
||||
await queueFollow()
|
||||
Toast.show(
|
||||
l`Following ${sanitizeDisplayName(
|
||||
profile.displayName || profile.handle,
|
||||
displayNameOrHandle,
|
||||
moderation.ui('displayName'),
|
||||
)}`,
|
||||
)
|
||||
onPressProp?.(e)
|
||||
onFollow?.()
|
||||
if (onPressProp) {
|
||||
onPressProp(e)
|
||||
}
|
||||
if (onFollow) {
|
||||
onFollow()
|
||||
}
|
||||
} catch (e) {
|
||||
const err = e as Error
|
||||
if (err?.name !== 'AbortError') {
|
||||
@@ -514,15 +519,18 @@ export function FollowButtonInner({
|
||||
const onPressUnfollow = async (e: GestureResponderEvent) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const displayNameOrHandle = profile.displayName || profile.handle
|
||||
try {
|
||||
await queueUnfollow()
|
||||
Toast.show(
|
||||
l`No longer following ${sanitizeDisplayName(
|
||||
profile.displayName || profile.handle,
|
||||
displayNameOrHandle,
|
||||
moderation.ui('displayName'),
|
||||
)}`,
|
||||
)
|
||||
onPressProp?.(e)
|
||||
if (onPressProp) {
|
||||
onPressProp(e)
|
||||
}
|
||||
} catch (e) {
|
||||
const err = e as Error
|
||||
if (err?.name !== 'AbortError') {
|
||||
|
||||
@@ -122,9 +122,12 @@ export function Trigger({children, hitSlop, label}: TriggerProps) {
|
||||
}
|
||||
}
|
||||
|
||||
const defaultValueText: NonNullable<ValueProps['children']> = value =>
|
||||
value.label
|
||||
|
||||
export function ValueText({
|
||||
placeholder,
|
||||
children = value => value.label,
|
||||
children = defaultValueText,
|
||||
style,
|
||||
}: ValueProps) {
|
||||
const [value] = useContext(ValueTextContext)
|
||||
|
||||
@@ -2,22 +2,32 @@ import {forwardRef, useCallback, useImperativeHandle, useState} from 'react'
|
||||
import {type ListRenderItemInfo, View} from 'react-native'
|
||||
import {AtUri} from '@atproto/syntax'
|
||||
import {type ModerationOpts} from '@bsky/sdk/moderation'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
|
||||
import {useBottomBarOffset} from '#/lib/hooks/useBottomBarOffset'
|
||||
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
||||
import {isBlockedOrBlocking} from '#/lib/moderation/blocked-and-muted'
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {useAllListMembersQuery} from '#/state/queries/list-members'
|
||||
import {useListMembershipRemoveMutation} from '#/state/queries/list-memberships'
|
||||
import {useSession} from '#/state/session'
|
||||
import {List, type ListRef} from '#/view/com/util/List'
|
||||
import {type SectionRef} from '#/screens/Profile/Sections/types'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import * as Admonition from '#/components/Admonition'
|
||||
import {ButtonIcon, ButtonText} from '#/components/Button'
|
||||
import {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import {Default as ProfileCard} from '#/components/ProfileCard'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
function keyExtractor(item: app.bsky.actor.defs.ProfileView, index: number) {
|
||||
return `${item.did}-${index}`
|
||||
function keyExtractor(item: app.bsky.graph.defs.ListItemView) {
|
||||
return item.uri
|
||||
}
|
||||
|
||||
interface ProfilesListProps {
|
||||
@@ -42,26 +52,26 @@ export const ProfilesList = forwardRef<SectionRef, ProfilesListProps>(
|
||||
|
||||
// The server returns these sorted by descending creation date, so we want to invert
|
||||
|
||||
const profiles = data
|
||||
const listItems = data
|
||||
?.filter(
|
||||
p => !isBlockedOrBlocking(p.subject) && !p.subject.associated?.labeler,
|
||||
)
|
||||
.map(p => p.subject)
|
||||
.reverse()
|
||||
const isOwn = new AtUri(listUri).host === currentAccount?.did
|
||||
|
||||
const getSortedProfiles = () => {
|
||||
if (!profiles) return
|
||||
if (!isOwn) return profiles
|
||||
if (!listItems) return
|
||||
|
||||
const myIndex = profiles.findIndex(p => p.did === currentAccount?.did)
|
||||
return myIndex !== -1
|
||||
? [
|
||||
profiles[myIndex],
|
||||
...profiles.slice(0, myIndex),
|
||||
...profiles.slice(myIndex + 1),
|
||||
]
|
||||
: profiles
|
||||
return [...listItems].sort((a, b) => {
|
||||
if (a.subjectOptedOut !== b.subjectOptedOut) {
|
||||
return a.subjectOptedOut ? -1 : 1
|
||||
}
|
||||
if (isOwn) {
|
||||
if (a.subject.did === currentAccount?.did) return -1
|
||||
if (b.subject.did === currentAccount?.did) return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
}
|
||||
const onScrollToTop = useCallback(() => {
|
||||
scrollElRef.current?.scrollToOffset({
|
||||
@@ -77,7 +87,7 @@ export const ProfilesList = forwardRef<SectionRef, ProfilesListProps>(
|
||||
const renderItem = ({
|
||||
item,
|
||||
index,
|
||||
}: ListRenderItemInfo<app.bsky.actor.defs.ProfileView>) => {
|
||||
}: ListRenderItemInfo<app.bsky.graph.defs.ListItemView>) => {
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
@@ -86,10 +96,13 @@ export const ProfilesList = forwardRef<SectionRef, ProfilesListProps>(
|
||||
(IS_WEB || index !== 0) && a.border_t,
|
||||
]}>
|
||||
<ProfileCard
|
||||
profile={item}
|
||||
profile={item.subject}
|
||||
moderationOpts={moderationOpts}
|
||||
logContext="StarterPackProfilesList"
|
||||
/>
|
||||
{item.subjectOptedOut ? (
|
||||
<OptedOutControls item={item} listUri={listUri} canRemove={isOwn} />
|
||||
) : null}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -136,3 +149,66 @@ export const ProfilesList = forwardRef<SectionRef, ProfilesListProps>(
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
function OptedOutControls({
|
||||
item,
|
||||
listUri,
|
||||
canRemove,
|
||||
}: {
|
||||
item: app.bsky.graph.defs.ListItemView
|
||||
listUri: string
|
||||
canRemove: boolean
|
||||
}) {
|
||||
const {_} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
const [isRemoved, setIsRemoved] = useState(false)
|
||||
const {mutate: removeMembership, isPending} = useListMembershipRemoveMutation(
|
||||
{
|
||||
onSuccess: () => {
|
||||
setIsRemoved(true)
|
||||
Toast.show(_(msg`Removed from starter pack`))
|
||||
},
|
||||
onError: error =>
|
||||
Toast.show(cleanError(error), {
|
||||
type: 'error',
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
if (isRemoved) return null
|
||||
|
||||
return (
|
||||
<Admonition.Outer type="info" style={[a.mt_sm]}>
|
||||
<Admonition.Row style={[a.align_center]}>
|
||||
<Admonition.Icon />
|
||||
<Admonition.Content>
|
||||
<Admonition.Text>
|
||||
<Trans>Opted out of this starter pack</Trans>
|
||||
</Admonition.Text>
|
||||
</Admonition.Content>
|
||||
{canRemove ? (
|
||||
<Admonition.Button
|
||||
label={_(msg`Remove user from starter pack`)}
|
||||
color="secondary"
|
||||
disabled={isPending}
|
||||
onPress={() => {
|
||||
ax.metric('starterPack:removeUser', {context: 'opt-out'})
|
||||
removeMembership({
|
||||
listUri,
|
||||
actorDid: item.subject.did,
|
||||
membershipUri: item.uri,
|
||||
})
|
||||
}}>
|
||||
{isPending ? (
|
||||
<ButtonIcon icon={Loader} />
|
||||
) : (
|
||||
<ButtonText>
|
||||
<Trans>Remove</Trans>
|
||||
</ButtonText>
|
||||
)}
|
||||
</Admonition.Button>
|
||||
) : null}
|
||||
</Admonition.Row>
|
||||
</Admonition.Outer>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -53,14 +53,15 @@ function ShareDialogInner({
|
||||
|
||||
const imageUrl = getStarterPackOgCard(starterPack)
|
||||
|
||||
const onShareLink = async () => {
|
||||
const onShareLink = () => {
|
||||
if (!link) return
|
||||
shareUrl(link)
|
||||
ax.metric('starterPack:share', {
|
||||
starterPack: starterPack.uri,
|
||||
shareType: 'link',
|
||||
})
|
||||
control.close()
|
||||
control.close(() => {
|
||||
void shareUrl(link)
|
||||
})
|
||||
}
|
||||
|
||||
const saveImageToAlbum = useSaveImageToMediaLibrary()
|
||||
|
||||
@@ -62,6 +62,7 @@ export function Card({
|
||||
const {_} = useLingui()
|
||||
const t = useTheme()
|
||||
const {currentAccount} = useSession()
|
||||
const isOwnStarterPack = creator?.did === currentAccount?.did
|
||||
|
||||
if (!bsky.isType(app.bsky.graph.starterpack, record)) {
|
||||
return null
|
||||
@@ -82,7 +83,7 @@ export function Card({
|
||||
emoji
|
||||
style={[a.leading_snug, t.atoms.text_contrast_medium]}
|
||||
numberOfLines={1}>
|
||||
{creator?.did === currentAccount?.did
|
||||
{isOwnStarterPack
|
||||
? _(msg`Starter pack by you`)
|
||||
: _(msg`Starter pack by ${sanitizeHandle(creator.handle, '@')}`)}
|
||||
</Text>
|
||||
|
||||
@@ -36,6 +36,7 @@ function WizardListCard({
|
||||
avatar,
|
||||
included,
|
||||
disabled,
|
||||
subjectOptedOut,
|
||||
moderationUi,
|
||||
}: {
|
||||
type: 'user' | 'algo'
|
||||
@@ -48,6 +49,7 @@ function WizardListCard({
|
||||
avatar?: string
|
||||
included?: boolean
|
||||
disabled?: boolean
|
||||
subjectOptedOut?: boolean
|
||||
moderationUi: ModerationUI
|
||||
}) {
|
||||
const t = useTheme()
|
||||
@@ -97,6 +99,11 @@ function WizardListCard({
|
||||
numberOfLines={1}>
|
||||
{subtitle}
|
||||
</Text>
|
||||
{subjectOptedOut ? (
|
||||
<Text style={[a.text_sm, t.atoms.text_contrast_medium]}>
|
||||
<Trans>Opted out</Trans>
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
{btnType === 'checkbox' ? (
|
||||
<Checkbox />
|
||||
@@ -123,12 +130,14 @@ export function WizardProfileCard({
|
||||
dispatch,
|
||||
profile,
|
||||
moderationOpts,
|
||||
subjectOptedOut = false,
|
||||
}: {
|
||||
btnType: 'checkbox' | 'remove'
|
||||
state: WizardState
|
||||
dispatch: (action: WizardAction) => void
|
||||
profile: bsky.profile.AnyProfileView
|
||||
moderationOpts: ModerationOpts
|
||||
subjectOptedOut?: boolean
|
||||
}) {
|
||||
const ax = useAnalytics()
|
||||
const {currentAccount} = useSession()
|
||||
@@ -138,7 +147,9 @@ export function WizardProfileCard({
|
||||
const isTarget = profile.did === targetProfileDid
|
||||
const included = isTarget || state.profiles.some(p => p.did === profile.did)
|
||||
const disabled =
|
||||
isTarget || (!included && state.profiles.length >= STARTER_PACK_MAX_SIZE)
|
||||
subjectOptedOut ||
|
||||
isTarget ||
|
||||
(!included && state.profiles.length >= STARTER_PACK_MAX_SIZE)
|
||||
const moderationUi = moderateProfile(profile, moderationOpts).ui('avatar')
|
||||
const displayName = profile.displayName
|
||||
? sanitizeDisplayName(profile.displayName)
|
||||
@@ -169,6 +180,7 @@ export function WizardProfileCard({
|
||||
avatar={profile.avatar}
|
||||
included={included}
|
||||
disabled={disabled}
|
||||
subjectOptedOut={subjectOptedOut}
|
||||
moderationUi={moderationUi}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {useEffect, useState} from 'react'
|
||||
import {useEffect, useEffectEvent, useState} from 'react'
|
||||
import {Pressable, View} from 'react-native'
|
||||
import {ImageBackground} from 'expo-image'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
@@ -35,11 +35,14 @@ export function WelcomeModal({control}: WelcomeModalProps) {
|
||||
}, 150)
|
||||
}
|
||||
|
||||
const onPresented = useEffectEvent(() => {
|
||||
ax.metric('welcomeModal:presented', {})
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (control.isOpen) {
|
||||
ax.metric('welcomeModal:presented', {})
|
||||
onPresented()
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [control.isOpen])
|
||||
|
||||
const onPressCreateAccount = () => {
|
||||
|
||||
@@ -114,7 +114,7 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) {
|
||||
style={[
|
||||
a.flex_row,
|
||||
a.align_center,
|
||||
a.gap_xs,
|
||||
{gap: 3},
|
||||
(hovered || focused || pressed) && native({opacity: 0.5}),
|
||||
style,
|
||||
]}>
|
||||
@@ -122,16 +122,16 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) {
|
||||
color={
|
||||
isThreadAuthor ? t.palette.primary_500 : t.palette.contrast_400
|
||||
}
|
||||
width={16}
|
||||
width={12}
|
||||
settings={settings}
|
||||
/>
|
||||
<Text
|
||||
style={[
|
||||
a.text_sm,
|
||||
a.text_xs,
|
||||
a.leading_tight,
|
||||
isThreadAuthor
|
||||
? {color: t.palette.primary_500}
|
||||
: t.atoms.text_contrast_medium,
|
||||
: t.atoms.text_contrast_high,
|
||||
(hovered || focused || pressed) && web(a.underline),
|
||||
]}>
|
||||
{description}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {Trans} from '@lingui/react/macro'
|
||||
import {EMBED_SCRIPT} from '#/lib/constants'
|
||||
import {niceDate} from '#/lib/strings/time'
|
||||
import {toShareUrl} from '#/lib/strings/url-helpers'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {atoms as a, useTheme, web} from '#/alf'
|
||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
import * as SegmentedControl from '#/components/forms/SegmentedControl'
|
||||
@@ -103,7 +103,7 @@ function EmbedDialogInner({
|
||||
}, [i18n, postUri, postCid, record, timestamp, postAuthor, colorMode])
|
||||
|
||||
return (
|
||||
<Dialog.Inner label={_(msg`Embed post`)} style={[{maxWidth: 500}]}>
|
||||
<Dialog.Inner label={_(msg`Embed post`)} style={[web({maxWidth: 500})]}>
|
||||
<View style={[a.gap_lg]}>
|
||||
<View style={[a.gap_sm]}>
|
||||
<Text style={[a.text_2xl, a.font_bold]}>
|
||||
|
||||
@@ -294,6 +294,37 @@ export function PostInteractionSettingsDialogControlledInner(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Lives outside the component because the early `return []` inside a `useMemo`
|
||||
* is memoization React Compiler cannot preserve.
|
||||
*/
|
||||
function getToggleGroupValues(settings: ThreadgateAllowUISetting[]): string[] {
|
||||
const values: string[] = []
|
||||
for (const setting of settings) {
|
||||
switch (setting.type) {
|
||||
case 'everybody':
|
||||
case 'nobody':
|
||||
// no granularity, early return with nothing
|
||||
return []
|
||||
case 'followers':
|
||||
values.push('followers')
|
||||
break
|
||||
case 'following':
|
||||
values.push('following')
|
||||
break
|
||||
case 'mention':
|
||||
values.push('mention')
|
||||
break
|
||||
case 'list':
|
||||
values.push(`list:${setting.list}`)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
||||
export function PostInteractionSettingsForm({
|
||||
canSave = true,
|
||||
onSave,
|
||||
@@ -348,32 +379,7 @@ export function PostInteractionSettingsForm({
|
||||
v => v.type === 'list',
|
||||
).length
|
||||
|
||||
const toggleGroupValues = useMemo(() => {
|
||||
const values: string[] = []
|
||||
for (const setting of threadgateAllowUISettings) {
|
||||
switch (setting.type) {
|
||||
case 'everybody':
|
||||
case 'nobody':
|
||||
// no granularity, early return with nothing
|
||||
return []
|
||||
case 'followers':
|
||||
values.push('followers')
|
||||
break
|
||||
case 'following':
|
||||
values.push('following')
|
||||
break
|
||||
case 'mention':
|
||||
values.push('mention')
|
||||
break
|
||||
case 'list':
|
||||
values.push(`list:${setting.list}`)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
return values
|
||||
}, [threadgateAllowUISettings])
|
||||
const toggleGroupValues = getToggleGroupValues(threadgateAllowUISettings)
|
||||
|
||||
const toggleGroupOnChange = (values: string[]) => {
|
||||
const settings: ThreadgateAllowUISetting[] = []
|
||||
|
||||
@@ -8,7 +8,7 @@ import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
||||
import {useCloseAllActiveElements} from '#/state/util'
|
||||
import {Logo} from '#/view/icons/Logo'
|
||||
import {Logotype} from '#/view/icons/Logotype'
|
||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
||||
import {Button, ButtonText} from '#/components/Button'
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
|
||||
@@ -45,7 +45,7 @@ function SigninDialogInner({}: {control: Dialog.DialogOuterProps['control']}) {
|
||||
return (
|
||||
<Dialog.ScrollableInner
|
||||
label={_(msg`Sign in to Bluesky or create a new account`)}
|
||||
style={[gtMobile ? {width: 'auto', maxWidth: 420} : a.w_full]}>
|
||||
style={[a.w_full, gtMobile && web({width: 'auto', maxWidth: 420})]}>
|
||||
<View style={[!IS_NATIVE && a.p_2xl]}>
|
||||
<View
|
||||
style={[
|
||||
|
||||
@@ -102,7 +102,7 @@ export function CreateListFromStarterPackDialog({
|
||||
await until(
|
||||
5,
|
||||
1e3,
|
||||
(res: {items: unknown[]}) => res.items.length > 0,
|
||||
res => !!res?.items.length,
|
||||
() =>
|
||||
appviewClient.call(app.bsky.graph.getList, {
|
||||
list: listUri as AtUriString,
|
||||
|
||||
@@ -221,6 +221,16 @@ function DialogInner({
|
||||
const onPressSave = useCallback(async () => {
|
||||
setImageError('')
|
||||
setDisplayNameTooShort(false)
|
||||
/*
|
||||
* Hoisted above the `try`: React Compiler cannot lower a conditional
|
||||
* expression inside one.
|
||||
*/
|
||||
const updatedMessage = isCurateList
|
||||
? _(msg({message: 'User list updated', context: 'toast'}))
|
||||
: _(msg({message: 'Moderation list updated', context: 'toast'}))
|
||||
const createdMessage = isCurateList
|
||||
? _(msg({message: 'User list created', context: 'toast'}))
|
||||
: _(msg({message: 'Moderation list created', context: 'toast'}))
|
||||
try {
|
||||
if (displayName.length === 0) {
|
||||
setDisplayNameTooShort(true)
|
||||
@@ -244,11 +254,7 @@ function DialogInner({
|
||||
descriptionFacets: richText.facets,
|
||||
avatar: newListAvatar,
|
||||
})
|
||||
Toast.show(
|
||||
isCurateList
|
||||
? _(msg({message: 'User list updated', context: 'toast'}))
|
||||
: _(msg({message: 'Moderation list updated', context: 'toast'})),
|
||||
)
|
||||
Toast.show(updatedMessage)
|
||||
control.close(() => onSave?.(list.uri))
|
||||
} else {
|
||||
const {uri} = await createListMutation({
|
||||
@@ -258,11 +264,7 @@ function DialogInner({
|
||||
descriptionFacets: richText.facets,
|
||||
avatar: newListAvatar,
|
||||
})
|
||||
Toast.show(
|
||||
isCurateList
|
||||
? _(msg({message: 'User list created', context: 'toast'}))
|
||||
: _(msg({message: 'Moderation list created', context: 'toast'})),
|
||||
)
|
||||
Toast.show(createdMessage)
|
||||
control.close(() => onSave?.(uri))
|
||||
}
|
||||
} catch (e: any) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
|
||||
import {urls} from '#/lib/constants'
|
||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
||||
import {Button, ButtonText} from '#/components/Button'
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
import {useNuxDialogContext} from '#/components/dialogs/nuxs'
|
||||
@@ -38,7 +38,8 @@ export function InitialVerificationAnnouncement() {
|
||||
<Dialog.ScrollableInner
|
||||
label={_(msg`Announcing verification on Bluesky`)}
|
||||
style={[
|
||||
gtMobile ? {width: 'auto', maxWidth: 400, minWidth: 200} : a.w_full,
|
||||
a.w_full,
|
||||
gtMobile && web({width: 'auto', maxWidth: 400, minWidth: 200}),
|
||||
]}>
|
||||
<View style={[a.align_start, a.gap_xl]}>
|
||||
<View
|
||||
|
||||
@@ -116,14 +116,15 @@ function Inner({
|
||||
setActiveNux(undefined)
|
||||
}, [activeNux, setActiveNux])
|
||||
|
||||
if (__DEV__ && typeof window !== 'undefined') {
|
||||
// @ts-expect-error
|
||||
useEffect(() => {
|
||||
if (!__DEV__ || typeof window === 'undefined') return
|
||||
// @ts-expect-error debug only
|
||||
window.clearNuxDialog = (id: Nux) => {
|
||||
if (!__DEV__ || !id) return
|
||||
if (!id) return
|
||||
resetNuxs([id])
|
||||
unsnooze()
|
||||
}
|
||||
}
|
||||
}, [resetNuxs])
|
||||
|
||||
useEffect(() => {
|
||||
if (snoozed) return // comment this out to test
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import {createSinglePathSVG} from './TEMPLATE'
|
||||
|
||||
export const ExclamationCircle_Stroke2_Corner0_Rounded = createSinglePathSVG({
|
||||
path: 'M20 12a8 8 0 1 0-16 0 8 8 0 0 0 16 0m2 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-10.843.256-.47-3.768a1.324 1.324 0 1 1 2.627 0l-.47 3.768a.85.85 0 0 1-1.687 0M12 17a1.2 1.2 0 1 0 0-2.4 1.2 1.2 0 0 0 0 2.4',
|
||||
})
|
||||
@@ -5,7 +5,7 @@ import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
|
||||
import {usePdsClient, useSession} from '#/state/session'
|
||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
import {type DialogControlProps} from '#/components/Dialog'
|
||||
@@ -62,7 +62,8 @@ function Inner({}: {control: DialogControlProps}) {
|
||||
<Dialog.ScrollableInner
|
||||
label={_(msg`Verify email dialog`)}
|
||||
style={[
|
||||
gtMobile ? {width: 'auto', maxWidth: 400, minWidth: 200} : a.w_full,
|
||||
a.w_full,
|
||||
gtMobile && web({width: 'auto', maxWidth: 400, minWidth: 200}),
|
||||
]}>
|
||||
<View style={[a.gap_xl]}>
|
||||
{status === 'loading' ? (
|
||||
|
||||
@@ -101,35 +101,28 @@ function ContentHiderActive({
|
||||
}
|
||||
}
|
||||
|
||||
const selfBlurCauses = []
|
||||
let hasAdultContentLabel = false
|
||||
const selfBlurNames = modui.blurs
|
||||
.filter(cause => {
|
||||
if (cause.type !== 'label') {
|
||||
return false
|
||||
}
|
||||
if (cause.source.type !== 'user') {
|
||||
return false
|
||||
}
|
||||
if (ADULT_CONTENT_LABELS.includes(cause.label.val as AdultSelfLabel)) {
|
||||
if (hasAdultContentLabel) {
|
||||
return false
|
||||
}
|
||||
hasAdultContentLabel = true
|
||||
}
|
||||
return true
|
||||
})
|
||||
.slice(0, 2)
|
||||
.map(cause => {
|
||||
if (cause.type !== 'label') {
|
||||
return
|
||||
}
|
||||
for (const cause of modui.blurs) {
|
||||
if (cause.type !== 'label') continue
|
||||
if (cause.source.type !== 'user') continue
|
||||
if (ADULT_CONTENT_LABELS.includes(cause.label.val as AdultSelfLabel)) {
|
||||
if (hasAdultContentLabel) continue
|
||||
hasAdultContentLabel = true
|
||||
}
|
||||
selfBlurCauses.push(cause)
|
||||
}
|
||||
const selfBlurNames = selfBlurCauses.slice(0, 2).map(cause => {
|
||||
if (cause.type !== 'label') {
|
||||
return
|
||||
}
|
||||
|
||||
const def = cause.labelDef || getDefinition(labelDefs, cause.label)
|
||||
if (def.identifier === 'porn' || def.identifier === 'sexual') {
|
||||
return l`Adult Content`
|
||||
}
|
||||
return getLabelStrings(i18n.locale, globalLabelStrings, def).name
|
||||
})
|
||||
const def = cause.labelDef || getDefinition(labelDefs, cause.label)
|
||||
if (def.identifier === 'porn' || def.identifier === 'sexual') {
|
||||
return l`Adult Content`
|
||||
}
|
||||
return getLabelStrings(i18n.locale, globalLabelStrings, def).name
|
||||
})
|
||||
|
||||
if (selfBlurNames.length === 0) {
|
||||
return desc.name
|
||||
|
||||
@@ -18,7 +18,7 @@ import {sanitizeHandle} from '#/lib/strings/handles'
|
||||
import {useMyLabelersQuery} from '#/state/queries/preferences'
|
||||
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
|
||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||
import {atoms as a, useGutters, useTheme} from '#/alf'
|
||||
import {atoms as a, useGutters, useTheme, web} from '#/alf'
|
||||
import * as Admonition from '#/components/Admonition'
|
||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
@@ -92,7 +92,7 @@ export function ReportDialog(
|
||||
openCount: number
|
||||
videoTimestampSeconds?: number
|
||||
}>({openCount: 0})
|
||||
const onOpen = useCallback(() => {
|
||||
const onOpen = () => {
|
||||
const seconds =
|
||||
subject?.type === 'post' && subject.attributes.video
|
||||
? reportDialogMetadata?.current.videoTimestampSeconds
|
||||
@@ -105,7 +105,7 @@ export function ReportDialog(
|
||||
videoTimestampSeconds:
|
||||
seconds !== undefined && seconds >= 1 ? Math.floor(seconds) : undefined,
|
||||
}))
|
||||
}, [reportDialogMetadata, subject])
|
||||
}
|
||||
const propsOnClose = props.onClose
|
||||
const onClose = useCallback(() => {
|
||||
ax.metric('reportDialog:close', {})
|
||||
@@ -334,7 +334,7 @@ function Inner(
|
||||
testID="report:dialog"
|
||||
label={l`Report dialog`}
|
||||
ref={ref}
|
||||
style={[a.w_full, {maxWidth: 500}]}>
|
||||
style={[a.w_full, web({maxWidth: 500})]}>
|
||||
<View style={[a.gap_2xl, IS_NATIVE && a.pt_md]}>
|
||||
<StepOuter>
|
||||
<StepTitle
|
||||
|
||||
@@ -8,7 +8,7 @@ import {getUserDisplayName} from '#/lib/getUserDisplayName'
|
||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||
import {useProfileQuery} from '#/state/queries/profile'
|
||||
import {useSession} from '#/state/session'
|
||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
||||
import {Admonition} from '#/components/Admonition'
|
||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
@@ -78,7 +78,8 @@ function Inner({
|
||||
<Dialog.ScrollableInner
|
||||
label={label}
|
||||
style={[
|
||||
gtMobile ? {width: 'auto', maxWidth: 400, minWidth: 200} : a.w_full,
|
||||
a.w_full,
|
||||
gtMobile && web({width: 'auto', maxWidth: 400, minWidth: 200}),
|
||||
]}>
|
||||
<View style={[a.gap_sm, a.pb_lg]}>
|
||||
<Text style={[a.text_2xl, a.font_semi_bold, a.pr_4xl, a.leading_tight]}>
|
||||
|
||||
@@ -7,7 +7,7 @@ import {Trans} from '@lingui/react/macro'
|
||||
import {urls} from '#/lib/constants'
|
||||
import {getUserDisplayName} from '#/lib/getUserDisplayName'
|
||||
import {useSession} from '#/state/session'
|
||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
||||
import {Button, ButtonText} from '#/components/Button'
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
import {VerifierCheck} from '#/components/icons/VerifierCheck'
|
||||
@@ -65,7 +65,8 @@ function Inner({
|
||||
<Dialog.ScrollableInner
|
||||
label={label}
|
||||
style={[
|
||||
gtMobile ? {width: 'auto', maxWidth: 400, minWidth: 200} : a.w_full,
|
||||
a.w_full,
|
||||
gtMobile && web({width: 'auto', maxWidth: 400, minWidth: 200}),
|
||||
]}>
|
||||
<View style={[a.gap_lg]}>
|
||||
<View
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {useEffect} from 'react'
|
||||
import {useEffect, useEffectEvent} from 'react'
|
||||
import {Pressable, View} from 'react-native'
|
||||
import {Image} from 'expo-image'
|
||||
import {useLingui} from '@lingui/react/macro'
|
||||
@@ -19,11 +19,14 @@ export function FollowersPromoBanner({
|
||||
const t = useTheme()
|
||||
const ax = useAnalytics()
|
||||
|
||||
useEffect(() => {
|
||||
const onSeen = useEffectEvent(() => {
|
||||
ax.metric('invite:followersPromo:seen', {})
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
// Fire once per mount - parent unmounts the banner when followers > 0 or
|
||||
// when dismissed, so each mount is a distinct impression.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
onSeen()
|
||||
}, [])
|
||||
|
||||
const handlePress = () => {
|
||||
|
||||
@@ -6,7 +6,6 @@ import {moderateStatus} from '@bsky/sdk/moderation'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||
import {isAfter, parseISO} from 'date-fns'
|
||||
|
||||
import {uploadBlob} from '#/lib/api'
|
||||
import {imageToThumb} from '#/lib/api/resolve'
|
||||
@@ -23,7 +22,11 @@ import {useTickEveryMinute} from '#/state/shell'
|
||||
import {useDialogContext} from '#/components/Dialog'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {getLiveNowHost, getLiveServiceNames} from '#/features/liveNow/utils'
|
||||
import {
|
||||
getLiveNowHost,
|
||||
getLiveServiceNames,
|
||||
isStatusStillActive,
|
||||
} from '#/features/liveNow/utils'
|
||||
import {app, com} from '#/lexicons'
|
||||
import * as bsky from '#/types/bsky'
|
||||
|
||||
@@ -151,14 +154,6 @@ export function useActorStatus(actor?: bsky.profile.AnyProfileView) {
|
||||
}, [shadowed, config, tick, moderation])
|
||||
}
|
||||
|
||||
export function isStatusStillActive(timeStr: string | undefined) {
|
||||
if (!timeStr) return false
|
||||
const now = new Date()
|
||||
const expiry = parseISO(timeStr)
|
||||
|
||||
return isAfter(expiry, now)
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates whether the live status is valid for display in the app. Does NOT
|
||||
* validate if the status is valid for the acting user e.g. as they go live.
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import {isStatusStillActive} from '#/features/liveNow/utils'
|
||||
|
||||
describe('isStatusStillActive', () => {
|
||||
const iso = (offsetMs: number) =>
|
||||
new Date(Date.now() + offsetMs).toISOString()
|
||||
|
||||
it('is active for a future expiry', () => {
|
||||
expect(isStatusStillActive(iso(60_000))).toBe(true)
|
||||
})
|
||||
|
||||
it('is not active for a past expiry', () => {
|
||||
expect(isStatusStillActive(iso(-60_000))).toBe(false)
|
||||
})
|
||||
|
||||
it('is not active without a value', () => {
|
||||
expect(isStatusStillActive(undefined)).toBe(false)
|
||||
expect(isStatusStillActive('')).toBe(false)
|
||||
})
|
||||
|
||||
/*
|
||||
* The predicate reads an atproto `datetime`, which always carries an offset.
|
||||
* An unparseable value yields NaN, and every NaN comparison is false, so a
|
||||
* bad timestamp reads as "not live" rather than throwing or showing a stale
|
||||
* live badge.
|
||||
*/
|
||||
it('is not active for an unparseable value', () => {
|
||||
expect(isStatusStillActive('not-a-date')).toBe(false)
|
||||
})
|
||||
|
||||
it('handles offsets and fractional seconds', () => {
|
||||
const future = new Date(Date.now() + 3_600_000)
|
||||
expect(isStatusStillActive(future.toISOString())).toBe(true)
|
||||
expect(isStatusStillActive('2000-01-01T00:00:00.123+00:00')).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -97,3 +97,16 @@ export function getLiveNowHost(url: string) {
|
||||
const {hostname} = new URL(url)
|
||||
return sanitizeLiveNowHost(hostname)
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a live status has not yet expired.
|
||||
*
|
||||
* Called per post, per render while scrolling, so this stays on primitives -
|
||||
* `parseISO` plus two `Date` objects showed up in the scroll profile.
|
||||
* `Date.parse` returns `NaN` for an unparseable value and `NaN > n` is `false`,
|
||||
* which is the same "not active" answer the date-fns version gave.
|
||||
*/
|
||||
export function isStatusStillActive(timeStr: string | undefined) {
|
||||
if (!timeStr) return false
|
||||
return Date.parse(timeStr) > Date.now()
|
||||
}
|
||||
|
||||
@@ -9,4 +9,5 @@ export const GEOLOCATION_SERVICE_URL = `${GEOLOCATION_URL}/geolocation`
|
||||
export const FALLBACK_GEOLOCATION_SERVICE_RESPONSE: Geolocation = {
|
||||
countryCode: undefined,
|
||||
regionCode: undefined,
|
||||
city: undefined,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export type Geolocation = {
|
||||
countryCode: string | undefined
|
||||
regionCode: string | undefined
|
||||
/** Only populated by the IP-based geolocation service. */
|
||||
city?: string
|
||||
serviceGeolocation?: Geolocation
|
||||
deviceGeolocation?: Geolocation
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import {type app} from '#/lexicons'
|
||||
import {createFeedViewPostsSlices} from './feed-manip'
|
||||
|
||||
jest.mock('./feed/home', () => ({
|
||||
FALLBACK_MARKER_POST: {post: {uri: 'at://did:plc:test/app.bsky.feed.post/1'}},
|
||||
}))
|
||||
|
||||
const author = {
|
||||
$type: 'app.bsky.actor.defs#profileViewBasic',
|
||||
did: 'did:plc:alice',
|
||||
handle: 'alice.test',
|
||||
} as app.bsky.actor.defs.ProfileViewBasic
|
||||
|
||||
function post(id: string) {
|
||||
return {
|
||||
$type: 'app.bsky.feed.defs#postView',
|
||||
uri: `at://did:plc:alice/app.bsky.feed.post/${id}`,
|
||||
cid: id,
|
||||
author,
|
||||
record: {
|
||||
$type: 'app.bsky.feed.post',
|
||||
text: id,
|
||||
createdAt: '2026-08-31T00:00:00.000Z',
|
||||
},
|
||||
indexedAt: '2026-08-31T00:00:00.000Z',
|
||||
} as app.bsky.feed.defs.PostView
|
||||
}
|
||||
|
||||
describe('createFeedViewPostsSlices', () => {
|
||||
it('preserves selected numbering and infers hydrated parent and root numbering', () => {
|
||||
const root = post('root')
|
||||
const parent = post('parent')
|
||||
const selected = post('selected')
|
||||
const feedPost = {
|
||||
post: selected,
|
||||
reply: {root, parent},
|
||||
opThreadPostIndex: 3,
|
||||
opThreadPostCount: 4,
|
||||
} as app.bsky.feed.defs.FeedViewPost & {
|
||||
opThreadPostIndex: number
|
||||
opThreadPostCount: number
|
||||
}
|
||||
|
||||
const [slice] = createFeedViewPostsSlices([feedPost])
|
||||
|
||||
expect(
|
||||
slice.items.map(item => [item.post.uri, item.postNumbering]),
|
||||
).toEqual([
|
||||
[root.uri, {opThreadPostIndex: 1, opThreadPostCount: 4}],
|
||||
[parent.uri, {opThreadPostIndex: 2, opThreadPostCount: 4}],
|
||||
[selected.uri, {opThreadPostIndex: 3, opThreadPostCount: 4}],
|
||||
])
|
||||
})
|
||||
})
|
||||
+20
-14
@@ -9,7 +9,7 @@ export type FeedPostNumbering = Pick<
|
||||
'opThreadPostIndex' | 'opThreadPostCount'
|
||||
>
|
||||
|
||||
type ValidFeedPostNumbering = Required<FeedPostNumbering>
|
||||
export type ValidFeedPostNumbering = Required<FeedPostNumbering>
|
||||
|
||||
// AppView adds these fields to feed responses ahead of their feed lexicon.
|
||||
type FeedViewPost = app.bsky.feed.defs.FeedViewPost & FeedPostNumbering
|
||||
@@ -62,7 +62,7 @@ export type FeedTunerFn = (
|
||||
type FeedSliceItem = {
|
||||
post: app.bsky.feed.defs.PostView
|
||||
record: app.bsky.feed.post.Main
|
||||
postNumbering: FeedPostNumbering | undefined
|
||||
postNumbering: ValidFeedPostNumbering | undefined
|
||||
parentAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
isParentBlocked: boolean
|
||||
isParentNotFound: boolean
|
||||
@@ -88,7 +88,7 @@ export class FeedViewPostsSlice {
|
||||
|
||||
constructor(
|
||||
feedPost: FeedViewPost,
|
||||
postNumberingByUri: Map<string, FeedPostNumbering>,
|
||||
postNumberingByUri: Map<string, ValidFeedPostNumbering>,
|
||||
) {
|
||||
const {post, reply, reason} = feedPost
|
||||
this.items = []
|
||||
@@ -286,6 +286,22 @@ export class FeedViewPostsSlice {
|
||||
}
|
||||
}
|
||||
|
||||
export function createFeedViewPostsSlices(
|
||||
feed: FeedViewPost[],
|
||||
): FeedViewPostsSlice[] {
|
||||
const postNumberingByUri = new Map<string, ValidFeedPostNumbering>()
|
||||
for (const item of feed) {
|
||||
const postNumbering = getPostNumbering(item)
|
||||
if (postNumbering) {
|
||||
postNumberingByUri.set(item.post.uri, postNumbering)
|
||||
}
|
||||
}
|
||||
|
||||
return feed
|
||||
.map(item => new FeedViewPostsSlice(item, postNumberingByUri))
|
||||
.filter(slice => slice.items.length > 0 || slice.isFallbackMarker)
|
||||
}
|
||||
|
||||
export class FeedTuner {
|
||||
seenKeys: Set<string> = new Set()
|
||||
seenUris: Set<string> = new Set()
|
||||
@@ -299,17 +315,7 @@ export class FeedTuner {
|
||||
dryRun: false,
|
||||
},
|
||||
): FeedViewPostsSlice[] {
|
||||
const postNumberingByUri = new Map<string, FeedPostNumbering>()
|
||||
for (const item of feed) {
|
||||
const postNumbering = getPostNumbering(item)
|
||||
if (postNumbering) {
|
||||
postNumberingByUri.set(item.post.uri, postNumbering)
|
||||
}
|
||||
}
|
||||
|
||||
let slices: FeedViewPostsSlice[] = feed
|
||||
.map(item => new FeedViewPostsSlice(item, postNumberingByUri))
|
||||
.filter(s => s.items.length > 0 || s.isFallbackMarker)
|
||||
let slices = createFeedViewPostsSlices(feed)
|
||||
|
||||
// run the custom tuners
|
||||
for (const tunerFn of this.tunerFns) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import {isRetryableRequestError} from '#/lib/async/retry'
|
||||
|
||||
describe('retry', () => {
|
||||
it('identifies retryable request errors', () => {
|
||||
expect(isRetryableRequestError(new TypeError('Failed to fetch'))).toBe(true)
|
||||
expect(isRetryableRequestError(new Error('Invalid request'))).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,9 @@
|
||||
import {timeout} from '#/lib/async/timeout'
|
||||
import {isNetworkError} from '#/lib/strings/errors'
|
||||
import {isNetworkError, shouldRetryError} from '#/lib/strings/errors'
|
||||
|
||||
export function isRetryableRequestError(error: unknown) {
|
||||
return isNetworkError(error) || shouldRetryError(error)
|
||||
}
|
||||
|
||||
export async function retry<P>(
|
||||
retries: number,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import {describe, expect, it, jest} from '@jest/globals'
|
||||
|
||||
import {until} from './until'
|
||||
|
||||
describe('until', () => {
|
||||
it('passes attempt errors to the condition', async () => {
|
||||
const error = new Error('failed')
|
||||
const fn = jest
|
||||
.fn<() => Promise<string>>()
|
||||
.mockRejectedValueOnce(error)
|
||||
.mockResolvedValue('ready')
|
||||
const cond = jest.fn((value: string | undefined) => value === 'ready')
|
||||
|
||||
await expect(until(2, 0, cond, fn)).resolves.toBe(true)
|
||||
expect(fn).toHaveBeenCalledTimes(2)
|
||||
expect(cond).toHaveBeenNthCalledWith(1, undefined, error)
|
||||
expect(cond).toHaveBeenNthCalledWith(2, 'ready', undefined)
|
||||
})
|
||||
|
||||
it('returns false when every attempt rejects', async () => {
|
||||
const fn = jest
|
||||
.fn<() => Promise<string>>()
|
||||
.mockRejectedValue(new Error('failed'))
|
||||
const cond = jest.fn((_value: string | undefined) => false)
|
||||
|
||||
await expect(until(2, 0, cond, fn)).resolves.toBe(false)
|
||||
expect(fn).toHaveBeenCalledTimes(2)
|
||||
expect(cond).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('can stop when an attempt rejects', async () => {
|
||||
const error = new Error('failed')
|
||||
const fn = jest.fn<() => Promise<string>>().mockRejectedValue(error)
|
||||
const cond = jest.fn(
|
||||
(_value: string | undefined, err: unknown) => err === error,
|
||||
)
|
||||
|
||||
await expect(until(2, 0, cond, fn)).resolves.toBe(true)
|
||||
expect(fn).toHaveBeenCalledTimes(1)
|
||||
expect(cond).toHaveBeenCalledWith(undefined, error)
|
||||
})
|
||||
})
|
||||
@@ -1,9 +1,12 @@
|
||||
import {timeout} from './timeout'
|
||||
|
||||
/**
|
||||
* Retries an async operation until its result or error matches `cond`.
|
||||
*/
|
||||
export async function until<T>(
|
||||
retries: number,
|
||||
delay: number,
|
||||
cond: (v: T, err: any) => boolean,
|
||||
cond: (v: T | undefined, err: unknown) => boolean,
|
||||
fn: () => Promise<T>,
|
||||
): Promise<boolean> {
|
||||
while (retries > 0) {
|
||||
@@ -12,10 +15,8 @@ export async function until<T>(
|
||||
if (cond(v, undefined)) {
|
||||
return true
|
||||
}
|
||||
} catch (e: any) {
|
||||
// TODO: change the type signature of cond to accept undefined
|
||||
// however this breaks every existing usage of until -sfn
|
||||
if (cond(undefined as unknown as T, e)) {
|
||||
} catch (err) {
|
||||
if (cond(undefined, err)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user