Commits

Maxim Moiseev committed 9121fd2

messages related members refactoring

Comments (0)

Files changed (1)

src/Common/UserAPI.fs

         
     member this.StatusUpdates
         with get () =
-            query Action.UpdatesActivity |>
-                getAllItems Conversions.toStatus
+            query Action.UpdatesActivity
+            |> getAllItems Conversions.toStatus
                 
     member this.FriendsOfFriends
         with get () =
-            query Action.UpdatesFriends |>
-                getAllItems Conversions.toFriend
+            query Action.UpdatesFriends
+            |> getAllItems Conversions.toFriend
             
     member this.FriendsPhotos
         with get () =
-            query Action.UpdatesPhotos |>
-                getAllItems Conversions.toPhoto
+            query Action.UpdatesPhotos
+            |> getAllItems Conversions.toPhoto
             
     member this.FriendsTaggedPhotos
         with get () =
-            query Action.UpdatesTaggedPhotos |>
-                getAllItems Conversions.toPhoto
+            query Action.UpdatesTaggedPhotos
+            |> getAllItems Conversions.toPhoto
 
     member private this.GetProfileFrom(queryF) =
         queryF Action.Profile
         with get () = 
             this.GetProfileFrom query
             
+    member private this.GetMessagesFor(action) =
+        match action with
+        | Action.Inbox | Action.Outbox //| Action.Message
+            -> query action 
+               |> getAllItems Conversions.toMessage
+        | _ -> raise <| NotSupportedException()
+            
     member this.Inbox
-        with get () =
-            query Action.Inbox |>
-                getAllItems Conversions.toMessage
+        with get () = this.GetMessagesFor Action.Inbox
                 
     member this.Outbox 
-        with get () =
-            query Action.Outbox |>
-                getAllItems Conversions.toMessage
+        with get () = this.GetMessagesFor Action.Outbox