Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fallback types to content types #147

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DecodedMessageWrapper {
"content" to ContentJson(model.encodedContent).toJsonMap(),
"senderAddress" to model.senderAddress,
"sent" to model.sent.time,
"fallback" to model.fallbackContent
)
}
}
8 changes: 8 additions & 0 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ test("can list batch messages", async () => {
throw Error("Unexpected message content " + messages[0].content);
}

if (messages[0].fallback !== 'Reacted “💖” to an earlier message') {
throw Error("Unexpected message fallback " + messages[0].fallback);
}

return true;
});

Expand Down Expand Up @@ -488,6 +492,10 @@ test("can send read receipts", async () => {
throw Error("Unexpected message content " + bobMessages[0].content);
}

if (bobMessages[0].fallback) {
throw Error("Unexpected message fallback " + bobMessages[0].fallback);
}

return true;
});

Expand Down
1 change: 1 addition & 0 deletions ios/Wrappers/DecodedMessageWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct DecodedMessageWrapper {
"content": ContentJson.fromEncoded(model.encodedContent, client: model.client).toJsonMap() as Any,
"senderAddress": model.senderAddress,
"sent": UInt64(model.sent.timeIntervalSince1970 * 1000),
"fallback": model.fallbackContent
]
}

Expand Down
1 change: 1 addition & 0 deletions src/XMTP.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export type DecodedMessage = {
content: MessageContent;
senderAddress: string;
sent: number; // timestamp in milliseconds
fallback: string | undefined;
};

export type ConversationContext = {
Expand Down
Loading