Skip to content

Commit 3f89b7a

Browse files
committed
Towards automarking behavior
1 parent 774b90f commit 3f89b7a

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

bin/slack

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if not token
99
process.exit 1
1010
else
1111
shutdown = false
12-
slack = new Slack token, true
12+
slack = new Slack token, true, true
1313
rl = Readline.createInterface(process.stdin, process.stdout)
1414

1515
slack.on 'error', (error) ->

src/channel.coffee

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Channel
88
for k of (data or {})
99
@[k] = data[k]
1010

11+
# TODO: Emit event for unread history
12+
1113
addMessage: (message) ->
1214
switch message.subtype
1315
when undefined, "channel_archive", "channel_unarchive", "group_archive", "group_unarchive"
@@ -59,6 +61,9 @@ class Channel
5961
if message.ts and @latest? and @latest.ts? and message.ts > @latest.ts
6062
@latest = message
6163

64+
# TODO: Update @unread_count
65+
if @_client.autoMark then @mark message.ts
66+
6267
getHistory: ->
6368
@_history
6469

@@ -113,6 +118,7 @@ class Channel
113118

114119
_onMark: (data) =>
115120
console.log data
121+
# TODO: Update @unread_count based on ts
116122

117123
leave: ->
118124
if @constructor.name == 'DM' then return null

src/client.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Client extends EventEmitter
1515

1616
host: 'api.slack.com'
1717

18-
constructor: (@token, @autoReconnect=true) ->
18+
constructor: (@token, @autoReconnect=true, @autoMark=false) ->
1919
@authenticated = false
2020
@connected = false
2121

@@ -342,7 +342,7 @@ class Client extends EventEmitter
342342
if channel
343343
channel.addMessage m
344344

345-
when "channel_marked", "im_marked"
345+
when "channel_marked", "im_marked", "group_marked"
346346
channel = @getChannelGroupOrDMByID message.channel
347347
if channel
348348
@emit 'channelMarked', channel, message.ts

src/dm.coffee

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class DM extends Channel
1010
u = @_client.getUserByID @user
1111
if u
1212
@name = u.name
13+
14+
# TODO: Emit event for unread history
1315

1416
close: ->
1517
params = {

0 commit comments

Comments
 (0)