We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 41b5042 commit b8c3e00Copy full SHA for b8c3e00
app/assets/javascripts/backbone/data/attachments.js.coffee
@@ -1,2 +1,23 @@
1
class Kandan.Data.Attachments
2
- # TODO use this for the file list plugin
+ @callbacks: { "change": [] }
3
+ @cache: []
4
+
5
6
+ @all: (callback)->
7
+ attachments = new Kandan.Collections.Attachments([], {
8
+ channel_id: Kandan.Data.Channels.activeChannelId()
9
+ })
10
+ attachments.fetch({ success: callback })
11
12
+ @registerCallback: (event, callback)->
13
+ @callbacks[event].push(callback)
14
15
+ @runCallbacks: (event, data)->
16
+ @cache = data.extra.attachments
17
+ callback(data) for callback in @callbacks[event]
18
19
20
+ @unregisterCallback: (event, callback)->
21
+ delete @callbacks[@callbacks.indexOf(callback)]
22
+ @callbacks.filter (element, index, array)->
23
+ element!=undefined
0 commit comments