Skip to content

Commit

Permalink
Merge branch 'main' of github.com:xmtp/xmtp-dot-org into message-hist
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaaaa committed Jul 23, 2024
2 parents ed75bd1 + 379cd36 commit 1c17650
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 80 deletions.
6 changes: 4 additions & 2 deletions docs/build/group-chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,13 @@ stream.stop()
## Sync group chats
Calling `sync()` for a group or groups gets any updates since the last sync and adds them to the local database. Be sure to periodically synchronize each group chat to ensure your app has the latest group chat details, including the most recent messages, member list, and group chat details, for example.
Calling `sync()` for a group or groups gets any updates since the last sync and adds them to the local database.
Sync group chats anytime a user accesses a conversation view. This sync is especially important if a user backgrounds (switches away from) your app, then reopens the app and accesses a conversation view. When the user reopens the app, it may be using an old epoch (snapshot) of data. This is even more likely to be true if there were many group membership changes during the time the app was backgrounded. A group chat sync bumps the app to the latest epoch, helping to ensure that your user always sees the current group chat, including the most recent messages, member list, and group chat details, for example.
Updates are also retrieved and added to the local database when streaming and when the user takes an action.
When your user sends a message, you don’t need to sync with the network for them to see their own message. The message gets written to their local database, and it shows up immediately for them. The same applies when your user creates a group.
When your user sends a message, you don’t need to sync with the network for them to see their own message. The message gets written to their local database, and it shows up immediately for them. The same applies when your user creates a group.
See [⚠️ Important: Manage actions that make a local database inaccessible](#️-important-manage-actions-that-make-a-local-database-inaccessible).
Expand Down
4 changes: 0 additions & 4 deletions docs/build/message-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ const client = await Client.create('0x1234...', {

## Request message history sync

Code your app to request a message history sync anytime a user accesses a conversation view.

This sync is especially important if a user backgrounds (switches away from) your app, then reopens the app and accesses a conversation view. When the user reopens the app, it may be using an old epoch (snapshot) of data. This is even more likely to be true if there were many group membership changes during the time the app was backgrounded. A message history sync bumps the app to the latest epoch, helping to ensure that your user always sees the current group chat.

When a new client is created, it will look for other clients registered with the same inbox ID. If there are none, there is no message history to be synced. If there are clients registered with the same inbox ID, it will request a message history sync with the clients.

For example, let’s say that inbox ID 1/client B requests a message history sync with inbox ID 1/client A.
Expand Down
74 changes: 0 additions & 74 deletions docs/build/messages/read-receipt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,6 @@ const xmtp = await Client.create(signer, { env: "dev" });
xmtp.registerCodec(new ReadReceiptCodec());
```

</TabItem>
<TabItem value="react" label="React" attributes={{className: "react_tab"}}>

The React SDK supports all current standards-track content types, but only text messages are enabled out of the box. Adding support for other standards-track content types requires a bit of configuration.

```jsx
import {
XMTPProvider,
readReceiptContentTypeConfig,
} from "@xmtp/react-sdk";

const contentTypeConfigs = [
readReceiptContentTypeConfig,
// other content type configs...
];

createRoot(document.getElementById("root") as HTMLElement).render(
<StrictMode>
<XMTPProvider contentTypeConfigs={contentTypeConfigs}>
<App />
</XMTPProvider>
</StrictMode>,
);
```

</TabItem>
<TabItem value="kotlin" label="Kotlin" attributes={{className: "kotlin_tab"}}>

Expand Down Expand Up @@ -132,20 +107,6 @@ The content of a read receipt message must be an empty object.
await conversation.messages.send({}, ContentTypeReadReceipt);
```

</TabItem>
<TabItem value="react" label="React" attributes={{className: "react_tab"}}>

The content of a read receipt message must be an empty object.

```jsx
import { useSendMessage } from "@xmtp/react-sdk";
import { ContentTypeReadReceipt } from "@xmtp/content-type-read-receipt";

const { sendMessage } = useSendMessage();

sendMessage(conversation, {}, ContentTypeReadReceipt);
```

</TabItem>
<TabItem value="kotlin" label="Kotlin" attributes={{className: "kotlin_tab"}}>

Expand Down Expand Up @@ -214,41 +175,6 @@ if (message.contentType.sameAs(ContentTypeReadReceipt)) {
}
```

</TabItem>
<TabItem value="react" label="React" attributes={{className: "react_tab"}}>

```jsx
import { ContentTypeId } from "@xmtp/react-sdk";
import { ContentTypeReadReceipt } from "@xmtp/content-type-read-receipt";

const contentType = ContentTypeId.fromString(message.contentType);

if (ContentTypeReadReceipt.sameAs(contentType)) {
// The message is a read receipt
const timestamp = message.sentAt;
}
```

**getReadReceipt**

Use to retrieve the read receipt from a cached conversation. It takes a `CachedConversation` object as a parameter and returns the read receipt date, or `undefined`, if the conversation has no read receipt.

```jsx
import { getReadReceipt } from "@xmtp/react-sdk";

const readReceiptDate = getReadReceipt(conversation);
```

**hasReadReceipt**

Use to check if a cached conversation has a read receipt. It takes a `CachedConversation` object as a parameter and returns `true` if the conversation has a read receipt and `false` if otherwise.

```jsx
import { hasReadReceipt } from "@xmtp/react-sdk";

const hasReceipt = hasReadReceipt(conversation);
```

</TabItem>
<TabItem value="kotlin" label="Kotlin" attributes={{className: "kotlin_tab"}}>

Expand Down

0 comments on commit 1c17650

Please sign in to comment.