forked from youiest/youiest-unionize
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.coffee
71 lines (53 loc) · 1.61 KB
/
client.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#client.coffee has code for creating connections
smite eval s
ConsoleMe.subscribe()
formatUpdate = (args) ->
up =
from: args.from # must have this, be somewhere
to: args.to or false
return up
@connect = (args) ->
smite eval(s), 'hi from connect', args, WI.findOne {_id:'wiber'}
eval smiter
smite 'smiter!', eval s
if !args.from
smite 'not from anywhere! run!', eval s
unless WI.findOne {_id:'wiber'} or !WI.findOne {_id: Meteor.userId}
smite 'we have no target! connect in what outbox?', eval s
ups = formatUpdate args
wi = WI.update
_id: user
,
'$push':
'outbox': ups
smite 'we have an outbox', WI.findOne({ _id: user }), eval s
return wi
# setTimeout(()->
Unionize.connect = connect
WIAfterUpdate = WI.after.update (userId, doc, fieldNames, modifier, options) ->
# WI.update
# "_id": doc._id
# ,
# $push:
# "journey":
# 'clientInbox': new Date().getTime()
# ,500)
# smite(,
# "rendering feedItems",
# eval s)
@feedItems = React.createClass
"getInitialState": ()->
{feeds: WI.findOne
"_id": user}
"componentDidMount": ()->
self = @
Tracker.autorun ()->
feed = WI.findOne({"_id": user})
self.setState({"feeds": feed})
"render": ()->
feedsList = []
if(this.state.feeds and this.state.feeds.sending)
sending = this.state.feeds.sending
feedsList = sending.map (feed)->
React.DOM.div(null,{},feed.from + feed.to)
return React.DOM.div(null,feedsList)