From 11b8d0c318ef46c3293200439b315976c2453483 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Tue, 30 Sep 2025 16:52:23 +0200 Subject: [PATCH] Version Notification: Prevent duplicates after release (#6284) --- src/@types/global.d.ts | 1 + src/config.ts | 1 - src/global/actions/ui/messages.ts | 3 +-- webpack.config.ts | 9 ++++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index cb2531ca1..b1e0e496e 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -4,6 +4,7 @@ declare module '*.module.scss'; declare const APP_VERSION: string; declare const APP_REVISION: string; +declare const CHANGELOG_DATETIME: number | undefined; declare namespace React { interface HTMLAttributes { diff --git a/src/config.ts b/src/config.ts index 977b2f71c..19e3d49a0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -8,7 +8,6 @@ import type { export const APP_CODE_NAME = 'A'; export const APP_NAME = process.env.APP_NAME || `Telegram Web ${APP_CODE_NAME}`; -export const RELEASE_DATETIME = process.env.RELEASE_DATETIME; export const PRODUCTION_HOSTNAME = 'web.telegram.org'; export const PRODUCTION_URL = 'https://web.telegram.org/a'; diff --git a/src/global/actions/ui/messages.ts b/src/global/actions/ui/messages.ts index a9886cc4a..0f42bf6fd 100644 --- a/src/global/actions/ui/messages.ts +++ b/src/global/actions/ui/messages.ts @@ -8,7 +8,6 @@ import { type ActiveDownloads, FocusDirection } from '../../../types'; import { ANIMATION_END_DELAY, - RELEASE_DATETIME, SCROLL_MAX_DURATION, SERVICE_NOTIFICATIONS_USER_ID, } from '../../../config'; @@ -780,7 +779,7 @@ addActionHandler('openTodoListModal', (global, actions, payload): ActionReturnTy addTabStateResetterAction('closeTodoListModal', 'todoListModal'); addActionHandler('checkVersionNotification', (global, actions): ActionReturnType => { - if (RELEASE_DATETIME && Date.now() > Number(RELEASE_DATETIME) + VERSION_NOTIFICATION_DURATION) { + if (CHANGELOG_DATETIME && Date.now() > CHANGELOG_DATETIME + VERSION_NOTIFICATION_DURATION) { return; } diff --git a/webpack.config.ts b/webpack.config.ts index 135de3e80..3c43a1c69 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -3,6 +3,7 @@ import 'dotenv/config'; import WatchFilePlugin from '@mytonwallet/webpack-watch-file-plugin'; import StatoscopeWebpackPlugin from '@statoscope/webpack-plugin'; +import { statSync } from 'fs'; import { GitRevisionPlugin } from 'git-revision-webpack-plugin'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; @@ -48,6 +49,8 @@ const CSP = ` form-action 'none';` .replace(/\s+/g, ' ').trim(); +const CHANGELOG_PATH = path.resolve(__dirname, 'src/versionNotification.txt'); + export default function createConfig( _: any, { mode = 'production' }: { mode: 'none' | 'development' | 'production' }, @@ -206,7 +209,6 @@ export default function createConfig( // eslint-disable-next-line no-null/no-null APP_NAME: null, APP_TITLE, - RELEASE_DATETIME: Date.now(), TELEGRAM_API_ID: undefined, TELEGRAM_API_HASH: undefined, // eslint-disable-next-line no-null/no-null @@ -221,6 +223,11 @@ export default function createConfig( const shouldDisplayOnlyCommit = APP_ENV === 'staging' || !branch || branch === 'HEAD'; return JSON.stringify(shouldDisplayOnlyCommit ? commit : `${branch}#${commit}`); }, mode === 'development' ? true : []), + CHANGELOG_DATETIME: DefinePlugin.runtimeValue(() => { + return JSON.stringify(statSync(CHANGELOG_PATH, { throwIfNoEntry: false })?.mtime.getTime()); + }, { + fileDependencies: [CHANGELOG_PATH], + }), }), new ProvidePlugin({ Buffer: ['buffer', 'Buffer'],