Skip to content
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

remake newGame notification, add join button #43

Conversation

VladimirAfanasievFS
Copy link
Collaborator

#19

const popupNotification = new Notification('Notification', notifications[notification]);
console.log('showNotification', storage);
const currentNotification = { ...notifications[notification], message };
const popupNotification = new Notification(id.toString(), currentNotification);
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
Collaborator Author

Choose a reason for hiding this comment

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

Ну типа в дефолтном уведомление заменить нужное, как лучше сделать видишь?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ну вот смотри.

  1. Я специально создал файл с моделями, чтобы держать там все шаблоны, и т.п.
  2. Есть класс Уведомление, у которого есть дефолтный шаблон. Ты можешь поправить реализацию класса, чтобы он получал шаблон и данные которые надо отобразить.
  3. В идеале, надо чтобы у нас была очередь сообщений, не больше Н числа. И обновляются они по принципу стека.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Что есть очередь сообщений? и зачем она? У нас уникальные ID

Copy link
Collaborator

Choose a reason for hiding this comment

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

очереди пока нет. Это была "преждевременная оптимизация"

if (gameStatus === gameStatuses.waiting) {
animateBadge();
showNotification('newGame');
const message = `Player - ${action.payload.players[0].name} || game level - ${action.payload.level} || status - ${action.payload.state} `;
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
Collaborator Author

Choose a reason for hiding this comment

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

Где- то про это общались в игре может быть только 2 игрока и players[0] всегда создатель
Если строку делать независимой я не узнаю имя создателя

@VladimirAfanasievFS
Copy link
Collaborator Author

Переделал на функцию, но возникли проблемы с addListener которые создавались каждый раз и множились. Пришлось сделать логику по их очищению. Есть сомнения что перемудрил

Copy link
Collaborator

@glagius glagius left a comment

Choose a reason for hiding this comment

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

Т.к. объект "notifications" глобальный, то и вотчеры надо делать в одном месте, а не на каждый чих.
Лучше сделать отдельно обработчик кликов, и слушать это событие ( browser.notifications.onButtonClicked.addListener(handleOnButtonClicked); ) в index.js

const currentNotification = { ...notifications[notification], message };
const popupNotification = new Notification(id.toString(), currentNotification);
popupNotification.addListener();
createNotification(gameID.toString(), notifications[notification], message, gameID);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Может вместо notifications будет templates ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

templates вроде как ничего не дает как информацию, и такие названия крайне не желательны типа const array =[] , нет?, templateNotifications но длинно получается

@VladimirAfanasievFS
Copy link
Collaborator Author

У меня вложенность из за того что внутренний обработчик должен имень доступ к переменным
Типа вынесу наверх и сделаю единый листенер на все кнопки я не смогу узнать какой именно отработал кроме id и индекса кнопки не возвращается никакой инфы

@VladimirAfanasievFS
Copy link
Collaborator Author

Переделал на советы сделать один/общий листенер, через хак передачи через ID

@VladimirAfanasievFS
Copy link
Collaborator Author

VladimirAfanasievFS commented Oct 13, 2020

Starting your workflow run...
Github Actions не работает , гугл говорит не правильно прописано/нравится версию убунту и матрикс

@glagius glagius merged commit 999b8ef into hexlet-codebattle:master Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants