Last active
September 20, 2022 11:25
-
-
Save BalogunofAfrica/63b8f18e0de169c81b0a2093488a0fc0 to your computer and use it in GitHub Desktop.
Initializing the stream client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { STREAM_API_KEY, STREAM_APP_ID } from "@env"; | |
import { connect, UR } from "getstream"; | |
export type User1Type = { name: string; username: string; image?: string }; | |
export type User2Type = { name: string; avatar?: string }; | |
export type Verbs = "follow" | "save" | "like" | "post" | "publish"; | |
export type ActivityDetail = { | |
actor: { | |
created_at: Date; | |
data: { | |
name: string; | |
type: "User" | "Collection" | "Tag"; | |
}; | |
id: string; | |
updated_at: Date; | |
}; | |
backdrop?: string; | |
foreign_id: string; | |
id: string; | |
object: string; | |
objectType: string; | |
origin: string; | |
target: string; | |
time: Date; | |
verb: Verbs; | |
}; | |
export type ActorType = { | |
created_at?: Date; | |
updated_at?: Date; | |
id: string; | |
data: { | |
imageSource?: "cloudinary"; | |
imageSourceId: string; | |
name: string; | |
type?: "User" | "Collection" | "Tag"; | |
}; | |
}; | |
export type GenericActivityDetailType = { | |
foreign_id: string; | |
id: string; | |
object: string; | |
objectType: string; | |
origin: string; | |
target: string; | |
time: Date; | |
}; | |
export type GenericBackdrop = { | |
backdropBookingAvailable: boolean; | |
backdropCity: { | |
country: { | |
id: string; | |
name: string; | |
}; | |
id: string; | |
name: string; | |
}; | |
backdropCurrentUserLike: boolean; | |
backdropCurrentUserSave: boolean; | |
backdropImages: { | |
source?: "cloudinary"; | |
sourceId: string; | |
}[]; | |
backdropLikeCount: number; | |
backdropName: string; | |
backdropTags: { | |
id: string; | |
name: string; | |
}[]; | |
}; | |
export type GenericCollection = { | |
followed: unknown; | |
collectionBelongsToCurrentUser: boolean; | |
collectionDescription: string; | |
collectionFollowed: boolean; | |
collectionFollowercount: number; | |
collectionImage: { | |
source?: "cloudinary"; | |
sourceId: string; | |
}; | |
collectionName: string; | |
collectionOwnerId: string; | |
collectionOwnerUsername: string; | |
}; | |
export type GenericActivityType = { | |
activity_count: number; | |
actor_count: number; | |
created_at: Date; | |
group: string; | |
id: string; | |
updated_at: Date; | |
}; | |
export type LikeActivtyDetail = GenericActivityDetailType & | |
GenericBackdrop & { | |
actor: ActorType; | |
verb: "like"; | |
}; | |
export type PostActivityDetail = GenericActivityDetailType & | |
GenericBackdrop & { | |
actor: ActorType; | |
verb: "post"; | |
}; | |
export type PublishActivityDetail = GenericActivityDetailType & | |
GenericCollection & { | |
actor: ActorType; | |
verb: "publish"; | |
}; | |
export type SaveActivityDetail = GenericActivityDetailType & | |
GenericCollection & | |
GenericBackdrop & { | |
actor: ActorType; | |
backdrop: string; | |
verb: "save"; | |
}; | |
export type FollowActivityDetail = GenericActivityDetailType & | |
GenericCollection & { | |
actor: ActorType; | |
verb: "follow"; | |
}; | |
export type LegacyActivtyType = GenericActivityType & { | |
activities: ActivityDetail[]; | |
verb: Verbs; | |
}; | |
export type ActivityType = | |
| (GenericActivityType & { | |
activities: LikeActivtyDetail[]; | |
verb: "like"; | |
}) | |
| (GenericActivityType & { | |
activities: PostActivityDetail[]; | |
verb: "post"; | |
}) | |
| (GenericActivityType & { | |
activities: PublishActivityDetail[]; | |
verb: "publish"; | |
}) | |
| (GenericActivityType & { | |
activities: SaveActivityDetail[]; | |
verb: "save"; | |
}) | |
| (GenericActivityType & { | |
activities: FollowActivityDetail[]; | |
verb: "follow"; | |
}) | |
| LegacyActivtyType; | |
export type Collection1Type = { cid: string; rating?: number }; | |
export type Collection2Type = { branch: number; location: string }; | |
export type ReactionType = { text: string }; | |
export type ChildReactionType = { text?: string }; | |
export type StreamType = { | |
userType: User1Type | User2Type; | |
activityType: ActivityType; | |
collectionType: Collection1Type | Collection2Type; | |
reactionType: ReactionType; | |
childReactionType: ChildReactionType; | |
personalizationType: UR; | |
}; | |
export const streamClient = (userToken: string) => { | |
const client = connect<StreamType>(STREAM_API_KEY, userToken, STREAM_APP_ID); | |
const clientFeed = client.feed("timeline_aggregated"); | |
return clientFeed; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment