innoq/spacy

Swap Session

Opened this issue · 1 comments

My idea for swap session is as follows:

When the user clicks on a link to move-session (see #28 and the description of the UI there), there would also be actions in the filled slots which would tell the user that they can "Request swap".

Then the behavior in the app when the session request is executed:

  1. if the user has swapped with their own session, the swap is executed immediately
  2. otherwise, we need to generate some kind of ::swap-requests [{ :session1 <id1> :session2 <id2> }] entry in our domain object so that in the UI we can generate a Notification for the other user and they can click on a "Confirm Swap" button

Obviously there are a lot of holes which would need to be filled out.

I've been thinking about the domain model for this, and I think we need to have a function swap-session

(defn swap-session [event current-user { :session-id <session1-id> :with <session2-id> }]  ;; format of params tbd
  ...
  {::facts [{::fact :session-swapped ...}]
   ::event (-> event
               (swap-room-and-time-of-sessions session1 session2))})```

And then also a domain object with something like 

```clojure
::requests { "user" [{ ::command ::swap-session ::params { :session-id <session-id> :with <session2-id> }}]}

Then the ::requests object here would be map of user to a generic data structure representing our commands, and we could extend it in the future to any new commands that are added to the application which user confirmation before they are executed.