Merge branch 'dev' of github.com:Discours/discoursio-webapp into dev

This commit is contained in:
tonyrewin 2022-09-23 11:28:10 +03:00
commit a541e34090
3 changed files with 12 additions and 6 deletions

View File

@ -216,7 +216,9 @@ type InitialState = {
topRatedMonthArticles?: Shout[]
}
export const useArticlesStore = ({ sortedArticles }: InitialState = {}) => {
export const useArticlesStore = (initialState: InitialState = {}) => {
const sortedArticles = [...(initialState.sortedArticles || [])]
addArticles(sortedArticles)
if (sortedArticles) {

View File

@ -96,8 +96,9 @@ type InitialState = {
authors?: Author[]
}
export const useAuthorsStore = ({ authors }: InitialState = {}) => {
addAuthors(authors || [])
export const useAuthorsStore = (initialState: InitialState = {}) => {
const authors = [...(initialState.authors || [])]
addAuthors(authors)
const getAuthorEntities = useStore(authorEntitiesStore)
const getSortedAuthors = useStore(sortedAuthorsStore)

View File

@ -116,9 +116,12 @@ type InitialState = {
sortBy?: TopicsSortBy
}
export const useTopicsStore = ({ topics, randomTopics, sortBy }: InitialState = {}) => {
if (sortBy) {
sortAllByStore.set(sortBy)
export const useTopicsStore = (initialState: InitialState = {}) => {
const topics = [...(initialState.topics || [])]
const randomTopics = [...(initialState.randomTopics || [])]
if (initialState.sortBy) {
sortAllByStore.set(initialState.sortBy)
}
addTopics(topics, randomTopics)