@fabriktor/fx 0.0.161 → 0.0.162

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,6 +84,7 @@ export type StartFeedSessionOptions = FeedPullContext & {
84
84
  export type AddFeedReactionOptions = {
85
85
  post: FeedPost;
86
86
  reaction_type: FeedReactionType;
87
+ replace_existing?: boolean;
87
88
  };
88
89
  export type RemoveFeedReactionOptions = {
89
90
  post: FeedPost;
@@ -372,7 +372,8 @@ export class FeedFX {
372
372
  const post_id = feedPostID(opts.post);
373
373
  return await this.runAction(post_id, FeedAction.Reaction, async (signal) => {
374
374
  const fresh = await this.requireFeedPost(post_id, signal);
375
- if (resolvedID(fresh.self.reaction_id))
375
+ const id = resolvedID(fresh.self.reaction_id);
376
+ if (id && !opts.replace_existing)
376
377
  throw errValidation({
377
378
  msg: "An action already exists for this post.",
378
379
  });
@@ -381,6 +382,11 @@ export class FeedFX {
381
382
  field: "reaction_type",
382
383
  msg: "Unsupported reaction.",
383
384
  });
385
+ if (id) {
386
+ await this.feed.deleteOneFeedReaction({ signal, id });
387
+ signal.throwIfAborted();
388
+ this.markActionRemoved(post_id, FeedAction.Reaction);
389
+ }
384
390
  const out = await this.feed.insertOneFeedReaction({
385
391
  signal,
386
392
  in: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.161",
3
+ "version": "0.0.162",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@fabriktor/client": "0.0.101",
21
21
  "@fabriktor/fx": "0.0.94",
22
- "@fabriktor/schema": "0.0.72",
22
+ "@fabriktor/schema": "0.0.73",
23
23
  "convert": "8.0.2"
24
24
  }
25
25
  }