Appearance
"New message": the recipient picker
Reached from the inbox.
Every example starts from saved, the checkpoint the index describes; the launch hands the feed, and a tab edge lands on the tab's root.
Start a one-to-one conversation
The picker's search is one keystroke's request; its answer is { recipients, threads }, the fresh people and, when the search shows threads, the conversations that match, each row with its own openThread() (a conversation row opens the conversation itself, a person row the conversation with that person). The server names the conversation a picked person opens: an answer with none is the typed DirectThreadNotFoundByParticipantsError.
"New message": the recipient picker, opened by openNewMessage().
Suggested recipients before typing.
The picker's results: the rows search(query) answers.
A recipient picked: openThread() opens the conversation.
ts
// Start a one-to-one conversation: "New message", search for the person, open the thread and write.
const started = await AndroidIgpapi.launch({
checkpoint: saved,
screen: FeedTimelineScreen,
main: feed =>
Effect.gen(function* () {
const tab = yield* feed.openDirectTab();
const picker = yield* tab.openNewMessage();
// One keystroke, one request; the answer's people are the fresh recipients to continue from.
const { recipients } = yield* picker.search('instagram');
const recipient = recipients[0];
if (recipient === undefined) return undefined;
const thread = yield* recipient.openThread();
return yield* thread.sendMessage('Hi!');
}),
});
console.log(started);Create a group chat
The "Group chat" row re-enters the same picker in group mode. createGroup takes the picked rows in pick order and opens the conversation it creates: it is the one way to open a new group's conversation from the picker.
The group picker: startGroupChat().
ts
// Create a group chat: "New message", the "Group chat" row, pick people, create the group and write.
const group = await AndroidIgpapi.launch({
checkpoint: saved,
screen: FeedTimelineScreen,
main: feed =>
Effect.gen(function* () {
const tab = yield* feed.openDirectTab();
const picker = yield* tab.openNewMessage();
// The same picker, re-entered in group mode.
const groupPicker = yield* picker.startGroupChat();
const { recipients } = yield* groupPicker.search('instagram');
const thread = yield* groupPicker.createGroup(recipients.slice(0, 2).map(recipient => recipient.data));
return yield* thread.sendMessage('Welcome to the group');
}),
});
console.log(group);
The created group's conversation.
The group with its first message.