Skip to content

Instantly share code, notes, and snippets.

@willdspd
Last active January 22, 2021 14:58
Show Gist options
  • Save willdspd/967916c877e29f4067589759e1229449 to your computer and use it in GitHub Desktop.
Save willdspd/967916c877e29f4067589759e1229449 to your computer and use it in GitHub Desktop.
Event SPA global state
event: {
id: [eventId],
selectorId: [eventSelectorId],
name: [eventName],
description: [eventDescription],
image: [eventImage],
startTime: [eventStartTime],
endTime: [eventEndTime],
creatorId: [eventCreatorId],
chatId: [eventChatId],
speakerIds: [1, 2, 3],
slug: [eventSlug],
roomIds: [1, 3],
hallIds: [2, 9, 10]
userCount: [eventUsersCount],
userIds: [24, 25],
usersInEventCount: [eventUsersOnlineCount],
// Is this needed if we have 'isInEvent:' in the users model? Probably will remove later
usersInEventIds: [24, 25]
}
-----
// Should this be placed in the event model? I think the rule should be, anything that is referenced in two seperate locations, gets its own model, so in my opinion, this shouldn't be in the event model.
tickets: [{
id: [ticketId],
type: "DONATION",
name: [ticketName],
description: [ticketDescription],
currency: [ticketCurrency],
price: [ticketPrice],
quantity: [ticketQuantity],
remainingQuantity: [ticketsRemainingQuantity]
}]
-----
// I agree it isn't needed, but I think rooms in halls probably should be added to the global state for consistency. It will just be much easier to understand that everything regading event state is in easy-peasy, no need for developers to have to look into the code to see what is local and what is global, plus we can see the whole event interior state using Redux dev tools which will be easier for debugging. However, if we face any issues or obvious inconveniences we can discuss again.
rooms: [{
id: [roomId],
selectorId: [roomSelectorId],
name: [roomName],
creatorId: [roomCreatorId],
slug: [roomSlug],
isLive: true,
// This should probably be changed from 'isStage:' to something else, because organizers may create private rooms for themsleves and speakers, which won't act as stages. I'm thinking reversing it and having something like 'isInHall:'
isStage: true,
chatId: [roomChatId],
audienceCount: [roomAudienceCount],
audienceIds: [1, 3, 5],
speakerCount: [roomSpeakersCount],
speakerIds: [6, 9, 10],
streamCredentials: {
appId: [appId],
// Can be changed
channel: [channelName],
isSpeaker: true,
isUserWatching: false,
// Agora names
screenToken: [screenToken],
videoToken: [videoToken]
},
accessPermissions: {
organizers: true,
speakers: true,
attendees: true,
tickets: [
23,
89
]
},
streamPermissions: {
organizers: true,
speakers: true,
attendees: true,
tickets: [
23,
89
]
},
}]
-----
halls: [{
id: [hallId],
selectorId: [hallSelectorId],
name: [hallName],
creatorId: [hallCreatorId],
roomIds: [1, 3, 4],
liveRoomCount: [hallLiveRoomsCount],
slug: [hallSlug],
accessPermissions: {
organizers: true,
speakers: true,
attendees: true,
tickets: [
23,
89
]
},
createRoomPermissions: {
organizers: true,
speakers: true,
attendees: true,
tickets: [
23,
89
]
}
}]
-----
chats: [{
id: [chatId],
// Should this be 'medium:' or 'location:' rather than 'type:'? What makes most intuitive sense to you? Should be type as will include 'DM' in the future
type: "ROOM",
messages: [{
id: [messageId],
senderId: [senderId],
message: "Hello"
}]
}]
-----
// Today you mentioned that if we include 'me' in the users model we'll have to "get an array from state and loop it to find our current user. Because of these reasons I believe it’s best to separate currentUser (which as I mentioned before might have special properties) from users array (a prop name for it may be “me”). And for that reason we can remove “isMe” property from other users". Is this still true after realising that we need 'me' to be included for things like audience?
// All users will be updated when we update 'me', but can be prevented using memo
users: [{
id: [userId],
selectorId: [userSelectorId],
name: [userName],
email: [userEmail],
image: [userImage],
slug: [userSlug],
color: [userColor],
verified: true,
// Only needs to be included if the user is in an event
eventUserId: [eventUserId],
eventUserType: "ATTENDEE",
ticketId: [eventUserTicketId],
// Do we need this if we have inEventIds in the event object? Or maybe we don't need the inEventIds?
isInEvent: true
// Only needs to be included if the user is the current user
isMe: true,
organizationIds: [23, 65, 21],
paymentAccounts: [{
id: [paymentAccountId],
email: [paymentAccountEmail],
userId: [paymentAccountUserId]
}],
}]
-----
// Can be ignored for the moment as organizations won't be needed inside event
// Maybe best to just reference in users. However, what if in the future we want to show a list of users and their organizations. If users share organizations we will want one centralised place to update organizations
organizations: [{
id: [organizationId],
selectorId: [organizationSelectorId],
name: [organizationName],
image: [organizationImage],
slug: [organizationSlug],
paymentAccounts: [{
id: [paymentAccountId],
email: [paymentAccountEmail],
userId: [paymentAccountUserId]
}]
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment