-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BOX-185: Доприкрутил API вместо mock-заглушек [part 2] [final] #56
The head ref may contain hidden characters: "feature/box-185-\u043F\u0440\u0438\u043A\u0440\u0443\u0442\u0438\u0442\u044C-\u0440\u0435\u0430\u043B\u044C\u043D\u0443\u044E-api-\u043D\u0430-\u0441\u043C\u0435\u043D\u0443-\u043C\u043E\u043A\u043E\u0432\u044B\u043C-2"
BOX-185: Доприкрутил API вместо mock-заглушек [part 2] [final] #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self-reviewed
export interface Question { | ||
readonly topic: string; | ||
readonly author: CommentUser; | ||
readonly when: string; | ||
readonly text: React.ReactNode; | ||
readonly resolved?: boolean; | ||
readonly responses: { | ||
authors: string[]; | ||
count: number; | ||
lastReponseAt: string; | ||
}; | ||
} | ||
export interface Answer { | ||
readonly author: CommentUser; | ||
readonly title: string; | ||
readonly when: string; | ||
readonly why: 'liked' | false; | ||
readonly text: React.ReactNode; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Позже прикрутим реальную АПИху для комментов
// FIXME: remove component as redundant later | ||
|
||
interface Props { | ||
cards: Card[]; | ||
getHref?: (data: Card) => string | undefined; | ||
getUserHref?: (data: Card) => string | undefined; | ||
// FIXME: will be removed later | ||
getUser: (data: Card) => User; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Меня оч корежит этот пропс-дриллинг и файлы **-list
, поэтому позже как удалим - это автоматически устранится
{/* FIXME: resolve better later */} | ||
<Editor value={content as EditorValue} readOnly={true} /> | ||
</> | ||
)} | ||
{size === 'small' && ( | ||
<ItemEditorContainer> | ||
{/* FIXME: resolve EditorValue BOX-185 */} | ||
<Editor value={content as any} readOnly={true} /> | ||
{/* FIXME: resolve better later */} | ||
<Editor value={content as EditorValue} readOnly={true} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Хз как лучше зарезолвить, ибо это генерится с typed-contracts
// FIXME: move logic to entities level? | ||
sample({ | ||
source: cardsSearchFx.doneData, | ||
fn: ({ answer }) => answer.users as User[], | ||
target: userModel.updateMap, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Для KV кэша
const topCards = useStore(model.$topCards); | ||
const latestCards = useStore(model.$latestCards); | ||
const usersMap = useStore(userModel.$usersMap); | ||
|
||
// FIXME: temp handlers | ||
const handleUser = useCallback( | ||
(card: Card) => { | ||
const user = usersMap[card.authorId]; | ||
return user; | ||
}, | ||
[usersMap], | ||
); | ||
|
||
const handleUserHref = useCallback( | ||
(card: Card) => { | ||
const user = usersMap[card.authorId]; | ||
return paths.user(user.username); | ||
}, | ||
[usersMap], | ||
); | ||
|
||
const handleCardHref = useCallback((card: Card) => { | ||
return paths.card(card.id); | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Самому оч не нравится, но когда задекомпозим нормально по слоям - и страница более тонкой станет
// FIXME: move to entities/card level later? (as cache store?) | ||
export const $topCards = createStore<Card[]>([]); | ||
export const $latestCards = createStore<Card[]>([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Пока показалось, что такое лучше всеж хранить на уровне страницы
const CardResults = () => { | ||
const usersMap = useStore(userModel.$usersMap); | ||
const cards = useStore(searchModel.$cardList); | ||
const isLoading = useStore(model.$isShowLoading); | ||
|
||
return ( | ||
<CardList | ||
cards={cards} | ||
getHref={(card) => paths.card(card.id)} | ||
loading={isLoading} | ||
getUser={(card) => usersMap[card.authorId]} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
По совету @sergeysova
src/pages/user/index.tsx
Outdated
{Boolean(socials.length) && ( | ||
<SocialStaff> | ||
<SocialStaffTitle>Social staff</SocialStaffTitle> | ||
<SocialStaffList> | ||
{socials.map((social) => ( | ||
<SocialStaffItem key={social.id}> | ||
<SocialLink href={social.link}> | ||
{avatar && <Avatar size="small" src={avatar} />} | ||
<SocialStaffItemText> | ||
@{social.username} | ||
</SocialStaffItemText> | ||
</SocialLink> | ||
</SocialStaffItem> | ||
))} | ||
</SocialStaffList> | ||
</SocialStaff> | ||
)} | ||
</UserSocial> | ||
{avatar && ( | ||
<UserLogo> | ||
<StAvatar size="large" src={avatar} /> | ||
</UserLogo> | ||
)} | ||
{/* FIXME: move to entities/user logic */} | ||
<UserLogo> | ||
<StAvatar size="large" src={avatar || imgLogo} /> | ||
</UserLogo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Тож декомпозируем позж при рефакторинге
src/pages/card/view/model.ts
Outdated
// FIXME: Временный хак, чтобы запросить сессию с клиента для одной страницы | ||
// (пока что нужно только на CardViewPage, но позже будет фетчится нормальным способом, когда подтянем авторизацию) | ||
sample({ | ||
source: pageLoaded, | ||
target: sessionModel._sessionLoadedClient, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Если есть получше методы обойти это - пишите)
@@ -241,7 +241,6 @@ export const cardsSearchOk = typed.object({ | |||
roles: typed.array(typed.string).maybe, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Можно игнорить файл при ревью (codegen)
export const $currentUser = createStore<User | null>(null); | ||
|
||
// FIXME: temp solution | ||
export const $usersMap = createStore<Record<string, User>>({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Потом мб уберем KV store, посмотрим
import imgLogo from './logo.png'; | ||
|
||
export { imgLogo }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Про проблемы реэкспорта помню, но и ассеты по проекту плодить не хочется "по месту использования")
DISCLAIMER
Изменений не так много, в основном опять же - из-за кодогенерации)
Этот файлик можно проигнорить при ревью
CHANGELOG