state = {
session: {
user: {}
},
search: {
users: {},
users_list: [{}, {}, {}, ...]
messages: {},
channels: {}
},
channels: {
id: { users: {}, messages: {}, all_messages: [] },
id: { users: {}, messages: {}, all_messages: [] },
...,
channel_list: [ {}, {}, {}, ... ],
dm_list: [ {}, {}, {}, ... ]
}
}
State
state: {
session: {},
channels: {},
search: {},
modals: {}
}
Session
user: {
channels: [{}, {}, {}, ...],
email: "",
first_name: "",
id: Number,
image_url: "",
last_name: "",
messages: [{}, {}, {}, ...]
}
Channels
--> state.channels
channels: {
id: {},
id: {},
...,
}
--> state.channels[id]
channels[id] = {
description: "",
id: Number,
is_dm: Boolean,
messages: [{}, {}, {}, ...]
owner_id: Number,
time_created: "",
time_updated: "",
title: "",
users_ids: [],
users_in_channel: [{}, {}, {}, ...]
}
--> state.channels[id].messages //to map over in react
all_messages = [
{
user_id: Number,
channel_id: Number,
content: Text
},
...
]
--> state.channels[id].users_in_channel
messages = [
{
email: "",
first_name: "",
id: Number,
image_url: "",
last_name: ""
},
...
]
Search
--> state.search
search: {
search_input: "",
users_results: [{}, {}, {}, ...]
}
--> state.search.users_reults
users_results: [
{
channels: [{}, {}, {}, ...]
email: "",
first_name: "",
id: Number,
image_url: "",
last_name: ""
messages: [{}, {}, {}, ...]
}
]
--> state.search.messages
// for future implementation of search for messages
--> state.search.channels
// for future implementation of search for channels
Modals
--> state.modals
modals: {
currentModal: {}
modalMount: {},
searchModalMount: {},
modalDisplay: Boolean,
searchDisplay: Boolean
}