Appearance
Carousel posts
A carousel at slide 1 of 6: swipeToSlide(index) moves to another.
A carousel is one post with several slides. The person swipes to a slide, likes it or opens its comments, and the comments sheet names the slide they are on. You say which slide with swipeToSlide(index); the Simulator works out the rest. This page owns the rules of slides, and the pages for the home feed and for likes, reposts and comments link here.
The slide is a fact of the person's view of the open post, on the screen showing it: swipeToSlide answers the post shown again with that slide in front, and you continue from that answer. It lives while that screen is open (a profile's posts feed, a feed post opened full screen, the home feed) and dies with it. A post opened again, or on another surface, starts at its first slide: the Simulator does not keep a swiped slide across visits.
Every example starts from session.json, the session Your first program saved, and reaches the post through the search (Profiles).
The matrix
| The person... | Starts on | Actions | Result |
|---|---|---|---|
| Swipes a carousel post to a slide and comments on it | the profile's posts feed, a post, the feed | the post's swipeToSlide(index), openComments({}) | The comments sheet opened on that slide, the first when they never swiped |
What is yours and what is the Simulator's
- The slide is yours.
swipeToSlide(index)is the person's swipe: zero-based, in the post's slides. Nothing goes out when it is taken, because the app sends no request for a swipe. The sheet opens on that slide, andopenCommentstakes no slide. - A slide the post does not hold fails
swipeToSlidewith the typedCarouselSlideNotFoundError(the post, the index you named and how many slides the answer carries), before anything changes. A slide the Simulator cannot name, for example in a post whose slides are not loaded, fails with the typedCarouselSlidesNotLoadedError: the slide may exist, so open the post again to load its slides. - Where a swipe exists. A carousel of the profile's posts feed has
swipeToSlide; every post of the home feed has it, and a post that is no carousel answersCarouselSlideNotFoundError; the post screen has it for every media the same way.
The scenario
Swipe a carousel post to a slide and open its comments
Starts on: the profile's posts feed, opened from a grid tile.
ts
import {
AndroidIgpapi,
FeedTimelineScreen,
isSearchInputUserResult,
ProfilePostsFeedCarouselItem,
} from '@igpapi/android';
import { Effect } from 'effect';
import { readFile } from 'node:fs/promises';
const saved = JSON.parse(await readFile('session.json', 'utf8'));
await AndroidIgpapi.launch({
checkpoint: saved,
screen: FeedTimelineScreen,
main: feed =>
Effect.gen(function* () {
const explore = yield* feed.openSearchTab();
const field = yield* explore.openSearchInput();
const typed = yield* field.change('instagram');
const user = typed.results.find(result => isSearchInputUserResult(result));
if (user === undefined) return;
const profile = yield* user.openProfile();
const tile = profile.grid[0];
if (tile === undefined) return;
const postsFeed = yield* tile.open();
const post = postsFeed.items.find(item => ProfilePostsFeedCarouselItem.is(item));
if (post === undefined) return;
// The person's swipe: nothing is sent, and the answer is the post with that slide in front.
const swiped = yield* post.swipeToSlide(1);
// The sheet opens on that slide; its opening page names the slide's id and place.
const comments = yield* swiped.openComments({});
yield* comments.comment('Nice second slide');
yield* comments.back();
}),
});
Your own carousel opened from your profile has the same swipe.