Skip to content

Commit

Permalink
Регресс последнего обновления (v0.9.0) (#192)
Browse files Browse the repository at this point in the history
* version update 0.9.1

* improve player page responsiveness

* migrate to ionic v8.4.1

* fix logo link styles

* theme management

* update default language detection logic

* fix & optimize fetching user id

* fix login button, disable exit

* add theme toggle

* add language selector

* fix webpack environment setup

* fix nullish values for video upload
  • Loading branch information
Smarthard authored Dec 26, 2024
1 parent be0ea3d commit 354e2b8
Show file tree
Hide file tree
Showing 38 changed files with 381 additions and 419 deletions.
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
}
],
"styles": [
"src/theme/variables.scss",
"src/global.scss"
"src/global.scss",
"src/theme/variables.scss"
],
"scripts": [],
"aot": true,
Expand Down
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shikicinema",
"version": "0.9.0",
"version": "0.9.1",
"description": "Shikicinema - player app for Shikimori",
"author": "Smarthard",
"repository": {
Expand Down
5 changes: 2 additions & 3 deletions extension-src/contributions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ async function correctContributions(element) {
let cInfoDiv = document.querySelector('div.c-info');
let activityDiv = document.querySelector('div.c-additionals');
let nickname = `${window.location}`.split('/').slice(-1)[0];
let user = await fetch(`/api/users/${nickname}?is_nickname=1`)
.then(res => res.json());
let user = JSON.parse(document.body?.getAttribute('data-user'));

if (user && user.id) {
let contributions = await fetch(`${SHIKIVIDEOS_API}/contributions?uploader=${user.id}`)
Expand All @@ -40,7 +39,7 @@ async function correctContributions(element) {
element.classList.add('uploader_contributions');
element.innerHTML = `<span><a href="#">${contributions.count} ${upload} видео</a></span>`;
element.onclick = () => {
chrome.runtime.sendMessage({ openUrl: `${PLAYER_URL}#/videos?uploader=${user.nickname}` });
chrome.runtime.sendMessage({ openUrl: `${PLAYER_URL}#/videos?uploader=${nickname}` });
};

if (
Expand Down
2 changes: 1 addition & 1 deletion extension-src/manifest.v2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "shikicinema",
"version": "0.9.0",
"version": "0.9.1",

"icons": {
"64": "assets/icon64.png",
Expand Down
2 changes: 1 addition & 1 deletion extension-src/manifest.v3.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "shikicinema",
"version": "0.9.0",
"version": "0.9.1",

"icons": {
"64": "assets/icon64.png",
Expand Down
4 changes: 3 additions & 1 deletion extension-webpack.hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ const path = require('path');
const ESLintPlugin = require('eslint-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const dotenv = require('dotenv');

dotenv.config();

const isProduction = process.env.NODE_ENV === 'production';
const manifestVersion = process.env.MANIFEST_VERSION ?? 'v2';
const manifestVersion = process.env.MANIFEST_VERSION || 'v2';

function processManifest(content) {
const manifestContents = JSON.parse(content.toString());
Expand Down
65 changes: 0 additions & 65 deletions manifest.v3.json

This file was deleted.

39 changes: 20 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shikicinema",
"version": "0.9.0",
"version": "0.9.1",
"description": "Returns video player on Shikimori",
"main": "src/shikicinema.js",
"engines": {
Expand Down Expand Up @@ -61,7 +61,8 @@
"@capacitor/haptics": "5.0.6",
"@capacitor/keyboard": "5.0.7",
"@capacitor/status-bar": "5.0.6",
"@ionic/angular": "8.0.1",
"@ionic/angular": "^8.4.1",
"@ionic/core": "^8.4.1",
"@ionic/storage-angular": "^4.0.0",
"@ngneat/transloco": "^6.0.4",
"@ngneat/until-destroy": "^10.0.0",
Expand Down Expand Up @@ -90,7 +91,7 @@
"@angular/language-service": "~17.3.6",
"@capacitor/cli": "^5.6.0",
"@digitak/esrun": "^3.2.26",
"@ionic/angular-toolkit": "11.0.0",
"@ionic/angular-toolkit": "^11.0.1",
"@ionic/cli": "^7.2.0",
"@ngrx/eslint-plugin": "17.2.0",
"@ngrx/schematics": "17.2.0",
Expand Down
44 changes: 33 additions & 11 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Store } from '@ngrx/store';
import { TranslocoService, getBrowserLang } from '@ngneat/transloco';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { getBrowserLang } from '@ngneat/transloco';
import { tap } from 'rxjs/operators';
import { distinctUntilChanged, tap } from 'rxjs/operators';

import { getCurrentUserAction } from '@app/store/shikimori/actions/get-current-user.action';
import { selectLanguage } from '@app/store/settings/selectors/settings.selectors';
import { updateSettingsAction } from '@app/store/settings/actions/settings.actions';
import { selectLanguage, selectTheme } from '@app/store/settings/selectors/settings.selectors';
import { updateLanguageAction } from '@app/store/settings/actions/settings.actions';

@UntilDestroy()
@Component({
Expand All @@ -30,27 +30,49 @@ export class AppComponent implements OnInit {
private readonly _document: Document,
private readonly _store: Store,
private readonly _renderer: Renderer2,
private readonly _transloco: TranslocoService,
) {}

ngOnInit(): void {
this.initializeLocale();
this.initializeUser();
this.initTheme();
this.initLocale();
this.initUser();
}

initializeLocale(): void {
initLocale(): void {
this._store.select(selectLanguage).pipe(
untilDestroyed(this),
tap((storedLanguage) => {
const availableLangs = this._transloco.getAvailableLangs() as string[];
const browserLang = getBrowserLang();
const language = storedLanguage || browserLang || 'en';
const defaultLang = availableLangs.includes(browserLang)
? browserLang
: 'en';
const language = storedLanguage || defaultLang;

this._renderer.setAttribute(this._document.documentElement, 'lang', language);
this._store.dispatch(updateSettingsAction({ config: { language } }));
this._store.dispatch(updateLanguageAction({ language }));
}),
untilDestroyed(this),
).subscribe();
}

initTheme(): void {
this._store.select(selectTheme).pipe(
distinctUntilChanged(),
tap((theme) => {
const darkThemeClass = 'ion-palette-dark';

if (!theme || theme === 'dark') {
this._renderer.addClass(this._document.documentElement, darkThemeClass);
} else {
this._renderer.removeClass(this._document.documentElement, darkThemeClass);
}
}),
untilDestroyed(this),
).subscribe();
}

initializeUser(): void {
initUser(): void {
this._store.dispatch(getCurrentUserAction());
}
}
Loading

0 comments on commit 354e2b8

Please sign in to comment.