diff --git a/.github/workflows/package-and-publish.yml b/.github/workflows/package-and-publish.yml index 1bbe95db2..7a4a4e6d5 100644 --- a/.github/workflows/package-and-publish.yml +++ b/.github/workflows/package-and-publish.yml @@ -57,6 +57,10 @@ jobs: security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k actions $KEY_CHAIN security find-identity -v -p codesigning $KEY_CHAIN + - name: Get branch name for current workflow run + id: branch-name + uses: tj-actions/branch-names@v7 + - name: Build, package and publish env: TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }} @@ -67,6 +71,8 @@ jobs: GH_TOKEN: ${{ secrets.GH_TOKEN }} PUBLISH_REPO: ${{ vars.PUBLISH_REPO }} + BASE_URL: ${{ vars.BASE_URL }} + IS_PREVIEW: ${{ steps.branch-name.outputs.current_branch != 'master' }} run: | if [ -z "$PUBLISH_REPO" ]; then npm run electron:package:staging diff --git a/package.json b/package.json index bb68b7e23..2d1cca4df 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,9 @@ "build:mocked": "cross-env APP_ENV=test APP_MOCKED_CLIENT=1 npm run build:dev", "build:production": "webpack && bash ./deploy/copy_to_dist.sh", "web:release:production": "npm run update_version && npm i && npm run build:production && git add -A && git commit -a -m '[Build]' --no-verify && git push", - "electron:dev": "npm run electron:webpack && IS_ELECTRON=true concurrently -n main,renderer,electron \"npm run electron:webpack -- --watch\" \"npm run dev\" \"electronmon dist/electron\"", + "electron:dev": "npm run electron:webpack && IS_ELECTRON_BUILD=true concurrently -n main,renderer,electron \"npm run electron:webpack -- --watch\" \"npm run dev\" \"electronmon dist/electron\"", "electron:webpack": "cross-env APP_ENV=$ENV webpack --config ./webpack-electron.config.ts", - "electron:build": "IS_ELECTRON=true npm run build:$ENV && electron-builder install-app-deps && electron-rebuild && ENV=$ENV npm run electron:webpack", + "electron:build": "IS_ELECTRON_BUILD=true npm run build:$ENV && electron-builder install-app-deps && electron-rebuild && ENV=$ENV npm run electron:webpack", "electron:package": "npm run electron:build && npx rimraf dist-electron && electron-builder build --win --mac --linux --config src/electron/config.yml", "electron:package:staging": "ENV=staging npm run electron:package -- -p never", "electron:release:production": "ENV=production npm run electron:package -- -p always", diff --git a/public/electronVersion.txt b/public/electronVersion.txt new file mode 100644 index 000000000..a13e7b9c8 --- /dev/null +++ b/public/electronVersion.txt @@ -0,0 +1 @@ +10.0.0 diff --git a/src/components/common/AnimatedSticker.tsx b/src/components/common/AnimatedSticker.tsx index e156d31de..b2e41a21c 100644 --- a/src/components/common/AnimatedSticker.tsx +++ b/src/components/common/AnimatedSticker.tsx @@ -6,13 +6,13 @@ import React, { import type RLottieInstance from '../../lib/rlottie/RLottie'; -import { IS_ELECTRON } from '../../config'; import { requestMeasure } from '../../lib/fasterdom/fasterdom'; import { ensureRLottie, getRLottie } from '../../lib/rlottie/RLottie.async'; import buildClassName from '../../util/buildClassName'; import buildStyle from '../../util/buildStyle'; import generateUniqueId from '../../util/generateUniqueId'; import { hexToRgb } from '../../util/switchTheme'; +import { IS_ELECTRON } from '../../util/windowEnvironment'; import useColorFilter from '../../hooks/stickers/useColorFilter'; import useBackgroundMode, { isBackgroundModeActive } from '../../hooks/useBackgroundMode'; diff --git a/src/components/common/helpers/renderText.tsx b/src/components/common/helpers/renderText.tsx index 438b96e8a..040d7be65 100644 --- a/src/components/common/helpers/renderText.tsx +++ b/src/components/common/helpers/renderText.tsx @@ -4,7 +4,7 @@ import React from '../../../lib/teact/teact'; import type { TextPart } from '../../../types'; import { - IS_ELECTRON, PRODUCTION_URL, RE_LINK_TEMPLATE, RE_MENTION_TEMPLATE, + BASE_URL, IS_ELECTRON_BUILD, RE_LINK_TEMPLATE, RE_MENTION_TEMPLATE, } from '../../../config'; import EMOJI_REGEX from '../../../lib/twemojiRegex'; import buildClassName from '../../../util/buildClassName'; @@ -112,7 +112,8 @@ function replaceEmojis(textParts: TextPart[], size: 'big' | 'small', type: 'jsx' if (!code) { emojiResult.push(emoji); } else { - const src = `${IS_ELECTRON ? PRODUCTION_URL : '.'}/img-apple-${size === 'big' ? '160' : '64'}/${code}.png`; + const baseSrcUrl = IS_ELECTRON_BUILD ? BASE_URL : '.'; + const src = `${baseSrcUrl}/img-apple-${size === 'big' ? '160' : '64'}/${code}.png`; const className = buildClassName( 'emoji', size === 'small' && 'emoji-small', diff --git a/src/components/common/hooks/useAnimatedEmoji.ts b/src/components/common/hooks/useAnimatedEmoji.ts index 036919209..8b446b688 100644 --- a/src/components/common/hooks/useAnimatedEmoji.ts +++ b/src/components/common/hooks/useAnimatedEmoji.ts @@ -3,9 +3,9 @@ import { getActions } from '../../../global'; import type { ActiveEmojiInteraction } from '../../../global/types'; -import { IS_ELECTRON } from '../../../config'; import buildStyle from '../../../util/buildStyle'; import safePlay from '../../../util/safePlay'; +import { IS_ELECTRON } from '../../../util/windowEnvironment'; import { REM } from '../helpers/mediaDimensions'; import useLastCallback from '../../../hooks/useLastCallback'; diff --git a/src/components/left/LeftColumn.tsx b/src/components/left/LeftColumn.tsx index cb5925f3b..0de337df2 100644 --- a/src/components/left/LeftColumn.tsx +++ b/src/components/left/LeftColumn.tsx @@ -40,7 +40,8 @@ type StateProps = { nextSettingsScreen?: SettingsScreens; nextFoldersAction?: ReducerAction; isChatOpen: boolean; - isUpdateAvailable?: boolean; + isAppUpdateAvailable?: boolean; + isElectronUpdateAvailable?: boolean; isForumPanelOpen?: boolean; forumPanelChatId?: string; isClosingSearch?: boolean; @@ -73,7 +74,8 @@ function LeftColumn({ nextSettingsScreen, nextFoldersAction, isChatOpen, - isUpdateAvailable, + isAppUpdateAvailable, + isElectronUpdateAvailable, isForumPanelOpen, forumPanelChatId, isClosingSearch, @@ -491,7 +493,8 @@ function LeftColumn({ onSettingsScreenSelect={handleSettingsScreenSelect} onReset={handleReset} shouldSkipTransition={shouldSkipHistoryAnimations} - isUpdateAvailable={isUpdateAvailable} + isAppUpdateAvailable={isAppUpdateAvailable} + isElectronUpdateAvailable={isElectronUpdateAvailable} isForumPanelOpen={isForumPanelOpen} onTopicSearch={handleTopicSearch} /> @@ -537,7 +540,8 @@ export default memo(withGlobal( passcode: { hasPasscode, }, - isUpdateAvailable, + isAppUpdateAvailable, + isElectronUpdateAvailable, archiveSettings, } = global; @@ -556,7 +560,8 @@ export default memo(withGlobal( nextSettingsScreen, nextFoldersAction, isChatOpen, - isUpdateAvailable, + isAppUpdateAvailable, + isElectronUpdateAvailable, isForumPanelOpen, forumPanelChatId, isClosingSearch: tabState.globalSearch.isClosing, diff --git a/src/components/left/main/LeftMain.tsx b/src/components/left/main/LeftMain.tsx index b0689af2c..dd734996b 100644 --- a/src/components/left/main/LeftMain.tsx +++ b/src/components/left/main/LeftMain.tsx @@ -8,7 +8,7 @@ import type { FolderEditDispatch } from '../../../hooks/reducers/useFoldersReduc import type { SettingsScreens } from '../../../types'; import { LeftColumnContent } from '../../../types'; -import { IS_ELECTRON } from '../../../config'; +import { PRODUCTION_URL } from '../../../config'; import buildClassName from '../../../util/buildClassName'; import { IS_TOUCH_ENV } from '../../../util/windowEnvironment'; @@ -35,7 +35,8 @@ type OwnProps = { contactsFilter: string; shouldSkipTransition?: boolean; foldersDispatch: FolderEditDispatch; - isUpdateAvailable?: boolean; + isAppUpdateAvailable?: boolean; + isElectronUpdateAvailable?: boolean; isForumPanelOpen?: boolean; isClosingSearch?: boolean; onSearchQuery: (query: string) => void; @@ -58,7 +59,8 @@ const LeftMain: FC = ({ contactsFilter, shouldSkipTransition, foldersDispatch, - isUpdateAvailable, + isAppUpdateAvailable, + isElectronUpdateAvailable, isForumPanelOpen, onSearchQuery, onContentChange, @@ -68,6 +70,11 @@ const LeftMain: FC = ({ }) => { const { closeForumPanel } = getActions(); const [isNewChatButtonShown, setIsNewChatButtonShown] = useState(IS_TOUCH_ENV); + const [isElectronAutoUpdateEnabled, setIsElectronAutoUpdateEnabled] = useState(false); + + useEffect(() => { + window.electron?.getIsAutoUpdateEnabled().then(setIsElectronAutoUpdateEnabled); + }, []); const { shouldRenderForumPanel, handleForumPanelAnimationEnd, @@ -79,7 +86,7 @@ const LeftMain: FC = ({ const { shouldRender: shouldRenderUpdateButton, transitionClassNames: updateButtonClassNames, - } = useShowTransition(isUpdateAvailable); + } = useShowTransition(isAppUpdateAvailable || isElectronUpdateAvailable); const isMouseInside = useRef(false); @@ -120,7 +127,9 @@ const LeftMain: FC = ({ }); const handleUpdateClick = useLastCallback(() => { - if (IS_ELECTRON) { + if (!isElectronAutoUpdateEnabled) { + window.open(`${PRODUCTION_URL}/get`, '_blank', 'noopener'); + } else if (isElectronUpdateAvailable) { window.electron?.installUpdate(); } else { window.location.reload(); @@ -214,6 +223,7 @@ const LeftMain: FC = ({