Appearance
A photo from the gallery
A photo sent from a conversation's gallery picker: the conversation's openMediaPicker() opens the picker (DirectMediaPickerPhotosScreen), and the picked photo's own sendPhoto({ file }) uploads it through PhotoAttachmentMessage and broadcasts photo_attachment.
The composer with the photo button tapped, before the gallery picker opens.
The picker: thread.openMediaPicker().
The photo message in the conversation, as the app shows it after sendPhoto({ file }).
ts
import { AndroidIgpapi, DirectMediaPickerPhotosScreen, FeedTimelineScreen } from '@igpapi/android';
import { Effect } from 'effect';
import { readFile } from 'node:fs/promises';
// A checkpoint read back from your storage (see "Keep a session").
const saved = JSON.parse(await readFile('session.json', 'utf8'));
// Send a photo: the composer's "+" opens the gallery picker, and the picked photo is sent.
const picture = await readFile('photo.jpg');
const sent = await AndroidIgpapi.launch({
checkpoint: saved,
screen: FeedTimelineScreen,
main: feed =>
Effect.gen(function* () {
const tab = yield* feed.openDirectTab();
const item = tab.threads[0];
if (item === undefined) return undefined;
const thread = yield* item.open();
const picker = yield* thread.openMediaPicker();
if (!DirectMediaPickerPhotosScreen.is(picker)) return undefined;
return yield* picker.sendPhoto({ file: picture });
}),
});
console.log(sent);The legacy facade's photoAttachment sends the same form as the picker's sendPhoto: the fields are the app's photo attachment's, and no recording shows the facade's own chain, so a difference between the two entry points is unmeasured.