Overview
Threadly uses two models to represent stories:StoriesModel: Represents a user’s story collectionStoryMediaModel: Represents individual story media items
StoriesModel
Represents a user’s story collection that appears in the stories tray.Fields
ID of the user who posted the story
URL to the user’s profile picture (displayed in the story ring)
Whether the current user has seen this user’s stories
Example
StoryMediaModel
Represents an individual story media item (image or video) within a user’s story collection.Fields
ID of the user who posted this story
Unique identifier for this story media item
URL to the story media content (image or video)
Whether the story is a video (
true) or image (false)Timestamp when the story was created
Whether the current user has liked this story
Methods
getUserId(): Get the user IDgetStoryId(): Get the story IDgetStoryUrl(): Get the media URLisVideo(): Check if story is a videogetCreatedAt(): Get creation timestampisLiked(): Check if user liked the storysetLiked(boolean): Update the liked status
Constructor
TheStoryMediaModel constructor accepts:
type should be either "video" or "image" and is automatically converted to the boolean isVideo field.
Example
Usage Pattern
These models are typically used together:- Stories Tray: Display a list of
StoriesModelobjects showing which users have active stories - Story Viewer: When a user taps on a story, fetch the associated
StoryMediaModelitems for that user - Story Ring: Use
isSeenfromStoriesModelto determine the visual state of the story ring (seen vs unseen)
Usage Notes
- Stories are typically ephemeral content that expires after 24 hours
- The
isSeenfield inStoriesModelhelps distinguish between viewed and new stories in the UI - The
isLikedfield inStoryMediaModelis derived from an integer value during construction (>0 = true) - The
isVideofield is determined by checking if the type string equals “video” - All other type strings default to
isVideo = false(treated as images)