Skip to content

Commit

Permalink
Fixes for first attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Pillowbee committed Apr 16, 2024
1 parent cea1423 commit c8750d6
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/components/avatar/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default class Avatar extends Block {

componentDidUpdate(oldProps: Props, newProps: Partial<Props>): 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)
}
Expand Down
1 change: 0 additions & 1 deletion src/components/chatWindow/chatWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
button {
margin-top: 16px;
}
}
}
2 changes: 1 addition & 1 deletion src/components/modal/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ export class Modal {
this.modalElement.style.display = 'none'
this.overlayElement.style.display = 'none'
}
}
}
2 changes: 1 addition & 1 deletion src/constants/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export const initialState = {
chats: [],
selectedChat: 0,
messages: [],
chatUsers: []
chatUsers: [],
}
2 changes: 1 addition & 1 deletion src/constants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type Message = {
id: number
is_read: boolean
time: string
type: "message"
type: 'message'
user_id: number
}

Expand Down
5 changes: 4 additions & 1 deletion src/controllers/AuthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
5 changes: 1 addition & 4 deletions src/core/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ class Store extends EventBus {
return this.state
}

public set<K extends keyof StateType>(
path: K,
value: StateType[K]
) {
public set<K extends keyof StateType>(path: K, value: StateType[K]) {
set(this.state, path, value)
this.emit(StoreEvents.UPDATED)
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/loginPage/loginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/pages/messengerPage/messengerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class MessengerPage extends Block {
type: 'text',
label: 'Название чата',
placeholder: 'Название...',
name: 'create-chat'
name: 'create-chat',
})
const btn = new Button({
label: 'Создать чат',
Expand All @@ -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[]) {
Expand Down
4 changes: 3 additions & 1 deletion src/pages/profilePage/profilePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/pages/registerPage/registerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/utils/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ export default function connect<P extends object>(
}
}
}

4 changes: 2 additions & 2 deletions src/utils/formatMessageDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
}

Expand Down

0 comments on commit c8750d6

Please sign in to comment.