chore(release): promote Private Zoom rename to pre
Docker Image / Build and Push Docker Image (push) Successful in 2m34s

This commit is contained in:
Codex
2026-07-22 18:31:36 +08:00
102 changed files with 695 additions and 519 deletions
+3 -3
View File
@@ -25,9 +25,9 @@
"./src/data/schemas/payment", "./src/data/schemas/payment",
"./src/data/schemas/payment/request", "./src/data/schemas/payment/request",
"./src/data/schemas/payment/response", "./src/data/schemas/payment/response",
"./src/data/schemas/private-room", "./src/data/schemas/private-zoom",
"./src/data/schemas/private-room/request", "./src/data/schemas/private-zoom/request",
"./src/data/schemas/private-room/response", "./src/data/schemas/private-zoom/response",
"./src/data/schemas/user", "./src/data/schemas/user",
"./src/data/storage/app", "./src/data/storage/app",
"./src/data/storage/auth", "./src/data/storage/auth",
+5 -5
View File
@@ -63,7 +63,7 @@ Authorization: Bearer <TOKEN>
2. `isActive=true` 2. `isActive=true`
3. `capabilities.chat=true` 3. `capabilities.chat=true`
服务端目录决定角色是否可聊天及排序;本地目录继续提供 slug、图片、文案和 Tip 能力。`privateRoom` 只有在本地能力和服务端 `privateContent` 同时开启时可用。 服务端目录决定角色是否可聊天及排序;本地目录继续提供 slug、图片、文案和 Tip 能力。`privateZoom` 只有在本地能力和服务端 `privateContent` 同时开启时可用。
远端目录返回前,生产环境只使用 Elio 作为临时目录;非生产环境可使用完整本地目录。远端目录加载成功后,以合并结果为准。 远端目录返回前,生产环境只使用 Elio 作为临时目录;非生产环境可使用完整本地目录。远端目录加载成功后,以合并结果为准。
@@ -72,7 +72,7 @@ Authorization: Bearer <TOKEN>
```text ```text
/characters/{slug}/splash /characters/{slug}/splash
/characters/{slug}/chat /characters/{slug}/chat
/characters/{slug}/private-room /characters/{slug}/private-zoom
/characters/{slug}/tip /characters/{slug}/tip
``` ```
@@ -81,11 +81,11 @@ Authorization: Bearer <TOKEN>
```text ```text
/splash -> /characters/elio/splash /splash -> /characters/elio/splash
/chat -> /characters/elio/chat /chat -> /characters/elio/chat
/private-room -> /characters/elio/private-room /private-zoom -> /characters/elio/private-zoom
/tip -> /characters/elio/tip /tip -> /characters/elio/tip
``` ```
Chat Provider 以 `characterId` 为边界,路由角色变化时创建新的 Actor。Private Room 的角色边界由 [Private Room 权威协议](./FRONTEND_PRIVATE_ROOM_API.md) 定义。 Chat Provider 以 `characterId` 为边界,路由角色变化时创建新的 Actor。Private Zoom 的角色边界由 [Private Zoom 权威协议](./FRONTEND_PRIVATE_ZOOM_API.md) 定义。
## 3. Chat HTTP 协议 ## 3. Chat HTTP 协议
@@ -308,7 +308,7 @@ conversationKey = {ownerKey}::character:{encodeURIComponent(characterId)}
## 7. 关联业务边界 ## 7. 关联业务边界
- Private Room 的相册、解锁、Gallery 和支付回跳由 [Private Room 权威协议](./FRONTEND_PRIVATE_ROOM_API.md) 定义。 - Private Zoom 的相册、解锁、Gallery 和支付回跳由 [Private Zoom 权威协议](./FRONTEND_PRIVATE_ZOOM_API.md) 定义。
- Tip 的角色归属、订单轮询和支付回跳由 [Payment 权威协议](./FRONTEND_PAYMENT_API.md) 定义;Chat 只保存解锁所需的原角色回跳地址。 - Tip 的角色归属、订单轮询和支付回跳由 [Payment 权威协议](./FRONTEND_PAYMENT_API.md) 定义;Chat 只保存解锁所需的原角色回跳地址。
- 登录、支付和解锁回跳保存原角色动态 URL,不能降级为通用 `/chat` - 登录、支付和解锁回跳保存原角色动态 URL,不能降级为通用 `/chat`
- Analytics 可以使用 `characterId`,聊天正文不属于路由或身份协议的一部分。 - Analytics 可以使用 `characterId`,聊天正文不属于路由或身份协议的一部分。
+2 -2
View File
@@ -224,7 +224,7 @@ payChannel = ezpay
subscriptionType = vip | topup | tip subscriptionType = vip | topup | tip
giftCategory(仅 Tip,可空) giftCategory(仅 Tip,可空)
giftPlanId(仅 Tip,可空) giftPlanId(仅 Tip,可空)
returnTo = chat | private-room | profile(可选) returnTo = chat | private-zoom | profile(可选)
characterSlug(可选) characterSlug(可选)
createdAt createdAt
``` ```
@@ -238,7 +238,7 @@ Tip -> /characters/{slug}/tip?category=...&planId=...&payChannel=ezpay&
恢复页面只接受与当前 `paymentType` 相同的待处理订单。带有 `paymentReturn=1` 时派发 `PaymentReturned` 并继续轮询;普通进入支付页时会清理同类型的旧待处理订单。订单进入 paid、failed 或 expired 后清理持久化记录。缺少 Gift 字段的旧记录由最新目录默认选择第一件商品,不再读取 `coffee_type` 恢复页面只接受与当前 `paymentType` 相同的待处理订单。带有 `paymentReturn=1` 时派发 `PaymentReturned` 并继续轮询;普通进入支付页时会清理同类型的旧待处理订单。订单进入 paid、failed 或 expired 后清理持久化记录。缺少 Gift 字段的旧记录由最新目录默认选择第一件商品,不再读取 `coffee_type`
无效或未知 `characterSlug` 回退到默认角色 slug。有效角色回跳必须保留原角色,不能统一返回 Elio。`returnTo=private-room` 的最终页面行为由 [Private Room 权威协议](./FRONTEND_PRIVATE_ROOM_API.md) 定义。 无效或未知 `characterSlug` 回退到默认角色 slug。有效角色回跳必须保留原角色,不能统一返回 Elio。`returnTo=private-zoom` 的最终页面行为由 [Private Zoom 权威协议](./FRONTEND_PRIVATE_ZOOM_API.md) 定义。
## 8. 成功后的跨域同步 ## 8. 成功后的跨域同步
@@ -1,4 +1,4 @@
# CozSweet Private Room 权威协议 # CozSweet Private Zoom 权威协议
## 1. 状态与范围 ## 1. 状态与范围
@@ -9,11 +9,11 @@
| 边界 | 实现位置 | | 边界 | 实现位置 |
| --- | --- | | --- | --- |
| API 路径与方法 | `src/data/services/api/api_contract.json` | | API 路径与方法 | `src/data/services/api/api_contract.json` |
| 请求与响应字段 | `src/data/schemas/private-room` | | 请求与响应字段 | `src/data/schemas/private-zoom` |
| API 与 Repository | `src/data/services/api/private_room_api.ts``src/data/repositories/private_room_repository.ts` | | API 与 Repository | `src/data/services/api/private_zoom_api.ts``src/data/repositories/private_zoom_repository.ts` |
| Private Room 状态机 | `src/stores/private-room` | | Private Zoom 状态机 | `src/stores/private-zoom` |
| 页面、Gallery 与导航 | `src/app/private-room` | | 页面、Gallery 与导航 | `src/app/private-zoom` |
| 角色 Provider | `src/providers/private-room-route-provider.tsx` | | 角色 Provider | `src/providers/private-zoom-route-provider.tsx` |
修改上述实现时必须在同一变更中更新本文,不能再新增按相册列表、解锁或 Gallery 拆分的并行协议。 修改上述实现时必须在同一变更中更新本文,不能再新增按相册列表、解锁或 Gallery 拆分的并行协议。
@@ -22,13 +22,13 @@
标准路由: 标准路由:
```text ```text
/characters/{characterSlug}/private-room /characters/{characterSlug}/private-zoom
``` ```
旧地址保留为默认角色重定向,并保留查询参数: 旧地址保留为默认角色重定向,并保留查询参数:
```text ```text
/private-room -> /characters/elio/private-room /private-zoom -> /characters/elio/private-zoom
``` ```
URL 使用角色 `slug`,API 和 Actor 使用角色业务 `id` URL 使用角色 `slug`,API 和 Actor 使用角色业务 `id`
@@ -39,14 +39,14 @@ URL 使用角色 `slug`API 和 Actor 使用角色业务 `id`
| `maya-tan` | `maya` | | `maya-tan` | `maya` |
| `nayeli-cervantes` | `nayeli` | | `nayeli-cervantes` | `nayeli` |
角色必须同时存在于本地目录且 `capabilities.privateRoom=true`。该能力由本地配置和角色目录响应的 `privateContent` 共同决定;能力关闭或 slug 未知时路由返回 Not Found。 角色必须同时存在于本地目录且 `capabilities.privateZoom=true`。该能力由本地配置和角色目录响应的 `privateContent` 共同决定;能力关闭或 slug 未知时路由返回 Not Found。
`PrivateRoomProvider``characterId` 为输入和 React key。切换角色会销毁旧 Actor 并创建空状态,不能复用上一角色的相册、余额或解锁请求。 `PrivateZoomProvider``characterId` 为输入和 React key。切换角色会销毁旧 Actor 并创建空状态,不能复用上一角色的相册、余额或解锁请求。
## 3. 相册列表 ## 3. 相册列表
```http ```http
GET <API_BASE_URL>/api/private-room/albums?characterId=maya-tan&limit=20 GET <API_BASE_URL>/api/private-zoom/albums?characterId=maya-tan&limit=20
Authorization: Bearer <TOKEN> Authorization: Bearer <TOKEN>
``` ```
@@ -55,7 +55,7 @@ Authorization: Bearer <TOKEN>
| `characterId` | 是 | 当前角色业务 ID | | `characterId` | 是 | 当前角色业务 ID |
| `limit` | 否 | 当前固定为 20 | | `limit` | 否 | 当前固定为 20 |
前端当前只加载第一页,不实现 Private Room 分页,也不把相册列表写入本地缓存。初始化、手动刷新或登录身份变化时重新请求网络。 前端当前只加载第一页,不实现 Private Zoom 分页,也不把相册列表写入本地缓存。初始化、手动刷新或登录身份变化时重新请求网络。
标准响应数据: 标准响应数据:
@@ -105,7 +105,7 @@ album.locked || !album.unlocked || album.lockDetail.locked
用户点击锁定相册后,前端先展示确认 Dialog。只有待确认 `albumId` 仍存在于当前 Actor 的 `items` 中,才会发起请求。 用户点击锁定相册后,前端先展示确认 Dialog。只有待确认 `albumId` 仍存在于当前 Actor 的 `items` 中,才会发起请求。
```http ```http
POST <API_BASE_URL>/api/private-room/albums/{albumId}/unlock POST <API_BASE_URL>/api/private-zoom/albums/{albumId}/unlock
Content-Type: application/json Content-Type: application/json
Authorization: Bearer <TOKEN> Authorization: Bearer <TOKEN>
``` ```
@@ -177,25 +177,25 @@ Schema 同时允许未知字符串,未知失败原因使用通用错误文案
## 5. 身份与支付导航 ## 5. 身份与支付导航
Private Room 初始化会复用 Guest 登录引导。Auth 尚未初始化或正在加载时不请求列表;`notLoggedIn` 完成 Guest bootstrap 后再进入列表加载。Guest 和正式用户都可以读取后端允许的相册列表。 Private Zoom 初始化会复用 Guest 登录引导。Auth 尚未初始化或正在加载时不请求列表;`notLoggedIn` 完成 Guest bootstrap 后再进入列表加载。Guest 和正式用户都可以读取后端允许的相册列表。
积分不足生成 Paywall 请求后: 积分不足生成 Paywall 请求后:
| 当前身份 | 导航 | | 当前身份 | 导航 |
| --- | --- | | --- | --- |
| Guest 或 Not Logged In | 打开 Authredirect 为当前角色 Private Room | | Guest 或 Not Logged In | 打开 Authredirect 为当前角色 Private Zoom |
| 已认证用户 | 打开 Top-up,`returnTo=private-room`,保留当前角色来源 | | 已认证用户 | 打开 Top-up,`returnTo=private-zoom`,保留当前角色来源 |
Paywall 导航发起后立即消费当前请求,避免 React 重渲染重复导航。支付回跳和订单恢复遵循 [Payment 权威协议](./FRONTEND_PAYMENT_API.md)。 Paywall 导航发起后立即消费当前请求,避免 React 重渲染重复导航。支付回跳和订单恢复遵循 [Payment 权威协议](./FRONTEND_PAYMENT_API.md)。
解锁成功后 `unlockSuccessNonce` 递增,页面桥接到 `UserFetch`,刷新当前积分和权益。Private Room 不自行修改 User Store 余额。 解锁成功后 `unlockSuccessNonce` 递增,页面桥接到 `UserFetch`,刷新当前积分和权益。Private Zoom 不自行修改 User Store 余额。
## 6. Gallery URL 协议 ## 6. Gallery URL 协议
解锁相册使用查询参数打开页内 Gallery: 解锁相册使用查询参数打开页内 Gallery:
```text ```text
/characters/{slug}/private-room?album={albumId}&image={zeroBasedIndex} /characters/{slug}/private-zoom?album={albumId}&image={zeroBasedIndex}
``` ```
解析规则: 解析规则:
@@ -208,7 +208,7 @@ Paywall 导航发起后立即消费当前请求,避免 React 重渲染重复
任一条件不满足时,页面通过 replace 删除 `album``image`,并保留其他查询参数。 任一条件不满足时,页面通过 replace 删除 `album``image`,并保留其他查询参数。
页面内点击九宫格缩略图时,Gallery 从该图片的后端数组原始索引打开。关闭操作优先使用浏览器 back;直接刷新或外部分享 Gallery URL 时,关闭操作使用 replace 返回当前角色 Private Room。 页面内点击九宫格缩略图时,Gallery 从该图片的后端数组原始索引打开。关闭操作优先使用浏览器 back;直接刷新或外部分享 Gallery URL 时,关闭操作使用 replace 返回当前角色 Private Zoom。
Gallery 只浏览 `locked=false` 且 URL 非空的图片,但 URL 中的 `image` 仍使用原始数组索引。横向拖动时图片跟随指针,达到视口宽度 18%(最低 56px),或达到 0.45px/ms 且至少移动 24px 时切换;首尾越界拖动使用 0.28 阻尼且不循环。松手后使用 240ms 横向吸附动画,键盘方向键和左右按钮复用相同切换逻辑。Escape 关闭;`prefers-reduced-motion` 下取消吸附过渡。 Gallery 只浏览 `locked=false` 且 URL 非空的图片,但 URL 中的 `image` 仍使用原始数组索引。横向拖动时图片跟随指针,达到视口宽度 18%(最低 56px),或达到 0.45px/ms 且至少移动 24px 时切换;首尾越界拖动使用 0.28 阻尼且不循环。松手后使用 240ms 横向吸附动画,键盘方向键和左右按钮复用相同切换逻辑。Escape 关闭;`prefers-reduced-motion` 下取消吸附过渡。
@@ -222,17 +222,17 @@ Gallery 只浏览 `locked=false` 且 URL 非空的图片,但 URL 中的 `image
- 超过 9 张时卡片显示前九张,末格显示 `+N`,Gallery 仍可浏览全部有效图片; - 超过 9 张时卡片显示前九张,末格显示 `+N`,Gallery 仍可浏览全部有效图片;
- Gallery 只挂载当前图片和相邻图片,避免多图相册同时解码全部原图; - Gallery 只挂载当前图片和相邻图片,避免多图相册同时解码全部原图;
- `creditBalance` 是当前列表/解锁响应快照,不替代 User Store 权益; - `creditBalance` 是当前列表/解锁响应快照,不替代 User Store 权益;
- Private Room 不使用 Chat 的 `conversationKey`、消息缓存或媒体缓存; - Private Zoom 不使用 Chat 的 `conversationKey`、消息缓存或媒体缓存;
- Private Room 不持有 Payment ActorTop-up 通过路由级导航进入独立 Payment Provider。 - Private Zoom 不持有 Payment ActorTop-up 通过路由级导航进入独立 Payment Provider。
## 8. 变更验收 ## 8. 变更验收
Private Room 协议相关变更至少验证: Private Zoom 协议相关变更至少验证:
1. `src/data/schemas/private-room/__tests__` 1. `src/data/schemas/private-zoom/__tests__`
2. `src/data/services/api/__tests__/multi_character_api.test.ts` 中的 Private Room 请求; 2. `src/data/services/api/__tests__/multi_character_api.test.ts` 中的 Private Zoom 请求;
3. `src/stores/private-room/__tests__` 3. `src/stores/private-zoom/__tests__`
4. `src/app/private-room/__tests__` 与组件测试; 4. `src/app/private-zoom/__tests__` 与组件测试;
5. Elio、Maya、Nayeli 列表互不串联; 5. Elio、Maya、Nayeli 列表互不串联;
6. 登录身份变化会刷新当前角色列表; 6. 登录身份变化会刷新当前角色列表;
7. 成功、余额不足、价格变化、重复解锁、退款失败和 not found 分支; 7. 成功、余额不足、价格变化、重复解锁、退款失败和 not found 分支;
+3 -3
View File
@@ -19,7 +19,7 @@ https://<APP_HOST>/external-entry?<参数>
| 参数 | 可选值或格式 | 用途 | | 参数 | 可选值或格式 | 用途 |
| --- | --- | --- | | --- | --- | --- |
| `target` | `chat``tip``private-room` | 指定进入的页面;不传或值无效时进入聊天页。 | | `target` | `chat``tip``private-zoom` | 指定进入的页面;不传或值无效时进入聊天页。 |
| `character` | `elio``maya``nayeli` | 指定角色;不传或值无效时使用 Elio。 | | `character` | `elio``maya``nayeli` | 指定角色;不传或值无效时使用 Elio。 |
| `psid` | string | 传入 Facebook Page-scoped User ID。 | | `psid` | string | 传入 Facebook Page-scoped User ID。 |
| `mode` | `promotion` | 开启聊天促销模式。 | | `mode` | `promotion` | 开启聊天促销模式。 |
@@ -78,13 +78,13 @@ https://<APP_HOST>/external-entry?target=tip
私密空间: 私密空间:
```text ```text
https://<APP_HOST>/external-entry?target=private-room https://<APP_HOST>/external-entry?target=private-zoom
``` ```
进入 Nayeli 私密空间: 进入 Nayeli 私密空间:
```text ```text
https://<APP_HOST>/external-entry?target=private-room&character=nayeli https://<APP_HOST>/external-entry?target=private-zoom&character=nayeli
``` ```
`psid` 可以与任意 `target` 或聊天促销参数组合使用。参数值需要进行 URL 编码,不要在入口中传递登录 Token、Page Access Token 或 App Secret。 `psid` 可以与任意 `target` 或聊天促销参数组合使用。参数值需要进行 URL 编码,不要在入口中传递登录 Token、Page Access Token 或 App Secret。
+3 -3
View File
@@ -40,8 +40,8 @@
| 角色 | 链接 | | 角色 | 链接 |
| --- | --- | | --- | --- |
| Elio | [打开 Elio 私密空间](http://localhost:3000/external-entry?target=private-room&character=elio) | | Elio | [打开 Elio 私密空间](http://localhost:3000/external-entry?target=private-zoom&character=elio) |
| Maya | [打开 Maya 私密空间](http://localhost:3000/external-entry?target=private-room&character=maya) | | Maya | [打开 Maya 私密空间](http://localhost:3000/external-entry?target=private-zoom&character=maya) |
| Nayeli | [打开 Nayeli 私密空间](http://localhost:3000/external-entry?target=private-room&character=nayeli) | | Nayeli | [打开 Nayeli 私密空间](http://localhost:3000/external-entry?target=private-zoom&character=nayeli) |
如需为其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020`。对于不带查询参数的默认入口,请改为追加 `?psid=27511427698460020` 如需为其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020`。对于不带查询参数的默认入口,请改为追加 `?psid=27511427698460020`
+6 -6
View File
@@ -18,9 +18,9 @@
| 咖啡打赏 | [打开咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip) | | 咖啡打赏 | [打开咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip) |
| Maya 咖啡打赏 | [打开 Maya 咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip&character=maya) | | Maya 咖啡打赏 | [打开 Maya 咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip&character=maya) |
| Nayeli 咖啡打赏 | [打开 Nayeli 咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip&character=nayeli) | | Nayeli 咖啡打赏 | [打开 Nayeli 咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip&character=nayeli) |
| 私密空间 | [打开私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-room) | | 私密空间 | [打开私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zoom) |
| Maya 私密空间 | [打开 Maya 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-room&character=maya) | | Maya 私密空间 | [打开 Maya 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zoom&character=maya) |
| Nayeli 私密空间 | [打开 Nayeli 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-room&character=nayeli) | | Nayeli 私密空间 | [打开 Nayeli 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zoom&character=nayeli) |
## 正式环境 ## 正式环境
@@ -36,8 +36,8 @@
| 咖啡打赏 | [打开咖啡打赏](https://cozsweet.com/external-entry?target=tip) | | 咖啡打赏 | [打开咖啡打赏](https://cozsweet.com/external-entry?target=tip) |
| Maya 咖啡打赏 | [打开 Maya 咖啡打赏](https://cozsweet.com/external-entry?target=tip&character=maya) | | Maya 咖啡打赏 | [打开 Maya 咖啡打赏](https://cozsweet.com/external-entry?target=tip&character=maya) |
| Nayeli 咖啡打赏 | [打开 Nayeli 咖啡打赏](https://cozsweet.com/external-entry?target=tip&character=nayeli) | | Nayeli 咖啡打赏 | [打开 Nayeli 咖啡打赏](https://cozsweet.com/external-entry?target=tip&character=nayeli) |
| 私密空间 | [打开私密空间](https://cozsweet.com/external-entry?target=private-room) | | 私密空间 | [打开私密空间](https://cozsweet.com/external-entry?target=private-zoom) |
| Maya 私密空间 | [打开 Maya 私密空间](https://cozsweet.com/external-entry?target=private-room&character=maya) | | Maya 私密空间 | [打开 Maya 私密空间](https://cozsweet.com/external-entry?target=private-zoom&character=maya) |
| Nayeli 私密空间 | [打开 Nayeli 私密空间](https://cozsweet.com/external-entry?target=private-room&character=nayeli) | | Nayeli 私密空间 | [打开 Nayeli 私密空间](https://cozsweet.com/external-entry?target=private-zoom&character=nayeli) |
如需在其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020` 如需在其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020`
@@ -0,0 +1,176 @@
# Private Zoom 全链路改名联调说明
- 日期:2026-07-22
- 目标环境:本地、`pre`、生产
- 当前状态:已实现待联调
## 1. 目标
原功能名称存在拼写错误。本次将前端、unified 后端、Manager、数据库、埋点和文档中的正式命名统一为 `Private Zoom`,并同步切换页面路由、API 路径和公开枚举值。
## 2. 环境地址
| 环境 | 前端 | API Base URL |
| --- | --- | --- |
| `pre` | `https://frontend-test.banlv-ai.com` | `https://proapi.banlv-ai.com` |
| 生产 | `https://cozsweet.com` | `https://api.banlv-ai.com` |
## 3. 前端影响
前端已完成以下修改:
- 页面路由统一为 `/private-zoom``/characters/{characterSlug}/private-zoom`
- 外部入口参数统一为 `target=private-zoom`
- 支付回跳参数统一为 `returnTo=private-zoom`
- 类型、Repository、API client、XState actor、Provider 和资源目录统一使用 `privateZoom``PrivateZoom``private-zoom``private_zoom`
- 埋点键统一为 `navigation.private_zoom``chat.open_private_zoom_from_avatar` 等新名称。
- 角色能力字段统一为 `capabilities.privateZoom`
旧页面和旧查询参数不再作为正式入口保留。发布时必须让前后端属于同一个发布批次。
## 4. API 变更清单
所有接口都使用 `Authorization: Bearer <TOKEN>`,响应继续使用现有统一 envelope。请求与响应中未列出的业务字段保持原类型和含义。
| 方法 | 新路径 | 用途 |
| --- | --- | --- |
| `GET` | `/api/private-zoom/albums` | 查询付费图片包 |
| `POST` | `/api/private-zoom/albums/{albumId}/unlock` | 解锁图片包 |
| `GET` | `/api/private-zoom/moments` | 查询朋友圈式内容 |
| `POST` | `/api/private-zoom/moments/{momentId}/unlock` | 解锁单条内容 |
| `GET` | `/api/private-zoom/config` | 查询当前角色和用户解锁配置 |
| `GET` | `/api/private-zoom/diaries` | 查询关系日记 |
| `POST` | `/api/private-zoom/diaries/{diaryId}/seen` | 标记关系日记已读 |
| `POST` | `/api/private-zoom/diaries/{diaryId}/unlock` | 解锁关系日记 |
### 4.1 图片包列表
```http
GET /api/private-zoom/albums?characterId=elio&limit=20
Authorization: Bearer <TOKEN>
```
| 字段 | 位置 | 类型 | 必填 | 可为 `null` | 说明 |
| --- | --- | --- | --- | --- | --- |
| `characterId` | query | string | 是 | 否 | 角色 ID |
| `limit` | query | integer | 否 | 否 | `1-50`,默认 `20` |
| `cursor` | query | string | 否 | 是 | 分页游标 |
调用示例:
```bash
curl 'https://proapi.banlv-ai.com/api/private-zoom/albums?characterId=elio&limit=20' \
-H 'Authorization: Bearer <TOKEN>'
```
### 4.2 解锁图片包
```http
POST /api/private-zoom/albums/{albumId}/unlock
Authorization: Bearer <TOKEN>
Content-Type: application/json
```
| 字段 | 位置 | 类型 | 必填 | 可为 `null` | 说明 |
| --- | --- | --- | --- | --- | --- |
| `albumId` | path | string | 是 | 否 | 图片包 ID |
| `expectedCost` | body | integer | 否 | 是 | 前端确认价格;与后端价格不一致时拒绝解锁 |
```bash
curl -X POST 'https://proapi.banlv-ai.com/api/private-zoom/albums/<ALBUM_ID>/unlock' \
-H 'Authorization: Bearer <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"expectedCost":320}'
```
### 4.3 Moments 内容与解锁
```http
GET /api/private-zoom/moments?characterId=elio&limit=20
POST /api/private-zoom/moments/{momentId}/unlock
```
解锁请求体与图片包一致,`expectedCost` 为可选整数。响应中的正式分类值同步改为:
```json
{
"lockDetail": {
"type": "private_zoom_moment",
"reason": "private_zoom_moment"
}
}
```
## 5. 其他公开值
| 使用位置 | 新值 | 类型 |
| --- | --- | --- |
| `/api/chat/unlock-private``lockType` 别名 | `private_zoom` | string enum |
| 日程导入 `contentType` 别名 | `private_zoom` | string enum,归一化为 `paid_content` |
| 外部入口 `target` | `private-zoom` | string enum |
| 支付回跳 `returnTo` | `private-zoom` | string enum |
| 锁定详情分类 | `private_zoom_moment` | string enum |
## 6. 数据库迁移
发布前执行 unified 仓库中的:
```text
database/private-zoom-migration.sql
```
迁移会在同一事务中完成:
- 将历史解锁表无损重命名;新旧表同时存在时先合并再删除旧表。
- 重命名关联约束、索引、策略和触发器。
- 合并 `users.preferences` 中历史解锁键,防止已解锁内容重新锁定。
-`credit_ledger` 历史分类迁移到 `private_zoom``private_zoom_moment`
- 定向迁移历史埋点键、页面 URL 和系统媒体路径,不改写用户聊天正文。
- 支持重复执行。
## 7. 兼容性与发布顺序
这是破坏性命名修正,不保留旧 API、旧页面路由或旧公开枚举作为正式兼容层。必须按以下顺序发布:
1. 备份数据库并记录当前 unified、前端和 Manager 版本。
2. 执行 `database/private-zoom-migration.sql`
3. 部署 unified `pre`,验证所有 `/api/private-zoom/*` 接口。
4. 部署前端 `pre`,验证页面、外部入口、解锁和支付回跳。
5. Manager 更新后验证积分用途显示为新分类。
6. `pre` 验证通过后,同一提交集晋级生产。
## 8. 错误与界面状态
- `401`:Token 缺失或无效,前端进入现有登录恢复流程。
- `403`:游客访问仅注册用户可用的关系日记操作,展示现有注册引导。
- `404`:角色、图片包、内容或日记不存在,展示现有空状态或失效提示。
- `409``expectedCost` 与后端价格不同,刷新列表后重新确认。
- `402` 或业务余额不足错误:进入现有充值流程,并使用 `returnTo=private-zoom` 返回原角色页面。
- 网络失败:不修改本地解锁状态,保留重试入口。
## 9. 验收用例
1. `/characters/elio/private-zoom`、Maya 和 Nayeli 对应页面均可打开。
2. `GET /api/private-zoom/albums` 返回当前角色内容,角色之间不混用。
3. 已解锁历史记录在迁移后保持解锁状态,不重复扣积分。
4. 新解锁成功后刷新页面仍为已解锁状态。
5. 积分不足进入充值页后,回跳到原角色 `/private-zoom` 页面。
6. `target=private-zoom&character=nayeli` 进入 Nayeli 对应页面。
7. Manager 的积分用途不再出现旧分类。
8. 三个仓库执行旧命名残留扫描,结果为 `0`
## 10. 当前测试证据
- unified`316 passed`
- 前端:TypeScript 类型检查通过;Vitest `639 passed`ESLint 通过;契约测试 `4 passed`;生产构建通过并生成三个角色的 `/private-zoom` 页面。
- Manager`75 passed`
- PostgreSQL 16 临时库:升级、重复升级、回滚和再次升级全部通过;历史解锁、偏好键、积分账本、埋点、媒体路径和数据库对象名均通过断言,临时容器已删除。
## 11. 回滚影响
仅回滚应用镜像而不回滚数据库,会让旧版本无法读取新表名,因此生产回滚必须同时执行 unified 仓库中的 `database/private-zoom-rollback.sql`。回滚前应停止写入,先保存切换后的新增解锁记录,再执行逆向迁移并恢复旧应用版本。不得只恢复前端或只恢复 unified。
## 12. 待确认事项
- `pre` 浏览器真实联调和生产发布尚未执行。
- 生产镜像 ID 将在发布前固化到发布记录。
@@ -42,7 +42,7 @@ test("guest user avatar returns to Profile after sign-in", async ({
}); });
for (const character of characters) { for (const character of characters) {
test(`${character.displayName} avatar opens the matching Private Room`, async ({ test(`${character.displayName} avatar opens the matching Private Zoom`, async ({
page, page,
}) => { }) => {
await enterCharacterChat(page, character.slug); await enterCharacterChat(page, character.slug);
@@ -50,13 +50,13 @@ for (const character of characters) {
await page await page
.getByRole("button", { .getByRole("button", {
name: `Open ${character.displayName}'s private room`, name: `Open ${character.displayName}'s private zoom`,
}) })
.last() .last()
.click(); .click();
await expect(page).toHaveURL( await expect(page).toHaveURL(
new RegExp(`/characters/${character.slug}/private-room(?:\\?.*)?$`), new RegExp(`/characters/${character.slug}/private-zoom(?:\\?.*)?$`),
); );
}); });
} }

Before

Width:  |  Height:  |  Size: 814 KiB

After

Width:  |  Height:  |  Size: 814 KiB

Before

Width:  |  Height:  |  Size: 652 KiB

After

Width:  |  Height:  |  Size: 652 KiB

Before

Width:  |  Height:  |  Size: 907 KiB

After

Width:  |  Height:  |  Size: 907 KiB

@@ -13,13 +13,13 @@ describe("OpenAPI contract comparison", () => {
chatHistory: { method: "get", path: "/api/chat/history" }, chatHistory: { method: "get", path: "/api/chat/history" },
unlockAlbum: { unlockAlbum: {
method: "post", method: "post",
path: "/api/private-room/albums/{albumId}/unlock", path: "/api/private-zoom/albums/{albumId}/unlock",
}, },
}, },
{ {
paths: { paths: {
"/api/chat/history": { get: {} }, "/api/chat/history": { get: {} },
"/api/private-room/albums/{album_id}/unlock/": { post: {} }, "/api/private-zoom/albums/{album_id}/unlock/": { post: {} },
}, },
}, },
); );
@@ -85,8 +85,8 @@ describe("shared Tailwind components", () => {
<CharacterAvatar <CharacterAvatar
src="/images/avatar/elio.png" src="/images/avatar/elio.png"
alt="Elio Silvestri" alt="Elio Silvestri"
actionLabel="Open Elio's private room" actionLabel="Open Elio's private zoom"
analyticsKey="chat.open_private_room_from_avatar" analyticsKey="chat.open_private_zoom_from_avatar"
onClick={() => undefined} onClick={() => undefined}
/>, />,
); );
@@ -100,10 +100,10 @@ describe("shared Tailwind components", () => {
expect(characterHtml).toContain('<button type="button"'); expect(characterHtml).toContain('<button type="button"');
expect(characterHtml).toContain( expect(characterHtml).toContain(
'aria-label="Open Elio&#x27;s private room"', 'aria-label="Open Elio&#x27;s private zoom"',
); );
expect(characterHtml).toContain( expect(characterHtml).toContain(
'data-analytics-key="chat.open_private_room_from_avatar"', 'data-analytics-key="chat.open_private_zoom_from_avatar"',
); );
expect(userHtml).toContain('<button type="button"'); expect(userHtml).toContain('<button type="button"');
expect(userHtml).toContain('aria-label="Open profile"'); expect(userHtml).toContain('aria-label="Open profile"');
@@ -79,18 +79,18 @@ describe("core Tailwind components", () => {
<AppBottomNav <AppBottomNav
activeItem="chat" activeItem="chat"
variant="dark" variant="dark"
privateRoomLabel="Maya Private room" privateZoomLabel="Maya Private Zoom"
onChatClick={() => undefined} onChatClick={() => undefined}
onPrivateRoomClick={() => undefined} onPrivateZoomClick={() => undefined}
/>, />,
); );
const privateRoomHtml = renderToStaticMarkup( const privateZoomHtml = renderToStaticMarkup(
<AppBottomNav <AppBottomNav
activeItem="privateRoom" activeItem="privateZoom"
variant="warm" variant="warm"
privateRoomLabel="Maya Private room" privateZoomLabel="Maya Private Zoom"
onChatClick={() => undefined} onChatClick={() => undefined}
onPrivateRoomClick={() => undefined} onPrivateZoomClick={() => undefined}
/>, />,
); );
@@ -99,13 +99,13 @@ describe("core Tailwind components", () => {
expect(chatHtml).toMatch( expect(chatHtml).toMatch(
/<button[^>]*aria-current="page"[^>]*>.*?<span>Chat<\/span>/, /<button[^>]*aria-current="page"[^>]*>.*?<span>Chat<\/span>/,
); );
expect(privateRoomHtml).toMatch(/class="[^"]*warm[^"]*"/); expect(privateZoomHtml).toMatch(/class="[^"]*warm[^"]*"/);
expect(privateRoomHtml).toMatch( expect(privateZoomHtml).toMatch(
/<button[^>]*aria-current="page"[^>]*>.*?<span>Maya Private room<\/span>/, /<button[^>]*aria-current="page"[^>]*>.*?<span>Maya Private Zoom<\/span>/,
); );
expect(chatHtml).toContain('data-analytics-key="navigation.chat"'); expect(chatHtml).toContain('data-analytics-key="navigation.chat"');
expect(privateRoomHtml).toContain( expect(privateZoomHtml).toContain(
'data-analytics-key="navigation.private_room"', 'data-analytics-key="navigation.private_zoom"',
); );
}); });
}); });
+11 -11
View File
@@ -4,23 +4,23 @@ import { Camera, MessageCircle } from "lucide-react";
import styles from "./app-bottom-nav.module.css"; import styles from "./app-bottom-nav.module.css";
export type AppBottomNavItem = "chat" | "privateRoom"; export type AppBottomNavItem = "chat" | "privateZoom";
export type AppBottomNavVariant = "warm" | "dark"; export type AppBottomNavVariant = "warm" | "dark";
export interface AppBottomNavProps { export interface AppBottomNavProps {
activeItem?: AppBottomNavItem | null; activeItem?: AppBottomNavItem | null;
variant?: AppBottomNavVariant; variant?: AppBottomNavVariant;
privateRoomLabel: string; privateZoomLabel: string;
onChatClick: () => void; onChatClick: () => void;
onPrivateRoomClick: () => void; onPrivateZoomClick: () => void;
} }
export function AppBottomNav({ export function AppBottomNav({
activeItem = null, activeItem = null,
variant = "warm", variant = "warm",
privateRoomLabel, privateZoomLabel,
onChatClick, onChatClick,
onPrivateRoomClick, onPrivateZoomClick,
}: AppBottomNavProps) { }: AppBottomNavProps) {
return ( return (
<nav className={getRootClass(variant)} aria-label="Primary navigation"> <nav className={getRootClass(variant)} aria-label="Primary navigation">
@@ -37,14 +37,14 @@ export function AppBottomNav({
</button> </button>
<button <button
type="button" type="button"
data-analytics-key="navigation.private_room" data-analytics-key="navigation.private_zoom"
data-analytics-label="Private room navigation" data-analytics-label="Private Zoom navigation"
className={getButtonClass(activeItem === "privateRoom")} className={getButtonClass(activeItem === "privateZoom")}
aria-current={activeItem === "privateRoom" ? "page" : undefined} aria-current={activeItem === "privateZoom" ? "page" : undefined}
onClick={onPrivateRoomClick} onClick={onPrivateZoomClick}
> >
<Camera size={20} aria-hidden="true" /> <Camera size={20} aria-hidden="true" />
<span>{privateRoomLabel}</span> <span>{privateZoomLabel}</span>
</button> </button>
</nav> </nav>
); );
@@ -1,5 +0,0 @@
import { PrivateRoomScreen } from "@/app/private-room/private-room-screen";
export default function CharacterPrivateRoomPage() {
return <PrivateRoomScreen />;
}
@@ -2,9 +2,9 @@ import type { ReactNode } from "react";
import { notFound } from "next/navigation"; import { notFound } from "next/navigation";
import { getCharacterBySlug } from "@/data/constants/character"; import { getCharacterBySlug } from "@/data/constants/character";
import { PrivateRoomRouteProvider } from "@/providers/private-room-route-provider"; import { PrivateZoomRouteProvider } from "@/providers/private-zoom-route-provider";
export default async function CharacterPrivateRoomLayout({ export default async function CharacterPrivateZoomLayout({
children, children,
params, params,
}: { }: {
@@ -13,11 +13,11 @@ export default async function CharacterPrivateRoomLayout({
}) { }) {
const { characterSlug } = await params; const { characterSlug } = await params;
const character = getCharacterBySlug(characterSlug); const character = getCharacterBySlug(characterSlug);
if (!character?.capabilities.privateRoom) notFound(); if (!character?.capabilities.privateZoom) notFound();
return ( return (
<PrivateRoomRouteProvider characterId={character.id}> <PrivateZoomRouteProvider characterId={character.id}>
{children} {children}
</PrivateRoomRouteProvider> </PrivateZoomRouteProvider>
); );
} }
@@ -0,0 +1,5 @@
import { PrivateZoomScreen } from "@/app/private-zoom/private-zoom-screen";
export default function CharacterPrivateZoomPage() {
return <PrivateZoomScreen />;
}
+3 -3
View File
@@ -253,8 +253,8 @@ export function ChatScreen() {
); );
} }
function handleOpenCharacterPrivateRoom(): void { function handleOpenCharacterPrivateZoom(): void {
router.push(characterRoutes.privateRoom); router.push(characterRoutes.privateZoom);
} }
return ( return (
@@ -304,7 +304,7 @@ export function ChatScreen() {
onUnlockImageMessage={handleUnlockImageMessage} onUnlockImageMessage={handleUnlockImageMessage}
onOpenImage={handleOpenImage} onOpenImage={handleOpenImage}
onUserAvatarClick={handleOpenUserProfile} onUserAvatarClick={handleOpenUserProfile}
onCharacterAvatarClick={handleOpenCharacterPrivateRoom} onCharacterAvatarClick={handleOpenCharacterPrivateZoom}
onLoadMoreHistory={() => { onLoadMoreHistory={() => {
chatDispatch({ type: "ChatLoadMoreHistoryRequested" }); chatDispatch({ type: "ChatLoadMoreHistoryRequested" });
}} }}
@@ -62,10 +62,10 @@ describe("chat Tailwind components", () => {
expect(aiHtml).toContain('<button type="button"'); expect(aiHtml).toContain('<button type="button"');
expect(aiHtml).toContain( expect(aiHtml).toContain(
'data-analytics-key="chat.open_private_room_from_avatar"', 'data-analytics-key="chat.open_private_zoom_from_avatar"',
); );
expect(aiHtml).toContain( expect(aiHtml).toContain(
'aria-label="Open Elio Silvestri&#x27;s private room"', 'aria-label="Open Elio Silvestri&#x27;s private zoom"',
); );
expect(userHtml).toContain('<button type="button"'); expect(userHtml).toContain('<button type="button"');
expect(userHtml).toContain( expect(userHtml).toContain(
+2 -2
View File
@@ -29,8 +29,8 @@ export function MessageAvatar({
imageSize={43} imageSize={43}
priority priority
className={AVATAR_CLASS_NAME} className={AVATAR_CLASS_NAME}
actionLabel={`Open ${character.displayName}'s private room`} actionLabel={`Open ${character.displayName}'s private zoom`}
analyticsKey="chat.open_private_room_from_avatar" analyticsKey="chat.open_private_zoom_from_avatar"
onClick={onClick} onClick={onClick}
/> />
); );
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import { import {
buildPrivateAlbumGalleryUrl, buildPrivateAlbumGalleryUrl,
buildPrivateRoomWithoutGalleryUrl, buildPrivateZoomWithoutGalleryUrl,
getPrivateAlbumGalleryState, getPrivateAlbumGalleryState,
} from "../private-album-gallery-url"; } from "../private-album-gallery-url";
@@ -11,7 +11,7 @@ describe("private album gallery URL", () => {
const url = buildPrivateAlbumGalleryUrl("album:91", 3); const url = buildPrivateAlbumGalleryUrl("album:91", 3);
const params = new URL(url, "https://cozsweet.test").searchParams; const params = new URL(url, "https://cozsweet.test").searchParams;
expect(url).toBe("/private-room?album=album%3A91&image=3"); expect(url).toBe("/private-zoom?album=album%3A91&image=3");
expect(getPrivateAlbumGalleryState(params)).toEqual({ expect(getPrivateAlbumGalleryState(params)).toEqual({
albumId: "album:91", albumId: "album:91",
imageIndex: 3, imageIndex: 3,
@@ -29,9 +29,9 @@ describe("private album gallery URL", () => {
it("removes gallery params without dropping other query values", () => { it("removes gallery params without dropping other query values", () => {
expect( expect(
buildPrivateRoomWithoutGalleryUrl( buildPrivateZoomWithoutGalleryUrl(
new URLSearchParams("album=album-1&image=2&source=external"), new URLSearchParams("album=album-1&image=2&source=external"),
), ),
).toBe("/private-room?source=external"); ).toBe("/private-zoom?source=external");
}); });
}); });
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { PrivateAlbumSchema } from "@/data/schemas/private-room"; import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
import { import {
findPrivateAlbumDisplayImage, findPrivateAlbumDisplayImage,
@@ -6,10 +6,10 @@ import { getCharacterBySlug } from "@/data/constants/character";
import type { LoginStatus } from "@/data/schemas/auth"; import type { LoginStatus } from "@/data/schemas/auth";
import { CharacterProvider } from "@/providers/character-provider"; import { CharacterProvider } from "@/providers/character-provider";
import { getCharacterRoutes } from "@/router/routes"; import { getCharacterRoutes } from "@/router/routes";
import type { PrivateRoomEvent } from "@/stores/private-room"; import type { PrivateZoomEvent } from "@/stores/private-zoom";
import type { PrivateRoomUnlockPaywallRequest } from "@/stores/private-room/private-room-state"; import type { PrivateZoomUnlockPaywallRequest } from "@/stores/private-zoom/private-zoom-state";
import { usePrivateRoomUnlockPaywallNavigation } from "../use-private-room-flow"; import { usePrivateZoomUnlockPaywallNavigation } from "../use-private-zoom-flow";
const mocks = vi.hoisted(() => ({ const mocks = vi.hoisted(() => ({
openAuth: vi.fn(), openAuth: vi.fn(),
@@ -30,7 +30,7 @@ vi.mock("@/lib/analytics", () => ({
}, },
})); }));
const unlockPaywallRequest: PrivateRoomUnlockPaywallRequest = { const unlockPaywallRequest: PrivateZoomUnlockPaywallRequest = {
albumId: "album-1", albumId: "album-1",
reason: "insufficient_credits", reason: "insufficient_credits",
requiredCredits: 10, requiredCredits: 10,
@@ -38,7 +38,7 @@ const unlockPaywallRequest: PrivateRoomUnlockPaywallRequest = {
shortfallCredits: 7, shortfallCredits: 7,
}; };
describe("Private Room paywall navigation", () => { describe("Private Zoom paywall navigation", () => {
let container: HTMLDivElement; let container: HTMLDivElement;
let root: Root; let root: Root;
@@ -58,31 +58,31 @@ describe("Private Room paywall navigation", () => {
container.remove(); container.remove();
}); });
it("opens top up with a private room return target", () => { it("opens top up with a private zoom return target", () => {
const roomDispatch = vi.fn<Dispatch<PrivateRoomEvent>>(); const roomDispatch = vi.fn<Dispatch<PrivateZoomEvent>>();
renderHarness(root, "email", roomDispatch); renderHarness(root, "email", roomDispatch);
expect(mocks.openSubscription).toHaveBeenCalledWith({ expect(mocks.openSubscription).toHaveBeenCalledWith({
type: "topup", type: "topup",
returnTo: "private-room", returnTo: "private-zoom",
analytics: { analytics: {
entryPoint: "private_album_unlock", entryPoint: "private_album_unlock",
triggerReason: "insufficient_credits", triggerReason: "insufficient_credits",
}, },
}); });
expect(roomDispatch).toHaveBeenCalledWith({ expect(roomDispatch).toHaveBeenCalledWith({
type: "PrivateRoomUnlockPaywallConsumed", type: "PrivateZoomUnlockPaywallConsumed",
}); });
}); });
it("keeps guest users on the private room auth return path", () => { it("keeps guest users on the private zoom auth return path", () => {
const roomDispatch = vi.fn<Dispatch<PrivateRoomEvent>>(); const roomDispatch = vi.fn<Dispatch<PrivateZoomEvent>>();
renderHarness(root, "guest", roomDispatch); renderHarness(root, "guest", roomDispatch);
expect(mocks.openAuth).toHaveBeenCalledWith( expect(mocks.openAuth).toHaveBeenCalledWith(
getCharacterRoutes("maya").privateRoom, getCharacterRoutes("maya").privateZoom,
); );
expect(mocks.openSubscription).not.toHaveBeenCalled(); expect(mocks.openSubscription).not.toHaveBeenCalled();
}); });
@@ -91,7 +91,7 @@ describe("Private Room paywall navigation", () => {
function renderHarness( function renderHarness(
root: Root, root: Root,
loginStatus: LoginStatus, loginStatus: LoginStatus,
roomDispatch: Dispatch<PrivateRoomEvent>, roomDispatch: Dispatch<PrivateZoomEvent>,
): void { ): void {
const character = getCharacterBySlug("maya"); const character = getCharacterBySlug("maya");
if (!character) throw new Error("Missing Maya character fixture"); if (!character) throw new Error("Missing Maya character fixture");
@@ -109,9 +109,9 @@ function Harness({
roomDispatch, roomDispatch,
}: { }: {
loginStatus: LoginStatus; loginStatus: LoginStatus;
roomDispatch: Dispatch<PrivateRoomEvent>; roomDispatch: Dispatch<PrivateZoomEvent>;
}) { }) {
usePrivateRoomUnlockPaywallNavigation({ usePrivateZoomUnlockPaywallNavigation({
loginStatus, loginStatus,
roomDispatch, roomDispatch,
unlockPaywallRequest, unlockPaywallRequest,
@@ -1,19 +1,19 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { isPrivateRoomAuthRequired } from "../use-private-room-flow"; import { isPrivateZoomAuthRequired } from "../use-private-zoom-flow";
describe("isPrivateRoomAuthRequired", () => { describe("isPrivateZoomAuthRequired", () => {
it.each(["guest", "notLoggedIn"] as const)( it.each(["guest", "notLoggedIn"] as const)(
"requires auth for %s users", "requires auth for %s users",
(loginStatus) => { (loginStatus) => {
expect(isPrivateRoomAuthRequired(loginStatus)).toBe(true); expect(isPrivateZoomAuthRequired(loginStatus)).toBe(true);
}, },
); );
it.each(["email", "facebook", "google"] as const)( it.each(["email", "facebook", "google"] as const)(
"allows %s users to top up directly", "allows %s users to top up directly",
(loginStatus) => { (loginStatus) => {
expect(isPrivateRoomAuthRequired(loginStatus)).toBe(false); expect(isPrivateZoomAuthRequired(loginStatus)).toBe(false);
}, },
); );
}); });
@@ -4,7 +4,7 @@ import { act } from "react";
import { createRoot, type Root } from "react-dom/client"; import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { PrivateAlbumSchema } from "@/data/schemas/private-room"; import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
import { PrivateAlbumCard } from "../private-album-card"; import { PrivateAlbumCard } from "../private-album-card";
@@ -33,9 +33,9 @@ describe("PrivateAlbumCard interactions", () => {
imageCount: 4, imageCount: 4,
images: [ images: [
{ url: "", locked: false, index: 0 }, { url: "", locked: false, index: 0 },
{ url: "/images/private-room/locked.png", locked: true, index: 1 }, { url: "/images/private-zoom/locked.png", locked: true, index: 1 },
{ url: "/images/private-room/photo-2.png", locked: false, index: 2 }, { url: "/images/private-zoom/photo-2.png", locked: false, index: 2 },
{ url: "/images/private-room/photo-3.png", locked: false, index: 3 }, { url: "/images/private-zoom/photo-3.png", locked: false, index: 3 },
], ],
locked: false, locked: false,
unlocked: true, unlocked: true,
@@ -72,7 +72,7 @@ describe("PrivateAlbumCard interactions", () => {
title: "Locked afternoon", title: "Locked afternoon",
imageCount: 3, imageCount: 3,
images: [ images: [
{ url: "/images/private-room/locked.png", locked: true, index: 0 }, { url: "/images/private-zoom/locked.png", locked: true, index: 0 },
], ],
locked: true, locked: true,
unlocked: false, unlocked: false,
@@ -5,11 +5,11 @@ import {
PrivateAlbumSchema, PrivateAlbumSchema,
type PrivateAlbum, type PrivateAlbum,
type PrivateAlbumInput, type PrivateAlbumInput,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import { PrivateAlbumCard } from "../private-album-card"; import { PrivateAlbumCard } from "../private-album-card";
const COVER_URL = "/images/private-room/banner/elio.png"; const COVER_URL = "/images/private-zoom/banner/elio.png";
function makeAlbum(overrides: Partial<PrivateAlbumInput> = {}): PrivateAlbum { function makeAlbum(overrides: Partial<PrivateAlbumInput> = {}): PrivateAlbum {
return PrivateAlbumSchema.parse({ return PrivateAlbumSchema.parse({
@@ -157,7 +157,7 @@ describe("PrivateAlbumCard", () => {
function makeImages(count: number) { function makeImages(count: number) {
return Array.from({ length: count }, (_, index) => ({ return Array.from({ length: count }, (_, index) => ({
url: `/images/private-room/photo-${index}.png`, url: `/images/private-zoom/photo-${index}.png`,
locked: false, locked: false,
index, index,
})); }));
@@ -4,7 +4,7 @@ import { act } from "react";
import { createRoot, type Root } from "react-dom/client"; import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { PrivateAlbumSchema } from "@/data/schemas/private-room"; import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
import { PrivateAlbumGallery } from "../private-album-gallery"; import { PrivateAlbumGallery } from "../private-album-gallery";
@@ -13,11 +13,11 @@ const album = PrivateAlbumSchema.parse({
title: "Private afternoon", title: "Private afternoon",
imageCount: 5, imageCount: 5,
images: [ images: [
{ url: "/images/private-room/photo-0.png", locked: false, index: 0 }, { url: "/images/private-zoom/photo-0.png", locked: false, index: 0 },
{ url: "", locked: false, index: 1 }, { url: "", locked: false, index: 1 },
{ url: "/images/private-room/locked.png", locked: true, index: 2 }, { url: "/images/private-zoom/locked.png", locked: true, index: 2 },
{ url: "/images/private-room/photo-3.png", locked: false, index: 3 }, { url: "/images/private-zoom/photo-3.png", locked: false, index: 3 },
{ url: "/images/private-room/photo-4.png", locked: false, index: 4 }, { url: "/images/private-zoom/photo-4.png", locked: false, index: 4 },
], ],
locked: false, locked: false,
unlocked: true, unlocked: true,
@@ -3,8 +3,8 @@ import Image from "next/image";
import { Copy, ImageIcon, LockKeyhole } from "lucide-react"; import { Copy, ImageIcon, LockKeyhole } from "lucide-react";
import { CharacterAvatar } from "@/app/_components"; import { CharacterAvatar } from "@/app/_components";
import type { PrivateAlbum } from "@/data/schemas/private-room"; import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import { isPrivateAlbumLocked } from "@/lib/private-room/private_album"; import { isPrivateAlbumLocked } from "@/lib/private-zoom/private_album";
import { import {
getPrivateAlbumDisplayImages, getPrivateAlbumDisplayImages,
@@ -12,7 +12,7 @@ import {
PRIVATE_ALBUM_GRID_LIMIT, PRIVATE_ALBUM_GRID_LIMIT,
} from "../private-album-images"; } from "../private-album-images";
import styles from "../private-room-screen.module.css"; import styles from "../private-zoom-screen.module.css";
export interface PrivateAlbumCardProps { export interface PrivateAlbumCardProps {
album: PrivateAlbum; album: PrivateAlbum;
@@ -11,14 +11,14 @@ import {
import Image from "next/image"; import Image from "next/image";
import { ChevronLeft, ChevronRight, X } from "lucide-react"; import { ChevronLeft, ChevronRight, X } from "lucide-react";
import type { PrivateAlbum } from "@/data/schemas/private-room"; import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import { import {
getResistedGalleryDragDistance, getResistedGalleryDragDistance,
resolveGallerySwipeDirection, resolveGallerySwipeDirection,
} from "../private-album-gallery-motion"; } from "../private-album-gallery-motion";
import { getPrivateAlbumDisplayImages } from "../private-album-images"; import { getPrivateAlbumDisplayImages } from "../private-album-images";
import styles from "../private-room-screen.module.css"; import styles from "../private-zoom-screen.module.css";
export interface PrivateAlbumGalleryProps { export interface PrivateAlbumGalleryProps {
album: PrivateAlbum; album: PrivateAlbum;
@@ -1,4 +1,4 @@
import styles from "../private-room-screen.module.css"; import styles from "../private-zoom-screen.module.css";
export interface StatusCardProps { export interface StatusCardProps {
message: string; message: string;
@@ -1,6 +1,6 @@
import type { PrivateAlbum } from "@/data/schemas/private-room"; import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import styles from "../private-room-screen.module.css"; import styles from "../private-zoom-screen.module.css";
export interface UnlockConfirmDialogProps { export interface UnlockConfirmDialogProps {
album: PrivateAlbum; album: PrivateAlbum;
@@ -7,14 +7,14 @@ import {
type RouteSearchParams, type RouteSearchParams,
} from "@/router/routes"; } from "@/router/routes";
export default async function PrivateRoomPage({ export default async function PrivateZoomPage({
searchParams, searchParams,
}: { }: {
searchParams: Promise<RouteSearchParams>; searchParams: Promise<RouteSearchParams>;
}) { }) {
redirect( redirect(
appendRouteSearchParams( appendRouteSearchParams(
getCharacterRoutes(DEFAULT_CHARACTER_SLUG).privateRoom, getCharacterRoutes(DEFAULT_CHARACTER_SLUG).privateZoom,
await searchParams, await searchParams,
), ),
); );
@@ -15,7 +15,7 @@ export function getPrivateAlbumGalleryState(input: {
export function buildPrivateAlbumGalleryUrl( export function buildPrivateAlbumGalleryUrl(
albumId: string, albumId: string,
imageIndex: number, imageIndex: number,
basePath: string = ROUTES.privateRoom, basePath: string = ROUTES.privateZoom,
): string { ): string {
const params = new URLSearchParams({ const params = new URLSearchParams({
[PRIVATE_ALBUM_QUERY_PARAM]: albumId, [PRIVATE_ALBUM_QUERY_PARAM]: albumId,
@@ -24,9 +24,9 @@ export function buildPrivateAlbumGalleryUrl(
return `${basePath}?${params.toString()}`; return `${basePath}?${params.toString()}`;
} }
export function buildPrivateRoomWithoutGalleryUrl( export function buildPrivateZoomWithoutGalleryUrl(
input: { toString: () => string }, input: { toString: () => string },
basePath: string = ROUTES.privateRoom, basePath: string = ROUTES.privateZoom,
): string { ): string {
const params = new URLSearchParams(input.toString()); const params = new URLSearchParams(input.toString());
params.delete(PRIVATE_ALBUM_QUERY_PARAM); params.delete(PRIVATE_ALBUM_QUERY_PARAM);
@@ -1,4 +1,4 @@
import type { PrivateAlbum } from "@/data/schemas/private-room"; import type { PrivateAlbum } from "@/data/schemas/private-zoom";
export const PRIVATE_ALBUM_GRID_LIMIT = 9; export const PRIVATE_ALBUM_GRID_LIMIT = 9;
@@ -11,12 +11,12 @@ import {
useActiveCharacter, useActiveCharacter,
useActiveCharacterRoutes, useActiveCharacterRoutes,
} from "@/providers/character-provider"; } from "@/providers/character-provider";
import { isPrivateAlbumLocked } from "@/lib/private-room/private_album"; import { isPrivateAlbumLocked } from "@/lib/private-zoom/private_album";
import { useAuthDispatch, useAuthState } from "@/stores/auth/auth-context"; import { useAuthDispatch, useAuthState } from "@/stores/auth/auth-context";
import { import {
usePrivateRoomDispatch, usePrivateZoomDispatch,
usePrivateRoomState, usePrivateZoomState,
} from "@/stores/private-room"; } from "@/stores/private-zoom";
import { import {
PrivateAlbumCard, PrivateAlbumCard,
@@ -24,21 +24,21 @@ import {
StatusCard, StatusCard,
UnlockConfirmDialog, UnlockConfirmDialog,
} from "./components"; } from "./components";
import styles from "./private-room-screen.module.css"; import styles from "./private-zoom-screen.module.css";
import { import {
isPrivateRoomAuthRequired, isPrivateZoomAuthRequired,
usePrivateRoomBootstrapFlow, usePrivateZoomBootstrapFlow,
usePrivateRoomUnlockPaywallNavigation, usePrivateZoomUnlockPaywallNavigation,
usePrivateRoomUnlockSuccessRefresh, usePrivateZoomUnlockSuccessRefresh,
} from "./use-private-room-flow"; } from "./use-private-zoom-flow";
import { import {
buildPrivateAlbumGalleryUrl, buildPrivateAlbumGalleryUrl,
buildPrivateRoomWithoutGalleryUrl, buildPrivateZoomWithoutGalleryUrl,
getPrivateAlbumGalleryState, getPrivateAlbumGalleryState,
} from "./private-album-gallery-url"; } from "./private-album-gallery-url";
import { findPrivateAlbumDisplayImage } from "./private-album-images"; import { findPrivateAlbumDisplayImage } from "./private-album-images";
export function PrivateRoomScreen() { export function PrivateZoomScreen() {
const router = useRouter(); const router = useRouter();
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const navigator = useAppNavigator(); const navigator = useAppNavigator();
@@ -46,15 +46,15 @@ export function PrivateRoomScreen() {
const characterRoutes = useActiveCharacterRoutes(); const characterRoutes = useActiveCharacterRoutes();
const authState = useAuthState(); const authState = useAuthState();
const authDispatch = useAuthDispatch(); const authDispatch = useAuthDispatch();
const state = usePrivateRoomState(); const state = usePrivateZoomState();
const dispatch = usePrivateRoomDispatch(); const dispatch = usePrivateZoomDispatch();
const openedGalleryInPageRef = useRef(false); const openedGalleryInPageRef = useRef(false);
const galleryState = useMemo( const galleryState = useMemo(
() => getPrivateAlbumGalleryState(searchParams), () => getPrivateAlbumGalleryState(searchParams),
[searchParams], [searchParams],
); );
usePrivateRoomBootstrapFlow({ usePrivateZoomBootstrapFlow({
authDispatch, authDispatch,
hasInitialized: authState.hasInitialized, hasInitialized: authState.hasInitialized,
isAuthLoading: authState.isLoading, isAuthLoading: authState.isLoading,
@@ -62,17 +62,17 @@ export function PrivateRoomScreen() {
roomDispatch: dispatch, roomDispatch: dispatch,
roomStatus: state.status, roomStatus: state.status,
}); });
usePrivateRoomUnlockPaywallNavigation({ usePrivateZoomUnlockPaywallNavigation({
loginStatus: authState.loginStatus, loginStatus: authState.loginStatus,
roomDispatch: dispatch, roomDispatch: dispatch,
unlockPaywallRequest: state.unlockPaywallRequest, unlockPaywallRequest: state.unlockPaywallRequest,
}); });
usePrivateRoomUnlockSuccessRefresh(state.unlockSuccessNonce); usePrivateZoomUnlockSuccessRefresh(state.unlockSuccessNonce);
const displayName = character.displayName; const displayName = character.displayName;
const avatarUrl = character.assets.avatar; const avatarUrl = character.assets.avatar;
const title = character.copy.privateRoomTitle; const title = character.copy.privateZoomTitle;
const subtitle = character.copy.privateRoomSubtitle; const subtitle = character.copy.privateZoomSubtitle;
const pendingAlbum = useMemo( const pendingAlbum = useMemo(
() => () =>
state.items.find( state.items.find(
@@ -107,15 +107,15 @@ export function PrivateRoomScreen() {
!galleryImage !galleryImage
) { ) {
router.replace( router.replace(
buildPrivateRoomWithoutGalleryUrl( buildPrivateZoomWithoutGalleryUrl(
searchParams, searchParams,
characterRoutes.privateRoom, characterRoutes.privateZoom,
), ),
{ scroll: false }, { scroll: false },
); );
} }
}, [ }, [
characterRoutes.privateRoom, characterRoutes.privateZoom,
galleryAlbum, galleryAlbum,
galleryImage, galleryImage,
galleryState, galleryState,
@@ -125,15 +125,15 @@ export function PrivateRoomScreen() {
]); ]);
const handleTopUpClick = () => { const handleTopUpClick = () => {
if (isPrivateRoomAuthRequired(authState.loginStatus)) { if (isPrivateZoomAuthRequired(authState.loginStatus)) {
navigator.openAuth(characterRoutes.privateRoom); navigator.openAuth(characterRoutes.privateZoom);
return; return;
} }
navigator.openSubscription({ navigator.openSubscription({
type: "topup", type: "topup",
returnTo: "private-room", returnTo: "private-zoom",
analytics: { analytics: {
entryPoint: "private_room", entryPoint: "private_zoom",
triggerReason: "vip_cta", triggerReason: "vip_cta",
}, },
}); });
@@ -145,7 +145,7 @@ export function PrivateRoomScreen() {
buildPrivateAlbumGalleryUrl( buildPrivateAlbumGalleryUrl(
albumId, albumId,
imageIndex, imageIndex,
characterRoutes.privateRoom, characterRoutes.privateZoom,
), ),
{ scroll: false }, { scroll: false },
); );
@@ -158,9 +158,9 @@ export function PrivateRoomScreen() {
return; return;
} }
router.replace( router.replace(
buildPrivateRoomWithoutGalleryUrl( buildPrivateZoomWithoutGalleryUrl(
searchParams, searchParams,
characterRoutes.privateRoom, characterRoutes.privateZoom,
), ),
{ scroll: false }, { scroll: false },
); );
@@ -172,7 +172,7 @@ export function PrivateRoomScreen() {
buildPrivateAlbumGalleryUrl( buildPrivateAlbumGalleryUrl(
galleryAlbum.albumId, galleryAlbum.albumId,
imageIndex, imageIndex,
characterRoutes.privateRoom, characterRoutes.privateZoom,
), ),
{ scroll: false }, { scroll: false },
); );
@@ -187,7 +187,7 @@ export function PrivateRoomScreen() {
<section className={styles.hero} aria-label={title}> <section className={styles.hero} aria-label={title}>
<div className={styles.heroCover}> <div className={styles.heroCover}>
<Image <Image
src={character.assets.privateRoomBanner} src={character.assets.privateZoomBanner}
alt="" alt=""
width={2048} width={2048}
height={1152} height={1152}
@@ -213,8 +213,8 @@ export function PrivateRoomScreen() {
<button <button
type="button" type="button"
data-analytics-key="private_room.primary_cta" data-analytics-key="private_zoom.primary_cta"
data-analytics-label="Open private room top up" data-analytics-label="Open private zoom top up"
className={styles.primaryCta} className={styles.primaryCta}
onClick={handleTopUpClick} onClick={handleTopUpClick}
> >
@@ -237,7 +237,7 @@ export function PrivateRoomScreen() {
<StatusCard <StatusCard
message={state.errorMessage} message={state.errorMessage}
actionLabel="Retry" actionLabel="Retry"
onAction={() => dispatch({ type: "PrivateRoomRefresh" })} onAction={() => dispatch({ type: "PrivateZoomRefresh" })}
/> />
) : null} ) : null}
@@ -249,7 +249,7 @@ export function PrivateRoomScreen() {
<StatusCard <StatusCard
message="No private albums yet." message="No private albums yet."
actionLabel="Refresh" actionLabel="Refresh"
onAction={() => dispatch({ type: "PrivateRoomRefresh" })} onAction={() => dispatch({ type: "PrivateZoomRefresh" })}
/> />
) : null} ) : null}
@@ -267,7 +267,7 @@ export function PrivateRoomScreen() {
} }
onUnlock={() => onUnlock={() =>
dispatch({ dispatch({
type: "PrivateRoomUnlockRequested", type: "PrivateZoomUnlockRequested",
albumId: album.albumId, albumId: album.albumId,
}) })
} }
@@ -277,12 +277,12 @@ export function PrivateRoomScreen() {
</section> </section>
<AppBottomNav <AppBottomNav
activeItem="privateRoom" activeItem="privateZoom"
privateRoomLabel={character.copy.privateRoomTitle} privateZoomLabel={character.copy.privateZoomTitle}
onChatClick={() => onChatClick={() =>
navigator.push(characterRoutes.splash, { scroll: false }) navigator.push(characterRoutes.splash, { scroll: false })
} }
onPrivateRoomClick={() => undefined} onPrivateZoomClick={() => undefined}
/> />
{pendingAlbum ? ( {pendingAlbum ? (
@@ -290,8 +290,8 @@ export function PrivateRoomScreen() {
album={pendingAlbum} album={pendingAlbum}
isUnlocking={state.isUnlocking} isUnlocking={state.isUnlocking}
errorMessage={state.unlockErrorMessage} errorMessage={state.unlockErrorMessage}
onCancel={() => dispatch({ type: "PrivateRoomUnlockCancelled" })} onCancel={() => dispatch({ type: "PrivateZoomUnlockCancelled" })}
onConfirm={() => dispatch({ type: "PrivateRoomUnlockConfirmed" })} onConfirm={() => dispatch({ type: "PrivateZoomUnlockConfirmed" })}
/> />
) : state.unlockErrorMessage ? ( ) : state.unlockErrorMessage ? (
<div className={styles.toast} role="status"> <div className={styles.toast} role="status">
@@ -8,37 +8,37 @@ import { behaviorAnalytics } from "@/lib/analytics";
import { useActiveCharacterRoutes } from "@/providers/character-provider"; import { useActiveCharacterRoutes } from "@/providers/character-provider";
import { useAppNavigator } from "@/router/use-app-navigator"; import { useAppNavigator } from "@/router/use-app-navigator";
import type { AuthEvent } from "@/stores/auth/auth-events"; import type { AuthEvent } from "@/stores/auth/auth-events";
import type { PrivateRoomEvent } from "@/stores/private-room"; import type { PrivateZoomEvent } from "@/stores/private-zoom";
import type { PrivateRoomUnlockPaywallRequest } from "@/stores/private-room/private-room-state"; import type { PrivateZoomUnlockPaywallRequest } from "@/stores/private-zoom/private-zoom-state";
import { useUserDispatch } from "@/stores/user/user-context"; import { useUserDispatch } from "@/stores/user/user-context";
export interface UsePrivateRoomBootstrapFlowInput { export interface UsePrivateZoomBootstrapFlowInput {
authDispatch: Dispatch<AuthEvent>; authDispatch: Dispatch<AuthEvent>;
hasInitialized: boolean; hasInitialized: boolean;
isAuthLoading: boolean; isAuthLoading: boolean;
loginStatus: LoginStatus; loginStatus: LoginStatus;
roomDispatch: Dispatch<PrivateRoomEvent>; roomDispatch: Dispatch<PrivateZoomEvent>;
roomStatus: string; roomStatus: string;
} }
export interface UsePrivateRoomUnlockPaywallNavigationInput { export interface UsePrivateZoomUnlockPaywallNavigationInput {
loginStatus: LoginStatus; loginStatus: LoginStatus;
roomDispatch: Dispatch<PrivateRoomEvent>; roomDispatch: Dispatch<PrivateZoomEvent>;
unlockPaywallRequest: PrivateRoomUnlockPaywallRequest | null; unlockPaywallRequest: PrivateZoomUnlockPaywallRequest | null;
} }
export function isPrivateRoomAuthRequired(loginStatus: LoginStatus): boolean { export function isPrivateZoomAuthRequired(loginStatus: LoginStatus): boolean {
return loginStatus === "guest" || loginStatus === "notLoggedIn"; return loginStatus === "guest" || loginStatus === "notLoggedIn";
} }
export function usePrivateRoomBootstrapFlow({ export function usePrivateZoomBootstrapFlow({
authDispatch, authDispatch,
hasInitialized, hasInitialized,
isAuthLoading, isAuthLoading,
loginStatus, loginStatus,
roomDispatch, roomDispatch,
roomStatus, roomStatus,
}: UsePrivateRoomBootstrapFlowInput): void { }: UsePrivateZoomBootstrapFlowInput): void {
const previousLoginStatusRef = useRef(loginStatus); const previousLoginStatusRef = useRef(loginStatus);
useGuestLoginBootstrap({ useGuestLoginBootstrap({
@@ -56,12 +56,12 @@ export function usePrivateRoomBootstrapFlow({
previousLoginStatusRef.current = loginStatus; previousLoginStatusRef.current = loginStatus;
if (roomStatus === "idle") { if (roomStatus === "idle") {
roomDispatch({ type: "PrivateRoomInit" }); roomDispatch({ type: "PrivateZoomInit" });
return; return;
} }
if (previousLoginStatus !== loginStatus && roomStatus !== "loading") { if (previousLoginStatus !== loginStatus && roomStatus !== "loading") {
roomDispatch({ type: "PrivateRoomRefresh" }); roomDispatch({ type: "PrivateZoomRefresh" });
} }
}, [ }, [
hasInitialized, hasInitialized,
@@ -72,19 +72,19 @@ export function usePrivateRoomBootstrapFlow({
]); ]);
} }
export function usePrivateRoomUnlockPaywallNavigation({ export function usePrivateZoomUnlockPaywallNavigation({
loginStatus, loginStatus,
roomDispatch, roomDispatch,
unlockPaywallRequest, unlockPaywallRequest,
}: UsePrivateRoomUnlockPaywallNavigationInput): void { }: UsePrivateZoomUnlockPaywallNavigationInput): void {
const navigator = useAppNavigator(); const navigator = useAppNavigator();
const characterRoutes = useActiveCharacterRoutes(); const characterRoutes = useActiveCharacterRoutes();
useEffect(() => { useEffect(() => {
if (!unlockPaywallRequest) return; if (!unlockPaywallRequest) return;
if (isPrivateRoomAuthRequired(loginStatus)) { if (isPrivateZoomAuthRequired(loginStatus)) {
navigator.openAuth(characterRoutes.privateRoom); navigator.openAuth(characterRoutes.privateZoom);
} else { } else {
behaviorAnalytics.paywallShown({ behaviorAnalytics.paywallShown({
entryPoint: "private_album_unlock", entryPoint: "private_album_unlock",
@@ -92,16 +92,16 @@ export function usePrivateRoomUnlockPaywallNavigation({
}); });
navigator.openSubscription({ navigator.openSubscription({
type: "topup", type: "topup",
returnTo: "private-room", returnTo: "private-zoom",
analytics: { analytics: {
entryPoint: "private_album_unlock", entryPoint: "private_album_unlock",
triggerReason: "insufficient_credits", triggerReason: "insufficient_credits",
}, },
}); });
} }
roomDispatch({ type: "PrivateRoomUnlockPaywallConsumed" }); roomDispatch({ type: "PrivateZoomUnlockPaywallConsumed" });
}, [ }, [
characterRoutes.privateRoom, characterRoutes.privateZoom,
loginStatus, loginStatus,
navigator, navigator,
roomDispatch, roomDispatch,
@@ -109,7 +109,7 @@ export function usePrivateRoomUnlockPaywallNavigation({
]); ]);
} }
export function usePrivateRoomUnlockSuccessRefresh( export function usePrivateZoomUnlockSuccessRefresh(
unlockSuccessNonce: number, unlockSuccessNonce: number,
): void { ): void {
const userDispatch = useUserDispatch(); const userDispatch = useUserDispatch();
+4 -4
View File
@@ -37,8 +37,8 @@ export function SplashScreen() {
navigator.openChat({ replace: true }); navigator.openChat({ replace: true });
}; };
const handleOpenPrivateRoom = () => { const handleOpenPrivateZoom = () => {
navigator.push(characterRoutes.privateRoom, { scroll: false }); navigator.push(characterRoutes.privateZoom, { scroll: false });
}; };
const handleOpenSplash = () => { const handleOpenSplash = () => {
@@ -77,9 +77,9 @@ export function SplashScreen() {
</div> </div>
<AppBottomNav <AppBottomNav
activeItem="chat" activeItem="chat"
privateRoomLabel={character.copy.privateRoomTitle} privateZoomLabel={character.copy.privateZoomTitle}
onChatClick={handleOpenSplash} onChatClick={handleOpenSplash}
onPrivateRoomClick={handleOpenPrivateRoom} onPrivateZoomClick={handleOpenPrivateZoom}
/> />
</div> </div>
</MobileShell> </MobileShell>
@@ -71,7 +71,7 @@ describe("local character catalog", () => {
expect(snapshot.catalog.getById("maya-tan")).toMatchObject({ expect(snapshot.catalog.getById("maya-tan")).toMatchObject({
displayName: "Maya Backend", displayName: "Maya Backend",
assets: { avatar: "/images/avatar/maya.png" }, assets: { avatar: "/images/avatar/maya.png" },
capabilities: { chat: true, privateRoom: false, tip: true }, capabilities: { chat: true, privateZoom: false, tip: true },
}); });
expect(snapshot.defaultCharacter.id).toBe("elio"); expect(snapshot.defaultCharacter.id).toBe("elio");
}); });
@@ -101,7 +101,7 @@ describe("local character catalog", () => {
for (const character of CHARACTERS) { for (const character of CHARACTERS) {
expect(character.capabilities).toEqual({ expect(character.capabilities).toEqual({
chat: true, chat: true,
privateRoom: true, privateZoom: true,
tip: true, tip: true,
}); });
expect(character.tagline.length).toBeGreaterThan(0); expect(character.tagline.length).toBeGreaterThan(0);
+18 -18
View File
@@ -1,6 +1,6 @@
export interface CharacterCapabilities { export interface CharacterCapabilities {
readonly chat: boolean; readonly chat: boolean;
readonly privateRoom: boolean; readonly privateZoom: boolean;
readonly tip: boolean; readonly tip: boolean;
} }
@@ -17,12 +17,12 @@ export interface CharacterProfile {
readonly avatar: string; readonly avatar: string;
readonly cover: string; readonly cover: string;
readonly chatBackground: string; readonly chatBackground: string;
readonly privateRoomBanner: string; readonly privateZoomBanner: string;
}; };
readonly copy: { readonly copy: {
readonly splashRelationship: string; readonly splashRelationship: string;
readonly privateRoomTitle: string; readonly privateZoomTitle: string;
readonly privateRoomSubtitle: string; readonly privateZoomSubtitle: string;
readonly tipHeader: string; readonly tipHeader: string;
readonly tipTitle: string; readonly tipTitle: string;
}; };
@@ -62,19 +62,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
"Finally I can relax. How was your day out?", "Finally I can relax. How was your day out?",
capabilities: { capabilities: {
chat: true, chat: true,
privateRoom: true, privateZoom: true,
tip: true, tip: true,
}, },
assets: { assets: {
avatar: "/images/avatar/elio.png", avatar: "/images/avatar/elio.png",
cover: "/images/cover/elio.png", cover: "/images/cover/elio.png",
chatBackground: "/images/chat/bg-chatpage.png", chatBackground: "/images/chat/bg-chatpage.png",
privateRoomBanner: "/images/private-room/banner/elio.png", privateZoomBanner: "/images/private-zoom/banner/elio.png",
}, },
copy: { copy: {
splashRelationship: "Your exclusive AI boyfriend", splashRelationship: "Your exclusive AI boyfriend",
privateRoomTitle: "Elio Private room", privateZoomTitle: "Elio Private Zoom",
privateRoomSubtitle: "Join me, unlock my private room", privateZoomSubtitle: "Join me, unlock my private zoom",
tipHeader: "Tip Elio", tipHeader: "Tip Elio",
tipTitle: "Buy Elio a coffee", tipTitle: "Buy Elio a coffee",
}, },
@@ -91,19 +91,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
"How was your day?", "How was your day?",
capabilities: { capabilities: {
chat: true, chat: true,
privateRoom: true, privateZoom: true,
tip: true, tip: true,
}, },
assets: { assets: {
avatar: "/images/avatar/maya.png", avatar: "/images/avatar/maya.png",
cover: "/images/cover/maya.png", cover: "/images/cover/maya.png",
chatBackground: "/images/chat/bg-chatpage.png", chatBackground: "/images/chat/bg-chatpage.png",
privateRoomBanner: "/images/private-room/banner/maya.png", privateZoomBanner: "/images/private-zoom/banner/maya.png",
}, },
copy: { copy: {
splashRelationship: "Your exclusive AI girlfriend", splashRelationship: "Your exclusive AI girlfriend",
privateRoomTitle: "Maya Private room", privateZoomTitle: "Maya Private Zoom",
privateRoomSubtitle: "Join me, unlock my private room", privateZoomSubtitle: "Join me, unlock my private zoom",
tipHeader: "Tip Maya", tipHeader: "Tip Maya",
tipTitle: "Buy Maya a coffee", tipTitle: "Buy Maya a coffee",
}, },
@@ -120,19 +120,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
"Tell me how your day went.", "Tell me how your day went.",
capabilities: { capabilities: {
chat: true, chat: true,
privateRoom: true, privateZoom: true,
tip: true, tip: true,
}, },
assets: { assets: {
avatar: "/images/avatar/nayeli.png", avatar: "/images/avatar/nayeli.png",
cover: "/images/cover/nayeli.png", cover: "/images/cover/nayeli.png",
chatBackground: "/images/chat/bg-chatpage.png", chatBackground: "/images/chat/bg-chatpage.png",
privateRoomBanner: "/images/private-room/banner/nayeli.png", privateZoomBanner: "/images/private-zoom/banner/nayeli.png",
}, },
copy: { copy: {
splashRelationship: "Your exclusive AI girlfriend", splashRelationship: "Your exclusive AI girlfriend",
privateRoomTitle: "Nayeli Private room", privateZoomTitle: "Nayeli Private Zoom",
privateRoomSubtitle: "Join me, unlock my private room", privateZoomSubtitle: "Join me, unlock my private zoom",
tipHeader: "Tip Nayeli", tipHeader: "Tip Nayeli",
tipTitle: "Buy Nayeli a coffee", tipTitle: "Buy Nayeli a coffee",
}, },
@@ -186,8 +186,8 @@ export function mergeRemoteCharacterCatalog(
sortOrder: item.sortOrder, sortOrder: item.sortOrder,
capabilities: { capabilities: {
chat: item.capabilities.chat, chat: item.capabilities.chat,
privateRoom: privateZoom:
local.capabilities.privateRoom && item.capabilities.privateContent, local.capabilities.privateZoom && item.capabilities.privateContent,
tip: local.capabilities.tip, tip: local.capabilities.tip,
}, },
}), }),
+2 -2
View File
@@ -8,7 +8,7 @@ export * from "./character_repository";
export * from "./feedback_repository"; export * from "./feedback_repository";
export * from "./metrics_repository"; export * from "./metrics_repository";
export * from "./payment_repository"; export * from "./payment_repository";
export * from "./private_room_repository"; export * from "./private_zoom_repository";
export * from "./user_repository"; export * from "./user_repository";
export * from "./interfaces/iauth_repository"; export * from "./interfaces/iauth_repository";
export * from "./interfaces/ichat_repository"; export * from "./interfaces/ichat_repository";
@@ -16,5 +16,5 @@ export * from "./interfaces/icharacter_repository";
export * from "./interfaces/ifeedback_repository"; export * from "./interfaces/ifeedback_repository";
export * from "./interfaces/imetrics_repository"; export * from "./interfaces/imetrics_repository";
export * from "./interfaces/ipayment_repository"; export * from "./interfaces/ipayment_repository";
export * from "./interfaces/iprivate_room_repository"; export * from "./interfaces/iprivate_zoom_repository";
export * from "./interfaces/iuser_repository"; export * from "./interfaces/iuser_repository";
+1 -1
View File
@@ -8,5 +8,5 @@ export * from "./icharacter_repository";
export * from "./ifeedback_repository"; export * from "./ifeedback_repository";
export * from "./imetrics_repository"; export * from "./imetrics_repository";
export * from "./ipayment_repository"; export * from "./ipayment_repository";
export * from "./iprivate_room_repository"; export * from "./iprivate_zoom_repository";
export * from "./iuser_repository"; export * from "./iuser_repository";
@@ -1,7 +1,7 @@
import type { import type {
PrivateAlbumsResponse, PrivateAlbumsResponse,
PrivateAlbumUnlockResponse, PrivateAlbumUnlockResponse,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import type { Result } from "@/utils/result"; import type { Result } from "@/utils/result";
export interface GetPrivateAlbumsInput { export interface GetPrivateAlbumsInput {
@@ -9,7 +9,7 @@ export interface GetPrivateAlbumsInput {
limit?: number; limit?: number;
} }
export interface IPrivateRoomRepository { export interface IPrivateZoomRepository {
getAlbums( getAlbums(
input: GetPrivateAlbumsInput, input: GetPrivateAlbumsInput,
): Promise<Result<PrivateAlbumsResponse>>; ): Promise<Result<PrivateAlbumsResponse>>;
@@ -1,22 +1,22 @@
import type { import type {
GetPrivateAlbumsInput, GetPrivateAlbumsInput,
IPrivateRoomRepository, IPrivateZoomRepository,
} from "@/data/repositories/interfaces"; } from "@/data/repositories/interfaces";
import { import {
type PrivateAlbumsResponse, type PrivateAlbumsResponse,
type PrivateAlbumUnlockResponse, type PrivateAlbumUnlockResponse,
UnlockPrivateAlbumRequestSchema, UnlockPrivateAlbumRequestSchema,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import { import {
PrivateRoomApi, PrivateZoomApi,
privateRoomApi, privateZoomApi,
} from "@/data/services/api/private_room_api"; } from "@/data/services/api/private_zoom_api";
import { Result } from "@/utils/result"; import { Result } from "@/utils/result";
import { createLazySingleton } from "./lazy_singleton"; import { createLazySingleton } from "./lazy_singleton";
export class PrivateRoomRepository implements IPrivateRoomRepository { export class PrivateZoomRepository implements IPrivateZoomRepository {
constructor(private readonly api: PrivateRoomApi) {} constructor(private readonly api: PrivateZoomApi) {}
getAlbums( getAlbums(
input: GetPrivateAlbumsInput, input: GetPrivateAlbumsInput,
@@ -37,7 +37,7 @@ export class PrivateRoomRepository implements IPrivateRoomRepository {
} }
} }
export const getPrivateRoomRepository = export const getPrivateZoomRepository =
createLazySingleton<IPrivateRoomRepository>( createLazySingleton<IPrivateZoomRepository>(
() => new PrivateRoomRepository(privateRoomApi), () => new PrivateZoomRepository(privateZoomApi),
); );
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
import { FacebookIdentityResponseSchema } from "@/data/schemas/auth"; import { FacebookIdentityResponseSchema } from "@/data/schemas/auth";
import { ChatHistoryResponseSchema } from "@/data/schemas/chat"; import { ChatHistoryResponseSchema } from "@/data/schemas/chat";
import { PaymentPlansResponseSchema } from "@/data/schemas/payment"; import { PaymentPlansResponseSchema } from "@/data/schemas/payment";
import { PrivateAlbumsResponseSchema } from "@/data/schemas/private-room"; import { PrivateAlbumsResponseSchema } from "@/data/schemas/private-zoom";
import { UserSchema } from "@/data/schemas/user"; import { UserSchema } from "@/data/schemas/user";
describe("immutable schemas", () => { describe("immutable schemas", () => {
@@ -33,7 +33,7 @@ describe("immutable schemas", () => {
expectDeepFrozen(response); expectDeepFrozen(response);
}); });
it("freezes payment and private-room collections", () => { it("freezes payment and private-zoom collections", () => {
const plans = PaymentPlansResponseSchema.parse({ const plans = PaymentPlansResponseSchema.parse({
firstRechargeOffer: { firstRechargeOffer: {
enabled: true, enabled: true,
@@ -4,7 +4,7 @@ import {
PrivateAlbumUnlockResponseSchema, PrivateAlbumUnlockResponseSchema,
PrivateAlbumsResponseSchema, PrivateAlbumsResponseSchema,
UnlockPrivateAlbumRequestSchema, UnlockPrivateAlbumRequestSchema,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import { ApiPath } from "@/data/services/api"; import { ApiPath } from "@/data/services/api";
const ALBUM_ID = "a1b2c3d4-0000-0000-0000-000000000000"; const ALBUM_ID = "a1b2c3d4-0000-0000-0000-000000000000";
@@ -96,8 +96,8 @@ describe("Private Album schema models", () => {
}); });
it("encodes the album id in the unlock path", () => { it("encodes the album id in the unlock path", () => {
expect(ApiPath.privateRoomAlbumUnlock("album:91")).toBe( expect(ApiPath.privateZoomAlbumUnlock("album:91")).toBe(
"/api/private-room/albums/album%3A91/unlock", "/api/private-zoom/albums/album%3A91/unlock",
); );
}); });
}); });
@@ -6,7 +6,7 @@ import { ApiPath } from "../api_path";
describe("ApiPath contract source", () => { describe("ApiPath contract source", () => {
it("uses the shared contract path for every static operation", () => { it("uses the shared contract path for every static operation", () => {
const staticOperations = Object.entries(apiContract).filter( const staticOperations = Object.entries(apiContract).filter(
([operationId]) => operationId !== "privateRoomAlbumUnlock", ([operationId]) => operationId !== "privateZoomAlbumUnlock",
); );
for (const [operationId, operation] of staticOperations) { for (const [operationId, operation] of staticOperations) {
@@ -17,8 +17,8 @@ describe("ApiPath contract source", () => {
}); });
it("fills and encodes the private album path parameter", () => { it("fills and encodes the private album path parameter", () => {
expect(ApiPath.privateRoomAlbumUnlock("album/id 1")).toBe( expect(ApiPath.privateZoomAlbumUnlock("album/id 1")).toBe(
"/api/private-room/albums/album%2Fid%201/unlock", "/api/private-zoom/albums/album%2Fid%201/unlock",
); );
}); });
}); });
@@ -14,7 +14,7 @@ vi.mock("../http_client", () => ({
import { ChatApi } from "../chat_api"; import { ChatApi } from "../chat_api";
import { CharacterApi } from "../character_api"; import { CharacterApi } from "../character_api";
import { PrivateRoomApi } from "../private_room_api"; import { PrivateZoomApi } from "../private_zoom_api";
const CHARACTER_ID = "elio"; const CHARACTER_ID = "elio";
@@ -146,18 +146,18 @@ describe("multi-character API contract", () => {
); );
}); });
it("scopes private-room albums to characterId", async () => { it("scopes private-zoom albums to characterId", async () => {
httpClientMock.mockResolvedValue({ httpClientMock.mockResolvedValue({
success: true, success: true,
data: { items: [], creditBalance: 0 }, data: { items: [], creditBalance: 0 },
}); });
await new PrivateRoomApi().getAlbums({ await new PrivateZoomApi().getAlbums({
characterId: CHARACTER_ID, characterId: CHARACTER_ID,
limit: 20, limit: 20,
}); });
expect(httpClientMock).toHaveBeenCalledWith("/api/private-room/albums", { expect(httpClientMock).toHaveBeenCalledWith("/api/private-zoom/albums", {
query: { characterId: CHARACTER_ID, limit: 20 }, query: { characterId: CHARACTER_ID, limit: 20 },
}); });
}); });
+2 -2
View File
@@ -21,8 +21,8 @@
"chatHistory": { "method": "get", "path": "/api/chat/history" }, "chatHistory": { "method": "get", "path": "/api/chat/history" },
"chatUnlockPrivate": { "method": "post", "path": "/api/chat/unlock-private" }, "chatUnlockPrivate": { "method": "post", "path": "/api/chat/unlock-private" },
"chatUnlockHistory": { "method": "post", "path": "/api/chat/unlock-history" }, "chatUnlockHistory": { "method": "post", "path": "/api/chat/unlock-history" },
"privateRoomAlbums": { "method": "get", "path": "/api/private-room/albums" }, "privateZoomAlbums": { "method": "get", "path": "/api/private-zoom/albums" },
"privateRoomAlbumUnlock": { "method": "post", "path": "/api/private-room/albums/{albumId}/unlock" }, "privateZoomAlbumUnlock": { "method": "post", "path": "/api/private-zoom/albums/{albumId}/unlock" },
"metricsPwaEvent": { "method": "post", "path": "/api/metrics/pwa/event" }, "metricsPwaEvent": { "method": "post", "path": "/api/metrics/pwa/event" },
"reportUserInfo": { "method": "post", "path": "/api/data/report-user-info" }, "reportUserInfo": { "method": "post", "path": "/api/data/report-user-info" },
"feedback": { "method": "post", "path": "/api/feedback" }, "feedback": { "method": "post", "path": "/api/feedback" },
+3 -3
View File
@@ -81,11 +81,11 @@ export class ApiPath {
// ============ 私密空间相关 ============ // ============ 私密空间相关 ============
/** 获取私密图片包列表 */ /** 获取私密图片包列表 */
static readonly privateRoomAlbums = apiContract.privateRoomAlbums.path; static readonly privateZoomAlbums = apiContract.privateZoomAlbums.path;
/** 解锁私密图片包 */ /** 解锁私密图片包 */
static privateRoomAlbumUnlock(albumId: string): string { static privateZoomAlbumUnlock(albumId: string): string {
return apiContract.privateRoomAlbumUnlock.path.replace( return apiContract.privateZoomAlbumUnlock.path.replace(
"{albumId}", "{albumId}",
encodeURIComponent(albumId), encodeURIComponent(albumId),
); );
+1 -1
View File
@@ -12,6 +12,6 @@ export * from "./feedback_api";
export * from "./http_client"; export * from "./http_client";
export * from "./metrics_api"; export * from "./metrics_api";
export * from "./payment_api"; export * from "./payment_api";
export * from "./private_room_api"; export * from "./private_zoom_api";
export * from "./response_helper"; export * from "./response_helper";
export * from "./user_api"; export * from "./user_api";
@@ -4,7 +4,7 @@ import {
PrivateAlbumUnlockResponse, PrivateAlbumUnlockResponse,
PrivateAlbumUnlockResponseSchema, PrivateAlbumUnlockResponseSchema,
UnlockPrivateAlbumRequest, UnlockPrivateAlbumRequest,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import { ApiPath } from "./api_path"; import { ApiPath } from "./api_path";
import { httpClient } from "./http_client"; import { httpClient } from "./http_client";
@@ -15,12 +15,12 @@ export interface GetPrivateAlbumsInput {
limit?: number; limit?: number;
} }
export class PrivateRoomApi { export class PrivateZoomApi {
async getAlbums( async getAlbums(
input: GetPrivateAlbumsInput, input: GetPrivateAlbumsInput,
): Promise<PrivateAlbumsResponse> { ): Promise<PrivateAlbumsResponse> {
const env = await httpClient<ApiEnvelope<unknown>>( const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.privateRoomAlbums, ApiPath.privateZoomAlbums,
{ {
query: { query: {
characterId: input.characterId, characterId: input.characterId,
@@ -36,7 +36,7 @@ export class PrivateRoomApi {
body: UnlockPrivateAlbumRequest, body: UnlockPrivateAlbumRequest,
): Promise<PrivateAlbumUnlockResponse> { ): Promise<PrivateAlbumUnlockResponse> {
const env = await httpClient<ApiEnvelope<unknown>>( const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.privateRoomAlbumUnlock(albumId), ApiPath.privateZoomAlbumUnlock(albumId),
{ {
method: "POST", method: "POST",
body, body,
@@ -46,4 +46,4 @@ export class PrivateRoomApi {
} }
} }
export const privateRoomApi = new PrivateRoomApi(); export const privateZoomApi = new PrivateZoomApi();
@@ -14,7 +14,7 @@ const PendingPaymentOrderSchema = z
subscriptionType: z.enum(["vip", "topup", "tip"]), subscriptionType: z.enum(["vip", "topup", "tip"]),
giftCategory: z.string().min(1).nullable().default(null), giftCategory: z.string().min(1).nullable().default(null),
giftPlanId: z.string().min(1).nullable().default(null), giftPlanId: z.string().min(1).nullable().default(null),
returnTo: z.enum(["chat", "private-room", "profile"]).optional(), returnTo: z.enum(["chat", "private-zoom", "profile"]).optional(),
characterSlug: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(), characterSlug: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
createdAt: z.number(), createdAt: z.number(),
}) })
@@ -15,7 +15,7 @@ export type PaymentAnalyticsEntryPoint =
| "chat_input" | "chat_input"
| "chat_unlock" | "chat_unlock"
| "private_album_unlock" | "private_album_unlock"
| "private_room" | "private_zoom"
| "profile" | "profile"
| "chat_offer_banner" | "chat_offer_banner"
| "subscription_direct" | "subscription_direct"
@@ -32,7 +32,7 @@ const ENTRY_POINTS = new Set<PaymentAnalyticsEntryPoint>([
"chat_input", "chat_input",
"chat_unlock", "chat_unlock",
"private_album_unlock", "private_album_unlock",
"private_room", "private_zoom",
"profile", "profile",
"chat_offer_banner", "chat_offer_banner",
"subscription_direct", "subscription_direct",
@@ -17,15 +17,15 @@ describe("external entry navigation", () => {
it("resolves only canonical targets", () => { it("resolves only canonical targets", () => {
expect(resolveExternalEntryTarget({ target: "chat" })).toBe(ROUTES.chat); expect(resolveExternalEntryTarget({ target: "chat" })).toBe(ROUTES.chat);
expect(resolveExternalEntryTarget({ target: "tip" })).toBe(ROUTES.tip); expect(resolveExternalEntryTarget({ target: "tip" })).toBe(ROUTES.tip);
expect(resolveExternalEntryTarget({ target: "private-room" })).toBe( expect(resolveExternalEntryTarget({ target: "private-zoom" })).toBe(
ROUTES.privateRoom, ROUTES.privateZoom,
); );
}); });
it("rejects removed aliases and unsupported targets", () => { it("rejects removed aliases and unsupported targets", () => {
expect(resolveExternalEntryTarget({ target: "tips" })).toBe(ROUTES.chat); expect(resolveExternalEntryTarget({ target: "tips" })).toBe(ROUTES.chat);
expect(resolveExternalEntryTarget({ target: "coffee" })).toBe(ROUTES.chat); expect(resolveExternalEntryTarget({ target: "coffee" })).toBe(ROUTES.chat);
expect(resolveExternalEntryTarget({ target: "private_room" })).toBe( expect(resolveExternalEntryTarget({ target: "private_zoom" })).toBe(
ROUTES.chat, ROUTES.chat,
); );
expect(resolveExternalEntryTarget({ target: "/tip" })).toBe(ROUTES.chat); expect(resolveExternalEntryTarget({ target: "/tip" })).toBe(ROUTES.chat);
@@ -44,10 +44,10 @@ describe("external entry navigation", () => {
).toBe(getCharacterRoutes("maya").chat); ).toBe(getCharacterRoutes("maya").chat);
expect( expect(
resolveExternalEntryDestination({ resolveExternalEntryDestination({
target: "private-room", target: "private-zoom",
character: "unknown", character: "unknown",
}), }),
).toBe(getCharacterRoutes("elio").privateRoom); ).toBe(getCharacterRoutes("elio").privateZoom);
}); });
}); });
@@ -89,7 +89,7 @@ describe("subscription exit helpers", () => {
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled(); expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
}); });
it("returns directly to private room without consuming chat state", async () => { it("returns directly to private zoom without consuming chat state", async () => {
consumePendingChatImageReturnMock.mockResolvedValue({ consumePendingChatImageReturnMock.mockResolvedValue({
reason: "image_paywall", reason: "image_paywall",
characterId: "elio", characterId: "elio",
@@ -108,18 +108,18 @@ describe("subscription exit helpers", () => {
createdAt: 1, createdAt: 1,
}); });
expect(getSubscriptionFallbackExitUrl("private-room")).toBe( expect(getSubscriptionFallbackExitUrl("private-zoom")).toBe(
getCharacterRoutes("elio").privateRoom, getCharacterRoutes("elio").privateZoom,
); );
await expect(consumeSubscriptionExitUrl("private-room")).resolves.toBe( await expect(consumeSubscriptionExitUrl("private-zoom")).resolves.toBe(
getCharacterRoutes("elio").privateRoom, getCharacterRoutes("elio").privateZoom,
); );
expect(consumePendingChatImageReturnMock).not.toHaveBeenCalled(); expect(consumePendingChatImageReturnMock).not.toHaveBeenCalled();
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled(); expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
expect(clearPendingChatUnlockMock).not.toHaveBeenCalled(); expect(clearPendingChatUnlockMock).not.toHaveBeenCalled();
}); });
it("keeps private room ahead of stale chat state after payment", async () => { it("keeps private zoom ahead of stale chat state after payment", async () => {
peekPendingChatUnlockMock.mockResolvedValue({ peekPendingChatUnlockMock.mockResolvedValue({
reason: "single_message_unlock", reason: "single_message_unlock",
characterId: "elio", characterId: "elio",
@@ -132,8 +132,8 @@ describe("subscription exit helpers", () => {
}); });
await expect( await expect(
resolveSubscriptionSuccessExitUrl("private-room", "maya"), resolveSubscriptionSuccessExitUrl("private-zoom", "maya"),
).resolves.toBe(getCharacterRoutes("maya").privateRoom); ).resolves.toBe(getCharacterRoutes("maya").privateZoom);
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled(); expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
expect(clearPendingChatUnlockMock).not.toHaveBeenCalled(); expect(clearPendingChatUnlockMock).not.toHaveBeenCalled();
}); });
+3 -3
View File
@@ -13,7 +13,7 @@ import { getCharacterRoutes, ROUTES } from "@/router/routes";
export type ExternalEntryTarget = export type ExternalEntryTarget =
| typeof ROUTES.chat | typeof ROUTES.chat
| typeof ROUTES.tip | typeof ROUTES.tip
| typeof ROUTES.privateRoom; | typeof ROUTES.privateZoom;
export interface ExternalEntryPayload { export interface ExternalEntryPayload {
deviceId?: string | null; deviceId?: string | null;
@@ -91,7 +91,7 @@ export function resolveExternalEntryDestination({
const routes = getCharacterRoutes(characterSlug); const routes = getCharacterRoutes(characterSlug);
const resolvedTarget = resolveExternalEntryTarget({ target }); const resolvedTarget = resolveExternalEntryTarget({ target });
if (resolvedTarget === ROUTES.tip) return routes.tip; if (resolvedTarget === ROUTES.tip) return routes.tip;
if (resolvedTarget === ROUTES.privateRoom) return routes.privateRoom; if (resolvedTarget === ROUTES.privateZoom) return routes.privateZoom;
return routes.chat; return routes.chat;
} }
@@ -129,7 +129,7 @@ function resolveTarget(
if (target === "chat") return ROUTES.chat; if (target === "chat") return ROUTES.chat;
if (target === "tip") return ROUTES.tip; if (target === "tip") return ROUTES.tip;
if (target === "private-room") return ROUTES.privateRoom; if (target === "private-zoom") return ROUTES.privateZoom;
return null; return null;
} }
+5 -5
View File
@@ -47,7 +47,7 @@ export function getSubscriptionFallbackExitUrl(
): string { ): string {
const routes = getCharacterRoutes(characterSlug); const routes = getCharacterRoutes(characterSlug);
if (returnTo === "chat") return routes.chat; if (returnTo === "chat") return routes.chat;
if (returnTo === "private-room") return routes.privateRoom; if (returnTo === "private-zoom") return routes.privateZoom;
if (returnTo === "profile") { if (returnTo === "profile") {
return buildGlobalPageUrl(ROUTES.profile, routes.chat); return buildGlobalPageUrl(ROUTES.profile, routes.chat);
} }
@@ -58,8 +58,8 @@ export async function consumeSubscriptionExitUrl(
returnTo: SubscriptionReturnTo, returnTo: SubscriptionReturnTo,
characterSlug: string = DEFAULT_CHARACTER_SLUG, characterSlug: string = DEFAULT_CHARACTER_SLUG,
): Promise<string> { ): Promise<string> {
if (returnTo === "private-room") { if (returnTo === "private-zoom") {
return getCharacterRoutes(characterSlug).privateRoom; return getCharacterRoutes(characterSlug).privateZoom;
} }
if (returnTo === "profile") { if (returnTo === "profile") {
return getSubscriptionFallbackExitUrl(returnTo, characterSlug); return getSubscriptionFallbackExitUrl(returnTo, characterSlug);
@@ -75,8 +75,8 @@ export async function resolveSubscriptionSuccessExitUrl(
returnTo: SubscriptionReturnTo, returnTo: SubscriptionReturnTo,
characterSlug: string = DEFAULT_CHARACTER_SLUG, characterSlug: string = DEFAULT_CHARACTER_SLUG,
): Promise<string> { ): Promise<string> {
if (returnTo === "private-room") { if (returnTo === "private-zoom") {
return getCharacterRoutes(characterSlug).privateRoom; return getCharacterRoutes(characterSlug).privateZoom;
} }
if (returnTo === "profile") { if (returnTo === "profile") {
return getSubscriptionFallbackExitUrl(returnTo, characterSlug); return getSubscriptionFallbackExitUrl(returnTo, characterSlug);
@@ -39,10 +39,10 @@ describe("payment search params", () => {
it("accepts only supported subscription return targets", () => { it("accepts only supported subscription return targets", () => {
expect(parseSubscriptionReturnTo("chat")).toBe("chat"); expect(parseSubscriptionReturnTo("chat")).toBe("chat");
expect(parseSubscriptionReturnTo("private-room")).toBe("private-room"); expect(parseSubscriptionReturnTo("private-zoom")).toBe("private-zoom");
expect(parseSubscriptionReturnTo("profile")).toBe("profile"); expect(parseSubscriptionReturnTo("profile")).toBe("profile");
expect(parseSubscriptionReturnTo(["private-room", "chat"])).toBe( expect(parseSubscriptionReturnTo(["private-zoom", "chat"])).toBe(
"private-room", "private-zoom",
); );
expect(parseSubscriptionReturnTo("tip")).toBeNull(); expect(parseSubscriptionReturnTo("tip")).toBeNull();
expect(parseSubscriptionReturnTo(undefined)).toBeNull(); expect(parseSubscriptionReturnTo(undefined)).toBeNull();
@@ -20,24 +20,24 @@ describe("pending payment order helpers", () => {
); );
}); });
it("preserves private room returns when rebuilding Ezpay urls", () => { it("preserves private zoom returns when rebuilding Ezpay urls", () => {
expect( expect(
buildPendingPaymentSubscriptionUrl({ buildPendingPaymentSubscriptionUrl({
payChannel: "ezpay", payChannel: "ezpay",
returnTo: "private-room", returnTo: "private-zoom",
subscriptionType: "topup", subscriptionType: "topup",
}), }),
).toBe( ).toBe(
"/subscription?type=topup&payChannel=ezpay&paymentReturn=1&returnTo=private-room&character=elio", "/subscription?type=topup&payChannel=ezpay&paymentReturn=1&returnTo=private-zoom&character=elio",
); );
}); });
it("stores private room as an Ezpay return target", async () => { it("stores private zoom as an Ezpay return target", async () => {
await clearPendingPaymentOrder(); await clearPendingPaymentOrder();
const saveResult = await savePendingEzpayOrder({ const saveResult = await savePendingEzpayOrder({
orderId: "order-private-room", orderId: "order-private-zoom",
returnTo: "private-room", returnTo: "private-zoom",
subscriptionType: "topup", subscriptionType: "topup",
createdAt: 1, createdAt: 1,
}); });
@@ -47,8 +47,8 @@ describe("pending payment order helpers", () => {
expect(storedResult).toMatchObject({ expect(storedResult).toMatchObject({
success: true, success: true,
data: { data: {
orderId: "order-private-room", orderId: "order-private-zoom",
returnTo: "private-room", returnTo: "private-zoom",
}, },
}); });
await clearPendingPaymentOrder(); await clearPendingPaymentOrder();
+1 -1
View File
@@ -28,7 +28,7 @@ export function parseSubscriptionReturnTo(
const returnTo = getFirstPaymentSearchParam(value); const returnTo = getFirstPaymentSearchParam(value);
if ( if (
returnTo === "chat" || returnTo === "chat" ||
returnTo === "private-room" || returnTo === "private-zoom" ||
returnTo === "profile" returnTo === "profile"
) { ) {
return returnTo; return returnTo;
@@ -1,4 +1,4 @@
import type { PrivateAlbum } from "@/data/schemas/private-room"; import type { PrivateAlbum } from "@/data/schemas/private-zoom";
export function isPrivateAlbumLocked(album: PrivateAlbum): boolean { export function isPrivateAlbumLocked(album: PrivateAlbum): boolean {
return album.locked || !album.unlocked || album.lockDetail.locked; return album.locked || !album.unlocked || album.lockDetail.locked;
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const instances = vi.hoisted(() => ({ const instances = vi.hoisted(() => ({
chat: 0, chat: 0,
payment: 0, payment: 0,
privateRoom: 0, privateZoom: 0,
})); }));
vi.mock("@/stores/chat/chat-context", async () => { vi.mock("@/stores/chat/chat-context", async () => {
@@ -51,23 +51,23 @@ vi.mock("@/stores/payment/payment-context", async () => {
}; };
}); });
vi.mock("@/stores/private-room", async () => { vi.mock("@/stores/private-zoom", async () => {
const { createElement, useState } = await import("react"); const { createElement, useState } = await import("react");
return { return {
PrivateRoomProvider({ PrivateZoomProvider({
characterId, characterId,
children, children,
}: { }: {
characterId: string; characterId: string;
children: ReactNode; children: ReactNode;
}) { }) {
const [instanceId] = useState(() => ++instances.privateRoom); const [instanceId] = useState(() => ++instances.privateZoom);
return createElement( return createElement(
"div", "div",
{ {
"data-character-id": characterId, "data-character-id": characterId,
"data-instance-id": instanceId, "data-instance-id": instanceId,
"data-testid": "private-room-provider", "data-testid": "private-zoom-provider",
}, },
children, children,
); );
@@ -85,7 +85,7 @@ vi.mock("@/stores/sync/payment-success-sync", () => ({
import { ChatRouteProviders } from "@/providers/chat-route-providers"; import { ChatRouteProviders } from "@/providers/chat-route-providers";
import { PaymentRouteProvider } from "@/providers/payment-route-provider"; import { PaymentRouteProvider } from "@/providers/payment-route-provider";
import { PrivateRoomRouteProvider } from "@/providers/private-room-route-provider"; import { PrivateZoomRouteProvider } from "@/providers/private-zoom-route-provider";
describe("character actor route providers", () => { describe("character actor route providers", () => {
let container: HTMLDivElement; let container: HTMLDivElement;
@@ -94,7 +94,7 @@ describe("character actor route providers", () => {
beforeEach(() => { beforeEach(() => {
instances.chat = 0; instances.chat = 0;
instances.payment = 0; instances.payment = 0;
instances.privateRoom = 0; instances.privateZoom = 0;
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }) (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean })
.IS_REACT_ACT_ENVIRONMENT = true; .IS_REACT_ACT_ENVIRONMENT = true;
container = document.createElement("div"); container = document.createElement("div");
@@ -121,14 +121,14 @@ describe("character actor route providers", () => {
); );
}); });
it("recreates the private-room actor when the character changes", () => { it("recreates the private-zoom actor when the character changes", () => {
renderPrivateRoom("elio"); renderPrivateZoom("elio");
const firstInstance = instanceId("private-room-provider"); const firstInstance = instanceId("private-zoom-provider");
renderPrivateRoom("maya-tan"); renderPrivateZoom("maya-tan");
expect(instanceId("private-room-provider")).not.toBe(firstInstance); expect(instanceId("private-zoom-provider")).not.toBe(firstInstance);
expect(testNode("private-room-provider").dataset.characterId).toBe( expect(testNode("private-zoom-provider").dataset.characterId).toBe(
"maya-tan", "maya-tan",
); );
}); });
@@ -155,12 +155,12 @@ describe("character actor route providers", () => {
}); });
} }
function renderPrivateRoom(characterId: string): void { function renderPrivateZoom(characterId: string): void {
act(() => { act(() => {
root.render( root.render(
<PrivateRoomRouteProvider characterId={characterId}> <PrivateZoomRouteProvider characterId={characterId}>
<span>private room</span> <span>private zoom</span>
</PrivateRoomRouteProvider>, </PrivateZoomRouteProvider>,
); );
}); });
} }
@@ -1,21 +0,0 @@
"use client";
import type { ReactNode } from "react";
import { PrivateRoomProvider } from "@/stores/private-room";
export interface PrivateRoomRouteProviderProps {
children: ReactNode;
characterId: string;
}
export function PrivateRoomRouteProvider({
children,
characterId,
}: PrivateRoomRouteProviderProps) {
return (
<PrivateRoomProvider key={characterId} characterId={characterId}>
{children}
</PrivateRoomProvider>
);
}
@@ -0,0 +1,21 @@
"use client";
import type { ReactNode } from "react";
import { PrivateZoomProvider } from "@/stores/private-zoom";
export interface PrivateZoomRouteProviderProps {
children: ReactNode;
characterId: string;
}
export function PrivateZoomRouteProvider({
children,
characterId,
}: PrivateZoomRouteProviderProps) {
return (
<PrivateZoomProvider key={characterId} characterId={characterId}>
{children}
</PrivateZoomProvider>
);
}
+1 -1
View File
@@ -4,7 +4,7 @@
* 根级 Client Providers 包装 * 根级 Client Providers 包装
* *
* 这里只保留跨路由的 Character Catalog、Auth、User、消息预览和 viewport * 这里只保留跨路由的 Character Catalog、Auth、User、消息预览和 viewport
* Provider。Chat、Payment、PrivateRoom 状态机由对应路由 layout 按需挂载。 * Provider。Chat、Payment、PrivateZoom 状态机由对应路由 layout 按需挂载。
*/ */
import type { ReactNode } from "react"; import type { ReactNode } from "react";
@@ -43,7 +43,7 @@ describe("global route context", () => {
"https://example.com/characters/maya/chat", "https://example.com/characters/maya/chat",
"//example.com/characters/maya/chat", "//example.com/characters/maya/chat",
"/characters/unknown/chat", "/characters/unknown/chat",
"/characters/maya/private-room", "/characters/maya/private-zoom",
"/characters/maya/chat?image=1", "/characters/maya/chat?image=1",
])("falls back to Elio for an invalid return target", (value) => { ])("falls back to Elio for an invalid return target", (value) => {
expect(resolveGlobalRouteContextValue(value)).toBe( expect(resolveGlobalRouteContextValue(value)).toBe(
@@ -54,15 +54,15 @@ describe("navigation resolver", () => {
).toBe(ROUTE_BUILDERS.authWithRedirect(subscriptionUrl)); ).toBe(ROUTE_BUILDERS.authWithRedirect(subscriptionUrl));
}); });
it("builds private room subscription return urls", () => { it("builds private zoom subscription return urls", () => {
expect( expect(
ROUTE_BUILDERS.subscription("topup", { ROUTE_BUILDERS.subscription("topup", {
payChannel: "stripe", payChannel: "stripe",
returnTo: "private-room", returnTo: "private-zoom",
sourceCharacterSlug: "maya", sourceCharacterSlug: "maya",
}), }),
).toBe( ).toBe(
"/subscription?type=topup&payChannel=stripe&returnTo=private-room&character=maya", "/subscription?type=topup&payChannel=stripe&returnTo=private-zoom&character=maya",
); );
}); });
+5 -5
View File
@@ -8,7 +8,7 @@ describe("route meta", () => {
expect(getRouteAccess(ROUTES.splash)).toBe("authOnly"); expect(getRouteAccess(ROUTES.splash)).toBe("authOnly");
expect(getRouteAccess(ROUTES.auth)).toBe("authOnly"); expect(getRouteAccess(ROUTES.auth)).toBe("authOnly");
expect(getRouteAccess(ROUTES.chat)).toBe("guestEntry"); expect(getRouteAccess(ROUTES.chat)).toBe("guestEntry");
expect(getRouteAccess(ROUTES.privateRoom)).toBe("guestEntry"); expect(getRouteAccess(ROUTES.privateZoom)).toBe("guestEntry");
expect(getRouteAccess(ROUTES.tip)).toBe("public"); expect(getRouteAccess(ROUTES.tip)).toBe("public");
expect(getRouteAccess(ROUTES.externalEntry)).toBe("public"); expect(getRouteAccess(ROUTES.externalEntry)).toBe("public");
expect(getRouteAccess(ROUTES.profile)).toBe("realUser"); expect(getRouteAccess(ROUTES.profile)).toBe("realUser");
@@ -26,12 +26,12 @@ describe("route meta", () => {
expect(routes).toEqual({ expect(routes).toEqual({
splash: "/characters/maya/splash", splash: "/characters/maya/splash",
chat: "/characters/maya/chat", chat: "/characters/maya/chat",
privateRoom: "/characters/maya/private-room", privateZoom: "/characters/maya/private-zoom",
tip: "/characters/maya/tip", tip: "/characters/maya/tip",
}); });
expect(getRouteAccess(routes.splash)).toBe("authOnly"); expect(getRouteAccess(routes.splash)).toBe("authOnly");
expect(getRouteAccess(routes.chat)).toBe("guestEntry"); expect(getRouteAccess(routes.chat)).toBe("guestEntry");
expect(getRouteAccess(routes.privateRoom)).toBe("guestEntry"); expect(getRouteAccess(routes.privateZoom)).toBe("guestEntry");
expect(getRouteAccess(routes.tip)).toBe("public"); expect(getRouteAccess(routes.tip)).toBe("public");
}); });
@@ -41,8 +41,8 @@ describe("route meta", () => {
expect(getRouteAccess("/characters/maya/coins-rules")).toBe("public"); expect(getRouteAccess("/characters/maya/coins-rules")).toBe("public");
}); });
it("includes private room in static routes", () => { it("includes private zoom in static routes", () => {
expect(ALL_STATIC_ROUTES).toContain(ROUTES.privateRoom); expect(ALL_STATIC_ROUTES).toContain(ROUTES.privateZoom);
}); });
it("includes tip in static routes", () => { it("includes tip in static routes", () => {
+1 -1
View File
@@ -9,7 +9,7 @@ import type {
export type AppSubscriptionType = "vip" | "topup"; export type AppSubscriptionType = "vip" | "topup";
export type AppSubscriptionReturnTo = export type AppSubscriptionReturnTo =
| "chat" | "chat"
| "private-room" | "private-zoom"
| "profile" | "profile"
| null; | null;
+2 -2
View File
@@ -12,7 +12,7 @@ const GLOBAL_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
[ROUTES.splash]: "authOnly", [ROUTES.splash]: "authOnly",
[ROUTES.auth]: "authOnly", [ROUTES.auth]: "authOnly",
[ROUTES.chat]: "guestEntry", [ROUTES.chat]: "guestEntry",
[ROUTES.privateRoom]: "guestEntry", [ROUTES.privateZoom]: "guestEntry",
[ROUTES.tip]: "public", [ROUTES.tip]: "public",
[ROUTES.externalEntry]: "public", [ROUTES.externalEntry]: "public",
[ROUTES.profile]: "realUser", [ROUTES.profile]: "realUser",
@@ -24,7 +24,7 @@ const GLOBAL_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
const CHARACTER_ROUTE_ACCESS: Readonly<Record<string, RouteAccess>> = { const CHARACTER_ROUTE_ACCESS: Readonly<Record<string, RouteAccess>> = {
splash: "authOnly", splash: "authOnly",
chat: "guestEntry", chat: "guestEntry",
"private-room": "guestEntry", "private-zoom": "guestEntry",
tip: "public", tip: "public",
}; };
+4 -4
View File
@@ -21,7 +21,7 @@ export const ROUTES = {
root: "/", root: "/",
splash: "/splash", splash: "/splash",
chat: "/chat", chat: "/chat",
privateRoom: "/private-room", privateZoom: "/private-zoom",
tip: "/tip", tip: "/tip",
externalEntry: "/external-entry", externalEntry: "/external-entry",
auth: "/auth", auth: "/auth",
@@ -36,7 +36,7 @@ export type StaticRoute = (typeof ROUTES)[keyof typeof ROUTES];
export interface CharacterRoutes { export interface CharacterRoutes {
readonly splash: string; readonly splash: string;
readonly chat: string; readonly chat: string;
readonly privateRoom: string; readonly privateZoom: string;
readonly tip: string; readonly tip: string;
} }
@@ -47,7 +47,7 @@ export function getCharacterRoutes(
return { return {
splash: `${root}/splash`, splash: `${root}/splash`,
chat: `${root}/chat`, chat: `${root}/chat`,
privateRoom: `${root}/private-room`, privateZoom: `${root}/private-zoom`,
tip: `${root}/tip`, tip: `${root}/tip`,
}; };
} }
@@ -110,7 +110,7 @@ export const ROUTE_BUILDERS = {
export const ALL_STATIC_ROUTES: readonly StaticRoute[] = [ export const ALL_STATIC_ROUTES: readonly StaticRoute[] = [
ROUTES.splash, ROUTES.splash,
ROUTES.chat, ROUTES.chat,
ROUTES.privateRoom, ROUTES.privateZoom,
ROUTES.tip, ROUTES.tip,
ROUTES.externalEntry, ROUTES.externalEntry,
ROUTES.auth, ROUTES.auth,
-7
View File
@@ -1,7 +0,0 @@
/** @file Private Room store barrel. */
export * from "./private-room-context";
export * from "./private-room-events";
export * from "./helper";
export * from "./private-room-machine";
export * from "./private-room-state";
@@ -1,8 +0,0 @@
/** Public events for one character-scoped Private Room actor. */
export type PrivateRoomEvent =
| { type: "PrivateRoomInit" }
| { type: "PrivateRoomRefresh" }
| { type: "PrivateRoomUnlockRequested"; albumId: string }
| { type: "PrivateRoomUnlockConfirmed" }
| { type: "PrivateRoomUnlockCancelled" }
| { type: "PrivateRoomUnlockPaywallConsumed" };
@@ -1,18 +0,0 @@
import {
privateRoomMachineSetup,
privateRoomRootStateConfig,
} from "./machine/unlock-flow";
import { createInitialPrivateRoomState } from "./private-room-state";
export type { PrivateRoomEvent } from "./private-room-events";
export type { PrivateRoomState } from "./private-room-state";
export { initialState } from "./private-room-state";
export const privateRoomMachine = privateRoomMachineSetup.createMachine({
id: "privateRoom",
context: ({ input }) =>
createInitialPrivateRoomState(input.characterId),
...privateRoomRootStateConfig,
});
export type PrivateRoomMachine = typeof privateRoomMachine;
@@ -2,18 +2,18 @@ import { describe, expect, it } from "vitest";
import { createActor, waitFor } from "xstate"; import { createActor, waitFor } from "xstate";
import { import {
createTestPrivateRoomMachine, createTestPrivateZoomMachine,
loadPrivateRoom, loadPrivateZoom,
makeAlbum, makeAlbum,
makeAlbumsResponse, makeAlbumsResponse,
TEST_PRIVATE_ROOM_INPUT, TEST_PRIVATE_ZOOM_INPUT,
} from "./private-room-machine.test-utils"; } from "./private-zoom-machine.test-utils";
describe("private room album flow", () => { describe("private zoom album flow", () => {
it("loads albums for the supplied character", async () => { it("loads albums for the supplied character", async () => {
let loadedCharacterId: string | null = null; let loadedCharacterId: string | null = null;
const actor = createActor( const actor = createActor(
createTestPrivateRoomMachine({ createTestPrivateZoomMachine({
onLoad: ({ characterId }) => { onLoad: ({ characterId }) => {
loadedCharacterId = characterId; loadedCharacterId = characterId;
}, },
@@ -21,7 +21,7 @@ describe("private room album flow", () => {
{ input: { characterId: "character_aria" } }, { input: { characterId: "character_aria" } },
).start(); ).start();
actor.send({ type: "PrivateRoomInit" }); actor.send({ type: "PrivateZoomInit" });
await waitFor(actor, (snapshot) => snapshot.matches("ready")); await waitFor(actor, (snapshot) => snapshot.matches("ready"));
expect(actor.getSnapshot().context.characterId).toBe("character_aria"); expect(actor.getSnapshot().context.characterId).toBe("character_aria");
@@ -30,7 +30,7 @@ describe("private room album flow", () => {
}); });
it("loads only the first non-paginated album page", async () => { it("loads only the first non-paginated album page", async () => {
const actor = await loadPrivateRoom({ const actor = await loadPrivateZoom({
loadResponse: makeAlbumsResponse({ loadResponse: makeAlbumsResponse({
items: Array.from({ length: 20 }, (_, index) => makeAlbum(index)), items: Array.from({ length: 20 }, (_, index) => makeAlbum(index)),
}), }),
@@ -43,12 +43,12 @@ describe("private room album flow", () => {
it("moves to failed when the album actor rejects", async () => { it("moves to failed when the album actor rejects", async () => {
const actor = createActor( const actor = createActor(
createTestPrivateRoomMachine({ createTestPrivateZoomMachine({
loadError: new Error("albums unavailable"), loadError: new Error("albums unavailable"),
}), }),
{ input: TEST_PRIVATE_ROOM_INPUT }, { input: TEST_PRIVATE_ZOOM_INPUT },
).start(); ).start();
actor.send({ type: "PrivateRoomInit" }); actor.send({ type: "PrivateZoomInit" });
await waitFor(actor, (snapshot) => snapshot.matches("failed")); await waitFor(actor, (snapshot) => snapshot.matches("failed"));
expect(actor.getSnapshot().context.errorMessage).toBe( expect(actor.getSnapshot().context.errorMessage).toBe(
"albums unavailable", "albums unavailable",
@@ -8,13 +8,13 @@ import {
type PrivateAlbumUnlockResponseInput, type PrivateAlbumUnlockResponseInput,
type PrivateAlbumsResponse, type PrivateAlbumsResponse,
type PrivateAlbumsResponseInput, type PrivateAlbumsResponseInput,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import { privateRoomMachine } from "@/stores/private-room/private-room-machine"; import { privateZoomMachine } from "@/stores/private-zoom/private-zoom-machine";
export const ALBUM_ID = "a1b2c3d4-0000-0000-0000-000000000000"; export const ALBUM_ID = "a1b2c3d4-0000-0000-0000-000000000000";
export const COVER_URL = export const COVER_URL =
"https://dbapi.banlv-ai.com/storage/v1/object/public/elio-schedules/01.jpg"; "https://dbapi.banlv-ai.com/storage/v1/object/public/elio-schedules/01.jpg";
export const TEST_PRIVATE_ROOM_INPUT = { export const TEST_PRIVATE_ZOOM_INPUT = {
characterId: DEFAULT_CHARACTER_ID, characterId: DEFAULT_CHARACTER_ID,
}; };
@@ -65,7 +65,7 @@ export function makeUnlockResponse(
}); });
} }
export function createTestPrivateRoomMachine( export function createTestPrivateZoomMachine(
options: { options: {
loadResponse?: PrivateAlbumsResponse; loadResponse?: PrivateAlbumsResponse;
unlockResponse?: PrivateAlbumUnlockResponse; unlockResponse?: PrivateAlbumUnlockResponse;
@@ -74,7 +74,7 @@ export function createTestPrivateRoomMachine(
onLoad?: (input: { characterId: string }) => void; onLoad?: (input: { characterId: string }) => void;
} = {}, } = {},
) { ) {
return privateRoomMachine.provide({ return privateZoomMachine.provide({
actors: { actors: {
loadAlbums: fromPromise<PrivateAlbumsResponse, { characterId: string }>( loadAlbums: fromPromise<PrivateAlbumsResponse, { characterId: string }>(
async ({ input }) => { async ({ input }) => {
@@ -91,24 +91,24 @@ export function createTestPrivateRoomMachine(
}); });
} }
export async function loadPrivateRoom( export async function loadPrivateZoom(
options: Parameters<typeof createTestPrivateRoomMachine>[0] = {}, options: Parameters<typeof createTestPrivateZoomMachine>[0] = {},
) { ) {
const actor = createActor(createTestPrivateRoomMachine(options), { const actor = createActor(createTestPrivateZoomMachine(options), {
input: TEST_PRIVATE_ROOM_INPUT, input: TEST_PRIVATE_ZOOM_INPUT,
}).start(); }).start();
actor.send({ type: "PrivateRoomInit" }); actor.send({ type: "PrivateZoomInit" });
await waitFor(actor, (snapshot) => snapshot.matches("ready")); await waitFor(actor, (snapshot) => snapshot.matches("ready"));
return actor; return actor;
} }
export async function unlockFirstAlbum( export async function unlockFirstAlbum(
actor: Awaited<ReturnType<typeof loadPrivateRoom>>, actor: Awaited<ReturnType<typeof loadPrivateZoom>>,
) { ) {
actor.send({ actor.send({
type: "PrivateRoomUnlockRequested", type: "PrivateZoomUnlockRequested",
albumId: ALBUM_ID, albumId: ALBUM_ID,
}); });
actor.send({ type: "PrivateRoomUnlockConfirmed" }); actor.send({ type: "PrivateZoomUnlockConfirmed" });
await waitFor(actor, (snapshot) => snapshot.matches("ready")); await waitFor(actor, (snapshot) => snapshot.matches("ready"));
} }
@@ -3,14 +3,14 @@ import { describe, expect, it } from "vitest";
import { import {
ALBUM_ID, ALBUM_ID,
COVER_URL, COVER_URL,
loadPrivateRoom, loadPrivateZoom,
makeUnlockResponse, makeUnlockResponse,
unlockFirstAlbum, unlockFirstAlbum,
} from "./private-room-machine.test-utils"; } from "./private-zoom-machine.test-utils";
describe("private room unlock flow", () => { describe("private zoom unlock flow", () => {
it("patches album images after a successful unlock", async () => { it("patches album images after a successful unlock", async () => {
const actor = await loadPrivateRoom(); const actor = await loadPrivateZoom();
await unlockFirstAlbum(actor); await unlockFirstAlbum(actor);
expect(actor.getSnapshot().context.items[0]).toMatchObject({ expect(actor.getSnapshot().context.items[0]).toMatchObject({
albumId: ALBUM_ID, albumId: ALBUM_ID,
@@ -24,7 +24,7 @@ describe("private room unlock flow", () => {
}); });
it("exposes a paywall request when credits are low", async () => { it("exposes a paywall request when credits are low", async () => {
const actor = await loadPrivateRoom({ const actor = await loadPrivateZoom({
unlockResponse: makeUnlockResponse({ unlockResponse: makeUnlockResponse({
locked: true, locked: true,
unlocked: false, unlocked: false,
@@ -47,7 +47,7 @@ describe("private room unlock flow", () => {
it("reloads when expected cost changes", async () => { it("reloads when expected cost changes", async () => {
let loadCount = 0; let loadCount = 0;
const actor = await loadPrivateRoom({ const actor = await loadPrivateZoom({
onLoad: () => { onLoad: () => {
loadCount += 1; loadCount += 1;
}, },
@@ -66,7 +66,7 @@ describe("private room unlock flow", () => {
}); });
it("removes an album that no longer exists", async () => { it("removes an album that no longer exists", async () => {
const actor = await loadPrivateRoom({ const actor = await loadPrivateZoom({
unlockResponse: makeUnlockResponse({ unlockResponse: makeUnlockResponse({
locked: true, locked: true,
unlocked: false, unlocked: false,
@@ -80,7 +80,7 @@ describe("private room unlock flow", () => {
}); });
it("keeps refunded persistence failures locked", async () => { it("keeps refunded persistence failures locked", async () => {
const actor = await loadPrivateRoom({ const actor = await loadPrivateZoom({
unlockResponse: makeUnlockResponse({ unlockResponse: makeUnlockResponse({
locked: true, locked: true,
unlocked: false, unlocked: false,
@@ -99,7 +99,7 @@ describe("private room unlock flow", () => {
}); });
it("returns to ready when the unlock actor rejects", async () => { it("returns to ready when the unlock actor rejects", async () => {
const actor = await loadPrivateRoom({ const actor = await loadPrivateZoom({
unlockError: new Error("unlock unavailable"), unlockError: new Error("unlock unavailable"),
}); });
await unlockFirstAlbum(actor); await unlockFirstAlbum(actor);
@@ -3,15 +3,15 @@ import {
PrivateAlbumSchema, PrivateAlbumSchema,
type PrivateAlbumsResponse, type PrivateAlbumsResponse,
type PrivateAlbumUnlockResponse, type PrivateAlbumUnlockResponse,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import type { PrivateRoomState } from "../private-room-state"; import type { PrivateZoomState } from "../private-zoom-state";
export const PRIVATE_ROOM_PAGE_SIZE = 20; export const PRIVATE_ZOOM_PAGE_SIZE = 20;
export function applyAlbumsResponse( export function applyAlbumsResponse(
response: PrivateAlbumsResponse, response: PrivateAlbumsResponse,
): Partial<PrivateRoomState> { ): Partial<PrivateZoomState> {
return { return {
items: response.items, items: response.items,
creditBalance: response.creditBalance, creditBalance: response.creditBalance,
@@ -20,7 +20,7 @@ export function applyAlbumsResponse(
} }
export function getPendingAlbum( export function getPendingAlbum(
context: PrivateRoomState, context: PrivateZoomState,
): PrivateAlbum | null { ): PrivateAlbum | null {
if (!context.pendingConfirmAlbumId) return null; if (!context.pendingConfirmAlbumId) return null;
return ( return (
@@ -1,10 +1,10 @@
import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-room"; import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-zoom";
import type { PrivateRoomUnlockPaywallRequest } from "../private-room-state"; import type { PrivateZoomUnlockPaywallRequest } from "../private-zoom-state";
export function toPrivateRoomErrorMessage(error: unknown): string { export function toPrivateZoomErrorMessage(error: unknown): string {
if (error instanceof Error && error.message) return error.message; if (error instanceof Error && error.message) return error.message;
return "Private room is temporarily unavailable. Please try again."; return "Private Zoom is temporarily unavailable. Please try again.";
} }
export function toUnlockErrorMessage( export function toUnlockErrorMessage(
@@ -30,7 +30,7 @@ export function toUnlockErrorMessage(
export function toPaywallRequest( export function toPaywallRequest(
response: PrivateAlbumUnlockResponse, response: PrivateAlbumUnlockResponse,
): PrivateRoomUnlockPaywallRequest { ): PrivateZoomUnlockPaywallRequest {
return { return {
albumId: response.albumId, albumId: response.albumId,
reason: response.reason, reason: response.reason,
+7
View File
@@ -0,0 +1,7 @@
/** @file Private Zoom store barrel. */
export * from "./private-zoom-context";
export * from "./private-zoom-events";
export * from "./helper";
export * from "./private-zoom-machine";
export * from "./private-zoom-state";
@@ -3,19 +3,19 @@ import { fromPromise } from "xstate";
import type { import type {
PrivateAlbumsResponse, PrivateAlbumsResponse,
PrivateAlbumUnlockResponse, PrivateAlbumUnlockResponse,
} from "@/data/schemas/private-room"; } from "@/data/schemas/private-zoom";
import { getPrivateRoomRepository } from "@/data/repositories/private_room_repository"; import { getPrivateZoomRepository } from "@/data/repositories/private_zoom_repository";
import { Result } from "@/utils/result"; import { Result } from "@/utils/result";
import { PRIVATE_ROOM_PAGE_SIZE } from "../../helper/albums"; import { PRIVATE_ZOOM_PAGE_SIZE } from "../../helper/albums";
export const loadPrivateAlbumsActor = export const loadPrivateAlbumsActor =
fromPromise<PrivateAlbumsResponse, { characterId: string }>(async ({ fromPromise<PrivateAlbumsResponse, { characterId: string }>(async ({
input, input,
}) => { }) => {
const result = await getPrivateRoomRepository().getAlbums({ const result = await getPrivateZoomRepository().getAlbums({
characterId: input.characterId, characterId: input.characterId,
limit: PRIVATE_ROOM_PAGE_SIZE, limit: PRIVATE_ZOOM_PAGE_SIZE,
}); });
if (Result.isErr(result)) throw result.error; if (Result.isErr(result)) throw result.error;
return result.data; return result.data;
@@ -25,7 +25,7 @@ export const unlockPrivateAlbumActor = fromPromise<
PrivateAlbumUnlockResponse, PrivateAlbumUnlockResponse,
{ albumId: string; expectedCost: number } { albumId: string; expectedCost: number }
>(async ({ input }) => { >(async ({ input }) => {
const result = await getPrivateRoomRepository().unlockAlbum( const result = await getPrivateZoomRepository().unlockAlbum(
input.albumId, input.albumId,
input.expectedCost, input.expectedCost,
); );
@@ -1,43 +1,43 @@
import type { DoneActorEvent, ErrorActorEvent } from "xstate"; import type { DoneActorEvent, ErrorActorEvent } from "xstate";
import type { PrivateAlbumsResponse } from "@/data/schemas/private-room"; import type { PrivateAlbumsResponse } from "@/data/schemas/private-zoom";
import { applyAlbumsResponse } from "../helper/albums"; import { applyAlbumsResponse } from "../helper/albums";
import { toPrivateRoomErrorMessage } from "../helper/unlock"; import { toPrivateZoomErrorMessage } from "../helper/unlock";
import { import {
basePrivateRoomMachineSetup, basePrivateZoomMachineSetup,
createPrivateRoomActorActionSetup, createPrivateZoomActorActionSetup,
} from "./setup"; } from "./setup";
const clearAlbumLoadStateAction = basePrivateRoomMachineSetup.assign({ const clearAlbumLoadStateAction = basePrivateZoomMachineSetup.assign({
errorMessage: null, errorMessage: null,
unlockPaywallRequest: null, unlockPaywallRequest: null,
}); });
export const albumMachineSetup = basePrivateRoomMachineSetup.extend({ export const albumMachineSetup = basePrivateZoomMachineSetup.extend({
actions: { actions: {
clearAlbumLoadState: clearAlbumLoadStateAction, clearAlbumLoadState: clearAlbumLoadStateAction,
}, },
}); });
const albumsDoneSetup = const albumsDoneSetup =
createPrivateRoomActorActionSetup< createPrivateZoomActorActionSetup<
DoneActorEvent<PrivateAlbumsResponse> DoneActorEvent<PrivateAlbumsResponse>
>(); >();
const albumErrorSetup = const albumErrorSetup =
createPrivateRoomActorActionSetup<ErrorActorEvent>(); createPrivateZoomActorActionSetup<ErrorActorEvent>();
const applyAlbumsResponseAction = albumsDoneSetup.assign(({ event }) => const applyAlbumsResponseAction = albumsDoneSetup.assign(({ event }) =>
applyAlbumsResponse(event.output), applyAlbumsResponse(event.output),
); );
const applyAlbumLoadErrorAction = albumErrorSetup.assign(({ event }) => ({ const applyAlbumLoadErrorAction = albumErrorSetup.assign(({ event }) => ({
errorMessage: toPrivateRoomErrorMessage(event.error), errorMessage: toPrivateZoomErrorMessage(event.error),
})); }));
export const idleState = albumMachineSetup.createStateConfig({ export const idleState = albumMachineSetup.createStateConfig({
on: { on: {
PrivateRoomInit: "loading", PrivateZoomInit: "loading",
}, },
}); });
@@ -59,7 +59,7 @@ export const loadingState = albumMachineSetup.createStateConfig({
export const failedState = albumMachineSetup.createStateConfig({ export const failedState = albumMachineSetup.createStateConfig({
on: { on: {
PrivateRoomInit: "loading", PrivateZoomInit: "loading",
PrivateRoomRefresh: "loading", PrivateZoomRefresh: "loading",
}, },
}); });
@@ -1,22 +1,22 @@
import { setup, type ActionFunction, type EventObject } from "xstate"; import { setup, type ActionFunction, type EventObject } from "xstate";
import { getPendingAlbum } from "../helper/albums"; import { getPendingAlbum } from "../helper/albums";
import type { PrivateRoomEvent } from "../private-room-events"; import type { PrivateZoomEvent } from "../private-zoom-events";
import type { PrivateRoomState } from "../private-room-state"; import type { PrivateZoomState } from "../private-zoom-state";
import { import {
loadPrivateAlbumsActor, loadPrivateAlbumsActor,
unlockPrivateAlbumActor, unlockPrivateAlbumActor,
} from "./actors/albums"; } from "./actors/albums";
export interface PrivateRoomMachineInput { export interface PrivateZoomMachineInput {
characterId: string; characterId: string;
} }
export const basePrivateRoomMachineSetup = setup({ export const basePrivateZoomMachineSetup = setup({
types: { types: {
context: {} as PrivateRoomState, context: {} as PrivateZoomState,
events: {} as PrivateRoomEvent, events: {} as PrivateZoomEvent,
input: {} as PrivateRoomMachineInput, input: {} as PrivateZoomMachineInput,
}, },
actors: { actors: {
loadAlbums: loadPrivateAlbumsActor, loadAlbums: loadPrivateAlbumsActor,
@@ -27,10 +27,10 @@ export const basePrivateRoomMachineSetup = setup({
}, },
}); });
type PrivateRoomActorAction<TEvent extends EventObject> = ActionFunction< type PrivateZoomActorAction<TEvent extends EventObject> = ActionFunction<
PrivateRoomState, PrivateZoomState,
TEvent, TEvent,
PrivateRoomEvent, PrivateZoomEvent,
undefined, undefined,
never, never,
never, never,
@@ -39,22 +39,22 @@ type PrivateRoomActorAction<TEvent extends EventObject> = ActionFunction<
never never
>; >;
export function createPrivateRoomActorActionSetup< export function createPrivateZoomActorActionSetup<
TEvent extends EventObject, TEvent extends EventObject,
>() { >() {
const actorActionSetup = setup({ const actorActionSetup = setup({
types: { types: {
context: {} as PrivateRoomState, context: {} as PrivateZoomState,
events: {} as TEvent, events: {} as TEvent,
}, },
}); });
return { return {
assign( assign(
assignment: Parameters<typeof actorActionSetup.assign>[0], assignment: Parameters<typeof actorActionSetup.assign>[0],
): PrivateRoomActorAction<TEvent> { ): PrivateZoomActorAction<TEvent> {
return actorActionSetup.assign( return actorActionSetup.assign(
assignment, assignment,
) as unknown as PrivateRoomActorAction<TEvent>; ) as unknown as PrivateZoomActorAction<TEvent>;
}, },
}; };
} }
@@ -1,6 +1,6 @@
import type { DoneActorEvent, ErrorActorEvent } from "xstate"; import type { DoneActorEvent, ErrorActorEvent } from "xstate";
import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-room"; import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-zoom";
import { import {
getPendingAlbum, getPendingAlbum,
@@ -9,7 +9,7 @@ import {
} from "../helper/albums"; } from "../helper/albums";
import { import {
toPaywallRequest, toPaywallRequest,
toPrivateRoomErrorMessage, toPrivateZoomErrorMessage,
toUnlockErrorMessage, toUnlockErrorMessage,
} from "../helper/unlock"; } from "../helper/unlock";
import { import {
@@ -18,10 +18,10 @@ import {
idleState, idleState,
loadingState, loadingState,
} from "./album-flow"; } from "./album-flow";
import { createPrivateRoomActorActionSetup } from "./setup"; import { createPrivateZoomActorActionSetup } from "./setup";
const requestUnlockAction = albumMachineSetup.assign(({ event }) => const requestUnlockAction = albumMachineSetup.assign(({ event }) =>
event.type === "PrivateRoomUnlockRequested" event.type === "PrivateZoomUnlockRequested"
? { ? {
pendingConfirmAlbumId: event.albumId, pendingConfirmAlbumId: event.albumId,
unlockErrorMessage: null, unlockErrorMessage: null,
@@ -44,7 +44,7 @@ const beginUnlockAction = albumMachineSetup.assign(({ context }) => ({
unlockPaywallRequest: null, unlockPaywallRequest: null,
})); }));
export const privateRoomMachineSetup = albumMachineSetup.extend({ export const privateZoomMachineSetup = albumMachineSetup.extend({
actions: { actions: {
requestUnlock: requestUnlockAction, requestUnlock: requestUnlockAction,
cancelUnlock: cancelUnlockAction, cancelUnlock: cancelUnlockAction,
@@ -54,11 +54,11 @@ export const privateRoomMachineSetup = albumMachineSetup.extend({
}); });
const unlockDoneSetup = const unlockDoneSetup =
createPrivateRoomActorActionSetup< createPrivateZoomActorActionSetup<
DoneActorEvent<PrivateAlbumUnlockResponse> DoneActorEvent<PrivateAlbumUnlockResponse>
>(); >();
const unlockErrorSetup = const unlockErrorSetup =
createPrivateRoomActorActionSetup<ErrorActorEvent>(); createPrivateZoomActorActionSetup<ErrorActorEvent>();
const applyUnlockSuccessAction = unlockDoneSetup.assign( const applyUnlockSuccessAction = unlockDoneSetup.assign(
({ context, event }) => ({ ({ context, event }) => ({
@@ -111,26 +111,26 @@ const applyUnlockFailureAction = unlockDoneSetup.assign(
const applyUnlockActorErrorAction = unlockErrorSetup.assign(({ event }) => ({ const applyUnlockActorErrorAction = unlockErrorSetup.assign(({ event }) => ({
pendingConfirmAlbumId: null, pendingConfirmAlbumId: null,
unlockingAlbumId: null, unlockingAlbumId: null,
unlockErrorMessage: toPrivateRoomErrorMessage(event.error), unlockErrorMessage: toPrivateZoomErrorMessage(event.error),
})); }));
const readyState = privateRoomMachineSetup.createStateConfig({ const readyState = privateZoomMachineSetup.createStateConfig({
on: { on: {
PrivateRoomInit: "loading", PrivateZoomInit: "loading",
PrivateRoomRefresh: "loading", PrivateZoomRefresh: "loading",
PrivateRoomUnlockRequested: { actions: "requestUnlock" }, PrivateZoomUnlockRequested: { actions: "requestUnlock" },
PrivateRoomUnlockCancelled: { actions: "cancelUnlock" }, PrivateZoomUnlockCancelled: { actions: "cancelUnlock" },
PrivateRoomUnlockConfirmed: [ PrivateZoomUnlockConfirmed: [
{ {
guard: "hasPendingAlbum", guard: "hasPendingAlbum",
target: "unlocking", target: "unlocking",
}, },
], ],
PrivateRoomUnlockPaywallConsumed: { actions: "clearUnlockPaywall" }, PrivateZoomUnlockPaywallConsumed: { actions: "clearUnlockPaywall" },
}, },
}); });
const unlockingState = privateRoomMachineSetup.createStateConfig({ const unlockingState = privateZoomMachineSetup.createStateConfig({
entry: "beginUnlock", entry: "beginUnlock",
invoke: { invoke: {
src: "unlockAlbum", src: "unlockAlbum",
@@ -175,8 +175,8 @@ const unlockingState = privateRoomMachineSetup.createStateConfig({
}, },
}); });
export const privateRoomRootStateConfig = export const privateZoomRootStateConfig =
privateRoomMachineSetup.createStateConfig({ privateZoomMachineSetup.createStateConfig({
initial: "idle", initial: "idle",
states: { states: {
idle: idleState, idle: idleState,
@@ -4,14 +4,14 @@ import type { Dispatch, ReactNode } from "react";
import { createActorContext, shallowEqual } from "@xstate/react"; import { createActorContext, shallowEqual } from "@xstate/react";
import type { SnapshotFrom } from "xstate"; import type { SnapshotFrom } from "xstate";
import { privateRoomMachine } from "./private-room-machine"; import { privateZoomMachine } from "./private-zoom-machine";
import type { import type {
PrivateRoomEvent, PrivateZoomEvent,
PrivateRoomState as MachineContext, PrivateZoomState as MachineContext,
} from "./private-room-machine"; } from "./private-zoom-machine";
/** Route UI reads this projection instead of the Private Room snapshot. */ /** Route UI reads this projection instead of the Private Zoom snapshot. */
export interface PrivateRoomContextState { export interface PrivateZoomContextState {
characterId: string; characterId: string;
status: string; status: string;
items: MachineContext["items"]; items: MachineContext["items"];
@@ -26,45 +26,45 @@ export interface PrivateRoomContextState {
isUnlocking: boolean; isUnlocking: boolean;
} }
type PrivateRoomSnapshot = SnapshotFrom<typeof privateRoomMachine>; type PrivateZoomSnapshot = SnapshotFrom<typeof privateZoomMachine>;
type PrivateRoomSelector<T> = (snapshot: PrivateRoomSnapshot) => T; type PrivateZoomSelector<T> = (snapshot: PrivateZoomSnapshot) => T;
const PrivateRoomActorContext = createActorContext(privateRoomMachine); const PrivateZoomActorContext = createActorContext(privateZoomMachine);
export interface PrivateRoomProviderProps { export interface PrivateZoomProviderProps {
children: ReactNode; children: ReactNode;
characterId: string; characterId: string;
} }
export function PrivateRoomProvider({ export function PrivateZoomProvider({
children, children,
characterId, characterId,
}: PrivateRoomProviderProps) { }: PrivateZoomProviderProps) {
return ( return (
<PrivateRoomActorContext.Provider options={{ input: { characterId } }}> <PrivateZoomActorContext.Provider options={{ input: { characterId } }}>
{children} {children}
</PrivateRoomActorContext.Provider> </PrivateZoomActorContext.Provider>
); );
} }
export function usePrivateRoomState(): PrivateRoomContextState { export function usePrivateZoomState(): PrivateZoomContextState {
return usePrivateRoomSelector(selectPrivateRoomState, shallowEqual); return usePrivateZoomSelector(selectPrivateZoomState, shallowEqual);
} }
export function usePrivateRoomDispatch(): Dispatch<PrivateRoomEvent> { export function usePrivateZoomDispatch(): Dispatch<PrivateZoomEvent> {
return PrivateRoomActorContext.useActorRef().send; return PrivateZoomActorContext.useActorRef().send;
} }
export function usePrivateRoomSelector<T>( export function usePrivateZoomSelector<T>(
selector: PrivateRoomSelector<T>, selector: PrivateZoomSelector<T>,
compare?: (previous: T, next: T) => boolean, compare?: (previous: T, next: T) => boolean,
): T { ): T {
return PrivateRoomActorContext.useSelector(selector, compare); return PrivateZoomActorContext.useSelector(selector, compare);
} }
function selectPrivateRoomState( function selectPrivateZoomState(
state: PrivateRoomSnapshot, state: PrivateZoomSnapshot,
): PrivateRoomContextState { ): PrivateZoomContextState {
return { return {
characterId: state.context.characterId, characterId: state.context.characterId,
status: String(state.value), status: String(state.value),
@@ -0,0 +1,8 @@
/** Public events for one character-scoped Private Zoom actor. */
export type PrivateZoomEvent =
| { type: "PrivateZoomInit" }
| { type: "PrivateZoomRefresh" }
| { type: "PrivateZoomUnlockRequested"; albumId: string }
| { type: "PrivateZoomUnlockConfirmed" }
| { type: "PrivateZoomUnlockCancelled" }
| { type: "PrivateZoomUnlockPaywallConsumed" };

Some files were not shown because too many files have changed in this diff Show More