Class: Slk::Services::UnreadMarker

Inherits:
Object
  • Object
show all
Defined in:
lib/slk/services/unread_marker.rb

Overview

Handles batch marking of unreads as read

Instance Method Summary collapse

Constructor Details

#initialize(conversations_api:, threads_api:, client_api:, users_api:, on_debug: nil) ⇒ UnreadMarker

Returns a new instance of UnreadMarker.



7
8
9
10
11
12
13
# File 'lib/slk/services/unread_marker.rb', line 7

def initialize(conversations_api:, threads_api:, client_api:, users_api:, on_debug: nil)
  @conversations = conversations_api
  @threads = threads_api
  @client = client_api
  @users = users_api
  @on_debug = on_debug
end

Instance Method Details

#mark_all(options: {}) ⇒ Hash

Mark all unreads in a workspace, return counts

Parameters:

  • options (Hash) (defaults to: {})

    :muted - include muted channels

Returns:

  • (Hash)

    { dms: count, channels: count, threads: count }



18
19
20
21
22
23
24
25
26
# File 'lib/slk/services/unread_marker.rb', line 18

def mark_all(options: {})
  counts = @client.counts

  {
    dms: mark_dms(counts['ims'] || []),
    channels: mark_channels(counts['channels'] || [], muted: options[:muted]),
    threads: mark_threads
  }
end

#mark_single_channel(channel_id) ⇒ Boolean

Mark a single channel as read

Parameters:

  • channel_id (String)

    Channel ID

Returns:

  • (Boolean)

    true if marked successfully



31
32
33
# File 'lib/slk/services/unread_marker.rb', line 31

def mark_single_channel(channel_id)
  mark_conversation(channel_id)
end