Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Домашнее задание 5 #12

Merged
merged 3 commits into from
May 22, 2019
Merged

Домашнее задание 5 #12

merged 3 commits into from
May 22, 2019

Conversation

denisstasyev
Copy link
Owner

@chexex Исправил все предыдущие замечания по стилю кода, удалил ненужный закомментированный код, исправил ошибки линтера.

Copy link
Collaborator

@chexex chexex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обратить внимание на то, что стрелочные функцию получают родительский this, поэтому нет необходимости делать привязывание this к этим функциям

@@ -23,11 +23,11 @@ class Chat extends React.Component {
);
}

onMessage(message) {
onMessage = message => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выше на 18-21 строках не нужен .bind(this), так как стрелочная функция уже захватывает this

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chexex Спасибо, теперь понятны слова Мартина про отсутствие своего this у стрелочных функций

this.state.worker.then(worker => {
worker.port.postMessage(message);
});
}
};

getSharedWorker() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему эта функция не прошла модернизацию?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot from 2019-05-22 12-21-51
@chexex не совсем понимаю почему, но кажется реакт почему-то не понимает, что я ему функцию отправляю

@@ -20,7 +20,7 @@ class FileButton extends React.Component {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 строка: var на const

reader.onload = () => {...}, bind убрать

@@ -7,7 +7,7 @@ import * as actionTypes from "store/actionTypes/actionTypes";
import ImageFileButton from "static/Chat/MessageForm/FileButton/paperclip.svg";

class FileButton extends React.Component {
onFileSelect(event) {
onFileSelect = event => {
event.preventDefault();
var files = Array.from(event.target.files);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var

@@ -5,14 +5,14 @@ import styles from "./styles.module.css";
import * as actionTypes from "store/actionTypes/actionTypes";

class ReactionButton extends React.Component {
sendReaction() {
sendReaction = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Везде, где используется sendReaction больше не нужен привязывать this (убрать .bind(this))


updateText() {
updateText = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрать .bind(this)

@@ -5,11 +5,11 @@ import styles from "./styles.module.css";
import * as actionTypes from "store/actionTypes/actionTypes";

class SendButton extends React.Component {
onSubmit(event) {
onSubmit = event => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрать .bind(this)


onSubmit(event) {
onSubmit = event => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрать .bind(this)

@@ -5,18 +5,18 @@ import styles from "./styles.module.css";
import * as actionTypes from "store/actionTypes/actionTypes";

class TextMessageForm extends React.Component {
onChange(event) {
onChange = event => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрать .bind(this)

@@ -21,7 +21,7 @@ class MessageList extends React.Component {
this.scrollToBottom();
}

handleDragAndDrop(event) {
handleDragAndDrop = event => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрать .bind(this)

@denisstasyev
Copy link
Owner Author

@chexex Исправил все замечания кроме getSharedWorker()

Copy link
Collaborator

@chexex chexex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Использованы ES6 возможности языка
Убраны комменты
Убраны var

6

@@ -11,13 +11,13 @@ export function getReadableSize(size) {
}

export function getTime() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const getTime = () => {...}

var date = new Date();
var timeRegex = "^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])(:[0-5][0-9])?";
let date = new Date();
let timeRegex = "^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])(:[0-5][0-9])?";
return date.toTimeString().match(timeRegex)[0];
}

export function sendToServer(text, file) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const sendToServer (text, file) {...}

@@ -26,11 +26,11 @@ class MessageList extends React.Component {
let files = Array.from(event.dataTransfer.files);

files.forEach(function(file) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files.forEach(file => {...})

@@ -9,14 +9,14 @@ import ImageFileButton from "static/Chat/MessageForm/FileButton/paperclip.svg";
class FileButton extends React.Component {
onFileSelect = event => {
event.preventDefault();
var files = Array.from(event.target.files);
let files = Array.from(event.target.files);

files.forEach(function(file) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files.forEach(file => {...})

@martinkomitsky martinkomitsky removed their request for review May 22, 2019 10:27
@martinkomitsky martinkomitsky removed their assignment May 22, 2019
@chexex chexex merged commit ff0e0f9 into master May 22, 2019
@martinkomitsky martinkomitsky deleted the sem2-hw5 branch May 24, 2019 14:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants