import { AmpStory } from '../../../types/ampStories'; import { BaseService } from '../../services/abstract/baseService'; import { Story } from '../../stories/models/story'; /** * Sometimes, the AMPHTML document can be out of sync with the Stories returned by the API. * Usually, the API is faster, so if we add a new Story or Page, it will be returned by the API * before it's visible in the AMPHTML document. This leads to a few issues: * - A Story isn't marked as read when the last page is opened since the real last page hasn't been viewed yet * - We get stories/pages by their indices and the indices can be off, leading to inaccurate event reporting * The solution is to get the player Stories and the appended pages from AMP and check them against the API stories. * */ declare class StoriesPlayerSyncService extends BaseService { protected logTag: string; private _apiStories; private _playerStories; _syncedStoriesIds: string[]; private onStoriesMismatch_; private _onStorySyncCheckComplete; stories: Story[] | null; constructor(onStoriesMismatch: () => void); set apiStories(stories: Story[] | null); set playerStories(playerStories: AmpStory[]); resetPlayerStories(): void; updatePlayerStory(updatedPlayerStory: AmpStory): void; ifStoryIsSynced(storyId: string, callback: () => void): void; /** * To run ONLY if the API and AMP story already matches. * If they don't, the row will re-render anyway. */ private whenStorySyncCheckComplete_; /** Gets the stories and pages that are both in the API response and the amp-story-player. */ private checkIfStoriesAreInSync_; } export default StoriesPlayerSyncService;