Skip to content

Commit

Permalink
Merge pull request #9 from frontend-park-mail-ru/RK4
Browse files Browse the repository at this point in the history
RK4 Additional features and fixex
  • Loading branch information
tkoibaev authored Dec 16, 2024
2 parents 8f0e835 + fd974f4 commit edbca4c
Show file tree
Hide file tree
Showing 23 changed files with 157 additions and 62 deletions.
Binary file added public/assets/icons/logo-172-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/icons/logo-172.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/assets/icons/logoIcon-144.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/icons/logoIcon-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/assets/icons/logoIcon-180.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/assets/icons/logoIcon-60.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions public/assets/icons/sendMessageIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/screenshots/screen1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/screenshots/screen2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion public/components/CoWatchBlock/CoWatchBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export class CoWatchBlock {

if (createRoomButton) {
createRoomButton.addEventListener('click', () => {
const modal = new CreateRoomModal();
const modal = new CreateRoomModal(
'Создание комнаты',
'Воспользуйтесь поиском, чтобы найти нужный фильм и создать комнату для совместного просмотра',
);
modal.render();
});
}
Expand Down
6 changes: 2 additions & 4 deletions public/components/CreateRoomModal/CreateRoomModal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
src='/assets/icons/closeNoShadowIcon.svg'
alt=''
/>
<h1 class='create-room-modal__content_title'>Создание комнаты</h1>
<h1 class='create-room-modal__content_title'>{{title}}</h1>
<div class='create-room-modal__content_search'>
<div class='create-room-modal__content_search_area'>
<span class='create-room-modal__content_search_desc'>Воспользуйтесь
поиском, чтобы найти нужный фильм и создать комнату для совместного
просмотра</span>
<span class='create-room-modal__content_search_desc'>{{text}}</span>
<input
autocomplete='off'
id='create-room-search-movie-input'
Expand Down
11 changes: 9 additions & 2 deletions public/components/CreateRoomModal/CreateRoomModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ export class CreateRoomModal {
#inputValueEmmitter: Emitter<string>;
#isModalOpen: boolean;
#onClick;
#title;
#text;

constructor(onClick?: (id: number) => void) {
constructor(title: string, text: string, onClick?: (id: number) => void) {
this.#isModalOpen = false;
this.#inputValue = '';
this.#inputValueEmmitter = new Emitter<string>('');
this.#onClick = onClick;
this.#title = title;
this.#text = text;

const userLoadingListener = searchBlockStore.movEm$.addListener(() => {
this.renderMoviesList(searchBlockStore.getMovies(), this.#inputValue);
Expand Down Expand Up @@ -88,7 +92,10 @@ export class CreateRoomModal {
render() {
const root = document.getElementById('root');
if (root) {
root.insertAdjacentHTML('beforeend', template());
root.insertAdjacentHTML(
'beforeend',
template({ title: this.#title, text: this.#text }),
);
root.style.overflow = 'hidden';
}

Expand Down
1 change: 0 additions & 1 deletion public/components/Slider/Slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
&__track {
display: flex;
height: auto;
align-items: center;

gap: 50px;
transition: transform 0.5s ease;
Expand Down
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="icon" type="image/svg" href="./assets/icons/logoIcon.svg"/>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap" rel="stylesheet">
<link rel="manifest" href="./manifest.json" />
</head>
<body>
<div id="root"></div>
Expand Down
9 changes: 0 additions & 9 deletions public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,5 @@ root.appendChild(footerElement);
root.appendChild(notifierElement);
root.appendChild(previewElement);

if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/sw.js', { scope: '/' })
.then(() => console.log('serviceWorker has been registered'))
.catch((err) => {
console.log('SW ERR: ', err);
});
}

initialStore.start();
router.start();
37 changes: 37 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"id": "/",
"lang": "ru-RU",
"short_name": "Cassette",
"name": "Cassette — онлайн кинотеатр с совместным просмотром",
"description": "Cassette — онлайн кинотеатр с совместным просмотром, широкой библиотекой фильмов и многофункциональным видео-плеером!",
"icons": [
{
"src": "/assets/icons/logo-172.png",
"sizes": "172x172"
},
{
"src": "/assets/icons/logo-172-mask.png",
"sizes": "172x172",
"type": "image/png",
"purpose": "maskable"
}
],
"background_color": "#000",
"display": "standalone",
"start_url": "/",
"theme_color": "#000",
"screenshots": [
{
"src": "/assets/screenshots/screen1.png",
"type": "image/png",
"sizes": "3024x1748",
"form_factor": "wide"
},
{
"src": "/assets/screenshots/screen2.png",
"type": "image/png",
"sizes": "708x1538",
"form_factor": "narrow"
}
]
}
18 changes: 10 additions & 8 deletions public/pages/MoviePage/MoviePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,17 @@ export class MoviePage {
season?: number,
series?: number,
) {
if (timeCode > duration * 0.95 || timeCode < duration * 0.05) {
Actions.deleteLastMovie();
return;
}
if (duration) {
if (timeCode > duration * 0.95 || timeCode < duration * 0.05) {
Actions.deleteLastMovie();
return;
}

if (!this.#movie?.isSerial) {
Actions.setLastMovies(timeCode, duration);
} else {
Actions.setLastMovies(timeCode, duration, season, series);
if (!this.#movie?.isSerial) {
Actions.setLastMovies(timeCode, duration);
} else {
Actions.setLastMovies(timeCode, duration, season, series);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions public/pages/RoomPage/RoomPage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
class='input room-page__chat_input'
placeholder='Введите сообщение...'
type='text'
autocomplete='off'
/>
<img
id='send-message-button'
Expand Down
4 changes: 2 additions & 2 deletions public/pages/RoomPage/RoomPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

&_button {
cursor: pointer;
width: 36px;
height: 36px;
width: 37px;
height: 37px;
}

&_block {
Expand Down
25 changes: 24 additions & 1 deletion public/pages/RoomPage/RoomPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ export class RoomPage {
}

handleChangeMovieClick() {
const modal = new CreateRoomModal((id: number) => Actions.changeMovie(id));
const modal = new CreateRoomModal(
'Изменение фильма',
'Воспользуйтесь поиском, чтобы найти нужный фильм',
(id: number) => Actions.changeMovie(id),
);
const createRoomButton = document.getElementById(
'change-movie-btn',
) as HTMLElement;
Expand Down Expand Up @@ -358,6 +362,25 @@ export class RoomPage {
) as HTMLButtonElement;
sendMessageButton.addEventListener('click', () => this.sendMessage());
this.handleChangeMovieClick();

const messageInput = document.getElementById(
'messages-input',
) as HTMLInputElement;

const handleEnterKey = (event: KeyboardEvent) => {
if (event.key === 'Enter') {
event.preventDefault();
this.sendMessage();
}
};

messageInput.addEventListener('focus', () => {
messageInput.addEventListener('keydown', handleEnterKey);
});

messageInput.addEventListener('blur', () => {
messageInput.removeEventListener('keydown', handleEnterKey);
});
} else {
this.#loader.render();
}
Expand Down
47 changes: 24 additions & 23 deletions public/store/MoviePageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class MoviePageStore {
foundMovie.season = season;
foundMovie.series = series;
foundMovie.albumImage = seriesImage as string;
foundMovie.savingSeconds = Date.now();
} else {
this.#lastMovies.push({
id: this.#movie.id,
Expand Down Expand Up @@ -313,35 +314,35 @@ class MoviePageStore {
}
break;
case ActionTypes.SET_LAST_MOVIES:
if (userStore.getUser().username) {
// TODO: Расскомментировать после мержа
// this.setLastMoviesRequest({
// ...action.payload,
// id: this.#movie?.id,
// title: this.#movie?.title,
// albumImage: this.#movie?.albumImage,
// savingSeconds: Date.now(),
// });
} else {
this.setLastMoviesToLocalStorage(
action.payload.timeCode,
action.payload.duration,
action.payload.season,
action.payload.series,
);
}
// if (userStore.getUser().username) {
// TODO: Расскомментировать после мержа
// this.setLastMoviesRequest({
// ...action.payload,
// id: this.#movie?.id,
// title: this.#movie?.title,
// albumImage: this.#movie?.albumImage,
// savingSeconds: Date.now(),
// });
// } else {
this.setLastMoviesToLocalStorage(
action.payload.timeCode,
action.payload.duration,
action.payload.season,
action.payload.series,
);
// }
break;
case ActionTypes.COPY_LAST_MOVIES:
// TODO: Расскомментировать после мержа
// this.setLastMoviesRequest();
break;
case ActionTypes.DELETE_LAST_MOVIE:
if (userStore.getUser().username) {
// TODO: Расскомментировать после мержа
// this.deleteLastMovieRequest();
} else {
this.deleteLastMovieFromLocalStorage();
}
// if (userStore.getUser().username) {
// TODO: Расскомментировать после мержа
// this.deleteLastMovieRequest();
// } else {
this.deleteLastMovieFromLocalStorage();
// }
break;
case ActionTypes.RATE_MOVIE:
this.rateMovieRequest(action.payload.rating);
Expand Down
18 changes: 11 additions & 7 deletions public/store/RoomPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ class RoomPageStore {
this.#globalRoomId = '';
}

ws.onclose = (event) => {
console.log('WebSocket соединение закрыто:', event.code, event.reason);
};
// ws.onclose = (event) => {
// console.log('WebSocket соединение закрыто:', event.code, event.reason);
// };

ws.onopen = () => {
console.log('WebSocket соединение открыто');
};
// ws.onopen = () => {
// console.log('WebSocket соединение открыто');
// };

ws.onmessage = (event) => {
const messageData = JSON.parse(event.data);
Expand Down Expand Up @@ -190,7 +190,11 @@ class RoomPageStore {
}
break;
case 'change_movie':
if (this.#room && messageData['movie'].id !== this.#room.movie.id) {
if (
this.#room &&
messageData['movie'] &&
messageData['movie'].id !== this.#room.movie.id
) {
this.#room.movie = serializeMovieDetailed(messageData['movie']);
if (this.#room.movie.seasons && this.#room.movie.seasons.length) {
roomPage.renderVideo(
Expand Down
1 change: 1 addition & 0 deletions public/store/UserStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class UserStore {
this.#user.username = '';
this.#user.avatar = '';
this.#user.id = 0;
this.#user.isPremium = false;

this.#isUserLoading = false;
this.#isUserLoadingEmmiter.set(false);
Expand Down

0 comments on commit edbca4c

Please sign in to comment.