Better support for non-production envs

This commit is contained in:
Alexander Zinchuk 2021-06-20 16:50:42 +03:00
parent f329217307
commit 71e90c7b64
4 changed files with 23 additions and 16 deletions

View File

@ -52,6 +52,7 @@ type DispatchProps = Pick<GlobalActions, (
const ANIMATION_LEVEL_OPTIONS = [0, 1, 2];
const PRODUCTION_HOSTNAME = 'web.telegram.org';
const LEGACY_VERSION_URL = 'https://web.telegram.org/?legacy=1';
const WEBK_VERSION_URL = 'https://web.telegram.org/k/';
const PERMANENT_VERSION_KEY = 'kz_version';
@ -101,6 +102,8 @@ const LeftMainHeader: FC<OwnProps & StateProps & DispatchProps> = ({
}, 0);
}, [hasMenu, chatsById]);
const withOtherVersions = window.location.hostname === PRODUCTION_HOSTNAME;
const MainButton: FC<{ onTrigger: () => void; isOpen?: boolean }> = useMemo(() => {
return ({ onTrigger, isOpen }) => (
<Button
@ -229,19 +232,23 @@ const LeftMainHeader: FC<OwnProps & StateProps & DispatchProps> = ({
>
Report Bug
</MenuItem>
<MenuItem
icon="char-K"
href={WEBK_VERSION_URL}
onClick={handleSwitchToWebK}
>
Switch to K Version
</MenuItem>
<MenuItem
icon="char-W"
href={LEGACY_VERSION_URL}
>
Switch to Old Version
</MenuItem>
{withOtherVersions && (
<>
<MenuItem
icon="char-K"
href={WEBK_VERSION_URL}
onClick={handleSwitchToWebK}
>
Switch to K Version
</MenuItem>
<MenuItem
icon="char-W"
href={LEGACY_VERSION_URL}
>
Switch to Old Version
</MenuItem>
</>
)}
</DropdownMenu>
<SearchInput
inputId="telegram-search-input"

View File

@ -1,7 +1,7 @@
export const PAGE_TITLE = 'Telegram';
export const INACTIVE_MARKER = ' [Inactive]';
export const APP_NAME = 'Telegram WebZ';
export const APP_NAME = process.env.APP_NAME || 'Telegram WebZ';
export const APP_VERSION = process.env.APP_VERSION || 'dev';
export const DEBUG = (

View File

@ -141,7 +141,7 @@ async function focusChatMessage(client: WindowClient, data: { chatId?: number; m
}
export function handleNotificationClick(e: NotificationEvent) {
const appUrl = process.env.APP_URL!;
const appUrl = self.location.href.replace('serviceWorker.js', '');
e.notification.close(); // Android needs explicit close.
const { data } = e.notification;
const notifyClients = async () => {

View File

@ -103,9 +103,9 @@ module.exports = (env = {}, argv = {}) => {
ignoreOrder: true,
}),
new EnvironmentPlugin({
APP_NAME: 'Telegram WebZ',
APP_VERSION: 'dev',
APP_ENV: 'production',
APP_URL: 'https://web.telegram.org/z/',
TELEGRAM_T_API_ID: '',
TELEGRAM_T_API_HASH: '',
}),