Observe location summary information

Build activity indicators and badges with information about a location and its threads


Overview

This method allows you to observe summary information about a location, including live updates.
import { thread } from '@cord-sdk/react';
const summary = thread.useLocationSummary(location, options);
Copy

Usage

import { thread } from '@cord-sdk/react';
const summary = thread.useLocationSummary({page: 'document_details'}, {partialMatch: true});
return (
  <div>
    {!summary && "Loading..."}
    {summary && (
      <p>Total threads: {summary.total}</p>
      <p>Unread threads: {summary.unread}</p>
      <p>Unread subscribed threads: {summary.unreadSubscribed}</p>
      <p>Resolved threads: {summary.resolved}</p>
    )}
  </div>
);
Copy

Available Data

Graphic showing example uses of the Cord Location Summary API

The API provides an object which has the following fields:


resolved

required
number
The number of resolved threads. This refers to threads that users have manually marked as resolved within Cord's UI components.

total

required
number
The total number of threads at the location, both resolved and unresolved.

unread

required
number
The total number of threads that have messages the current user hasn't seen yet.
This will count all threads with unread messages at the location, whether the current user is subscribed to the thread or not.

unreadSubscribed

required
number
The number of threads that have messages the current user hasn't seen yet and is subscribed to.
A user is automatically subscribed to threads relevant to them, for example because they have sent a message or have been @-mentioned in them. unreadSubscribed is always less than or equal to unread.

What this function returns

The hook will initially return undefined while the data loads from our API. Once it has loaded, your component will re-render and the hook will return an object containing the fields described under "Available Data" above. The component will automatically re-render if any of the data changes, i.e., this data is always "live".

Arguments this function takes


location

required
Location
The location to fetch summary information for.

options

optional
ObserveThreadActivitySummaryOptions
Miscellaneous options. See below.

The "options" argument


partialMatch

optional
boolean
If true, perform partial matching on the specified location. If false, fetch information for only exactly the location specified.
If unset, defaults to false.