From c8750d6692671354e2d0660b46e3db0c5abbc46a Mon Sep 17 00:00:00 2001 From: pillowbee Date: Tue, 16 Apr 2024 19:41:50 +0300 Subject: [PATCH] Fixes for first attempt --- src/components/avatar/avatar.ts | 3 ++- src/components/chatWindow/chatWindow.ts | 1 - src/components/modal/modal.css | 2 +- src/components/modal/modal.ts | 2 +- src/constants/initialState.ts | 2 +- src/constants/types.ts | 2 +- src/controllers/AuthController.ts | 5 ++++- src/core/Store.ts | 5 +---- src/pages/loginPage/loginPage.ts | 4 +++- src/pages/messengerPage/messengerPage.ts | 10 +++++----- src/pages/profilePage/profilePage.ts | 4 +++- src/pages/registerPage/registerPage.ts | 4 +++- src/utils/connect.ts | 1 - src/utils/formatMessageDate.ts | 4 ++-- 14 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/components/avatar/avatar.ts b/src/components/avatar/avatar.ts index afbc15ce3..0347d46b1 100644 --- a/src/components/avatar/avatar.ts +++ b/src/components/avatar/avatar.ts @@ -40,7 +40,8 @@ export default class Avatar extends Block { componentDidUpdate(oldProps: Props, newProps: Partial): boolean { if (!newProps.src) { - newProps.src = 'https://i2.wp.com/vdostavka.ru/wp-content/uploads/2019/05/no-avatar.png?fit=512%2C512&ssl=1' + newProps.src = + 'https://i2.wp.com/vdostavka.ru/wp-content/uploads/2019/05/no-avatar.png?fit=512%2C512&ssl=1' } return super.componentDidUpdate(oldProps, newProps) } diff --git a/src/components/chatWindow/chatWindow.ts b/src/components/chatWindow/chatWindow.ts index edf964c87..ae65f3030 100644 --- a/src/components/chatWindow/chatWindow.ts +++ b/src/components/chatWindow/chatWindow.ts @@ -162,7 +162,6 @@ export class ChatWindow extends Block { showDeleteUserModal() { const content = document.createElement('div') content.className = 'users' - ;(this.props.chatUsers as User[]).map((user: User) => { const userBlock = document.createElement('div') const userLogin = document.createElement('span') diff --git a/src/components/modal/modal.css b/src/components/modal/modal.css index 194e7801a..aa51eac37 100644 --- a/src/components/modal/modal.css +++ b/src/components/modal/modal.css @@ -44,4 +44,4 @@ button { margin-top: 16px; } -} \ No newline at end of file +} diff --git a/src/components/modal/modal.ts b/src/components/modal/modal.ts index d2c07dc64..767535996 100644 --- a/src/components/modal/modal.ts +++ b/src/components/modal/modal.ts @@ -57,4 +57,4 @@ export class Modal { this.modalElement.style.display = 'none' this.overlayElement.style.display = 'none' } -} \ No newline at end of file +} diff --git a/src/constants/initialState.ts b/src/constants/initialState.ts index c7afc8186..9de273257 100644 --- a/src/constants/initialState.ts +++ b/src/constants/initialState.ts @@ -12,5 +12,5 @@ export const initialState = { chats: [], selectedChat: 0, messages: [], - chatUsers: [] + chatUsers: [], } diff --git a/src/constants/types.ts b/src/constants/types.ts index c01d24861..32d35c5e9 100644 --- a/src/constants/types.ts +++ b/src/constants/types.ts @@ -30,7 +30,7 @@ export type Message = { id: number is_read: boolean time: string - type: "message" + type: 'message' user_id: number } diff --git a/src/controllers/AuthController.ts b/src/controllers/AuthController.ts index 03e5279c9..b1af22398 100644 --- a/src/controllers/AuthController.ts +++ b/src/controllers/AuthController.ts @@ -29,7 +29,10 @@ export class AuthController { }) .then((resp) => { if (resp.status === 200) { - store.set('userdata', { ...store.getState().userdata, id: resp.response }) + store.set('userdata', { + ...store.getState().userdata, + id: resp.response, + }) } return resp }) diff --git a/src/core/Store.ts b/src/core/Store.ts index e9cc3a7a7..3e6a9ba5f 100644 --- a/src/core/Store.ts +++ b/src/core/Store.ts @@ -33,10 +33,7 @@ class Store extends EventBus { return this.state } - public set( - path: K, - value: StateType[K] - ) { + public set(path: K, value: StateType[K]) { set(this.state, path, value) this.emit(StoreEvents.UPDATED) } diff --git a/src/pages/loginPage/loginPage.ts b/src/pages/loginPage/loginPage.ts index b7d524692..234274f1b 100644 --- a/src/pages/loginPage/loginPage.ts +++ b/src/pages/loginPage/loginPage.ts @@ -100,7 +100,9 @@ const loginForm = new Form({ }), }) -const withUserdata = connect((state) => ({ userdata: state.userdata }))(LoginPage) +const withUserdata = connect((state) => ({ userdata: state.userdata }))( + LoginPage +) export const loginPage = new withUserdata({ loginForm: loginForm, diff --git a/src/pages/messengerPage/messengerPage.ts b/src/pages/messengerPage/messengerPage.ts index 8f0c4545d..e9914591e 100644 --- a/src/pages/messengerPage/messengerPage.ts +++ b/src/pages/messengerPage/messengerPage.ts @@ -62,7 +62,7 @@ export class MessengerPage extends Block { type: 'text', label: 'Название чата', placeholder: 'Название...', - name: 'create-chat' + name: 'create-chat', }) const btn = new Button({ label: 'Создать чат', @@ -71,15 +71,15 @@ export class MessengerPage extends Block { click: () => { chatController.createChat(input.getValue()) this.modal.close() - } - } + }, + }, }) content.appendChild(input.element) content.appendChild(btn.element) - this.modal.setContent('Создать чат', content); - this.modal.open(); + this.modal.setContent('Создать чат', content) + this.modal.open() } createChatItems(chats: Chat[]) { diff --git a/src/pages/profilePage/profilePage.ts b/src/pages/profilePage/profilePage.ts index 5aab58e8f..f19fcb4e8 100644 --- a/src/pages/profilePage/profilePage.ts +++ b/src/pages/profilePage/profilePage.ts @@ -116,7 +116,9 @@ const logoutBtnHandler = () => { }) } -const withUserdata = connect((state) => ({ userdata: state.userdata }))(ProfilePage) +const withUserdata = connect((state) => ({ userdata: state.userdata }))( + ProfilePage +) export const withUserAvatar = connect((state) => ({ src: state.userdata.avatar, }))(Avatar) diff --git a/src/pages/registerPage/registerPage.ts b/src/pages/registerPage/registerPage.ts index f5b0361a0..8446364d4 100644 --- a/src/pages/registerPage/registerPage.ts +++ b/src/pages/registerPage/registerPage.ts @@ -146,7 +146,9 @@ const registerForm = new Form({ }), }) -const withUserdata = connect((state) => ({ userdata: state.userdata }))(RegisterPage) +const withUserdata = connect((state) => ({ userdata: state.userdata }))( + RegisterPage +) export const registerPage = new withUserdata({ registerForm: registerForm, diff --git a/src/utils/connect.ts b/src/utils/connect.ts index 4207478c7..3cbdafb1b 100644 --- a/src/utils/connect.ts +++ b/src/utils/connect.ts @@ -25,4 +25,3 @@ export default function connect

( } } } - diff --git a/src/utils/formatMessageDate.ts b/src/utils/formatMessageDate.ts index 2e69576d1..5e0a34ab3 100644 --- a/src/utils/formatMessageDate.ts +++ b/src/utils/formatMessageDate.ts @@ -13,12 +13,12 @@ export default (date: string) => { } } else if (offset < 168) { options = { - weekday: 'short' + weekday: 'short', } } else { options = { month: 'short', - day: 'numeric' + day: 'numeric', } }