(
dispatchAction:
| ReturnType<typeof threadAdapterEvents.renameRequested>
| ReturnType<typeof threadAdapterEvents.archiveRequested>
| ReturnType<typeof threadAdapterEvents.unarchiveRequested>
| ReturnType<typeof threadAdapterEvents.deleteRequested>,
)
| 1249 | }); |
| 1250 | |
| 1251 | function trackMutation( |
| 1252 | dispatchAction: |
| 1253 | | ReturnType<typeof threadAdapterEvents.renameRequested> |
| 1254 | | ReturnType<typeof threadAdapterEvents.archiveRequested> |
| 1255 | | ReturnType<typeof threadAdapterEvents.unarchiveRequested> |
| 1256 | | ReturnType<typeof threadAdapterEvents.deleteRequested>, |
| 1257 | ): Promise<void> { |
| 1258 | const completion$ = merge( |
| 1259 | store.actions$.pipe( |
| 1260 | ofType(threadRestEvents.mutationFinished), |
| 1261 | filter( |
| 1262 | (action) => action.outcome.requestId === dispatchAction.requestId, |
| 1263 | ), |
| 1264 | map((action) => action.outcome), |
| 1265 | ), |
| 1266 | store.actions$.pipe( |
| 1267 | ofType(threadAdapterEvents.stopped), |
| 1268 | map( |
| 1269 | () => |
| 1270 | ({ |
| 1271 | requestId: dispatchAction.requestId, |
| 1272 | sessionId: store.getState().sessionId, |
| 1273 | ok: false, |
| 1274 | error: new Error( |
| 1275 | "Thread store stopped before mutation completed", |
| 1276 | ), |
| 1277 | }) satisfies MutationOutcome, |
| 1278 | ), |
| 1279 | ), |
| 1280 | ).pipe(take(1)); |
| 1281 | |
| 1282 | const resultPromise = firstValueFrom(completion$).then((outcome) => { |
| 1283 | if (outcome.ok) { |
| 1284 | return; |
| 1285 | } |
| 1286 | |
| 1287 | throw outcome.error; |
| 1288 | }); |
| 1289 | |
| 1290 | store.dispatch(dispatchAction); |
| 1291 | return resultPromise; |
| 1292 | } |
| 1293 | |
| 1294 | // Surface mutation rejections to the optional environment callback. The |
| 1295 | // reducer has already applied any delete rollback by the time this fires |
no test coverage detected
searching dependent graphs…