birdwingo / react-native-instagram-stories

🚀 Instagram stories is a versatile React Native component designed to display a horizontal scrollable list of user stories, similar to the stories feature found in the Instagram app.
https://birdwingo.com
MIT License
121 stars 34 forks source link

Add Support for Tracking and Prioritizing Unseen Stories #101

Open Adil7767 opened 1 month ago

Adil7767 commented 1 month ago

Title: Add Support for Tracking and Prioritizing Unseen Stories Across Devices

Issue Text:

Enhance the story playback functionality to prioritize unseen stories and maintain a persistent record of seen stories across devices.

Current Behavior:

Expected Behavior:

Steps to Reproduce:

  1. Add 4 stories and view all of them.
  2. Add a new story and observe that playback starts from the first story instead of the unseen one.
  3. Save the status of seen stories on one device and log in on another device to see that the status is not retained.

Possible Solution:

  1. Introduce a mechanism to pass a list of stories with a key is_seen indicating whether the story has been seen.
  2. Modify the playback logic to prioritize unseen stories.
  3. Ensure that the status of seen stories can be fetched from and saved to the server, allowing for a consistent experience across devices.

Data Structure Example:

const stories = [{
  id: 'user1',
  name: 'User 1',
  imgUrl: 'user1-profile-image-url',
  stories: [
    { id: 'story1', is_seen: true, source: { uri: 'story1-image-url' } },
    { id: 'story2', is_seen: false, source: { uri: 'story2-video-url' }, mediaType: 'video' },
    // ...
  ]
}, 
// ...
];

Alternative Approach:

Pass a separate array for seen stories:

const seenStories = [{
  id: 'user1',
  name: 'User 1',
  imgUrl: 'user1-profile-image-url',
  stories: [
    { id: 'story1', is_seen: true, source: { uri: 'story1-image-url' } },
    { id: 'story2', is_seen: false, source: { uri: 'story2-video-url' }, mediaType: 'video' },
    // ...
  ]
},
// ...
];

<InstagramStories
  ref={instagramStoriesRef}
  isVisible={isVisible}
  stories={stories}
  saveProgress={true}
  seenStories={seenStories}
/>

Additional Note:

The saveProgress prop is suitable for device-oriented usage but not for multiple users.

Adil7767 commented 1 month ago

@LukasFridmansky