removed whileUnchanged for devices
[mTask.git] / Shares / mTaskShare.icl
index 43350e1..fda2a39 100644 (file)
@@ -13,10 +13,10 @@ from StdFunc import flip
 derive class iTask MTaskShare
 
 manageShares :: Task [MTaskDevice]
-manageShares = whileUnchanged deviceStoreNP
-       $ \devs->case devs of
-               [] = viewInformation "No devices yet" [] []
-               _ = allTasks (map manageSharesOnDevice devs)
+manageShares = viewInformation "" [] []//whileUnchanged deviceStoreNP
+//     $ \devs->case devs of
+//             [] = viewInformation "No devices yet" [] []
+//             _ = allTasks (map manageSharesOnDevice devs)
 
 manageSharesOnDevice :: MTaskDevice -> Task MTaskDevice
 manageSharesOnDevice dev = (case dev.deviceShares of
@@ -97,6 +97,28 @@ getRealShare dev share = sdsFocus ()
        $ sdsFocus (Just (dev, share.identifier))
        $ deviceStore
 
+//getRealShare :: MTaskDevice MTaskShare -> Shared BCValue
+//getRealShare dev share = sdsLens
+//     ("realShare" +++ toString share.identifier)
+//     (const $ Just (dev, share.identifier))
+//     (SDSRead $ const $ \rs->case find ((==)dev) rs of
+//             Nothing = Error $ exception "Device doesn't exist anymore"
+//             Just {deviceShares} = case find ((==)share) deviceShares of
+//                     Nothing = Error $ exception "Share doesn't exist anymore"
+//                     Just share = Ok share.MTaskShare.value
+//     )
+//     (SDSWrite $ const $ \rs w->partition ((==)dev) devs of
+//             ([], _) = Error $ exception "Device doesn't exist anymore"
+//             ([_,_:_], _) = Error $ exception "Multiple matching devices"
+//             ([d=:{deviceShares}], devs) = case partition ((==)share) deviceShares of
+//                     ([], _) = Error $ exception "Share doesn't exist anymore"
+//                     ([_,_:_], _) = Error $ exception "Multiple matching shares"
+//                     ([s], shares)
+//                             # s = {MTaskShare | s & value=val}
+//                             # d = {MTaskDevice | d & deviceShares=[s:shares]}
+//                             = Ok $ Just [d:devs])
+//     (SDSNotify $ const $ \rs w
+
 deviceLens dev share = (mread, mwrite)
 where
        mread :: [MTaskDevice] -> MaybeError TaskException BCValue