Skip to content

Commit 77e8202

Browse files
committed
Not show upgrade alert if not installed from store
1 parent 48c0e77 commit 77e8202

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"Echart",
2020
"cond",
2121
"daterange",
22+
"dkdhhcbjijekmneelocdllcldcpmekmm",
23+
"fepjgblalcnepokjblgbgmapmlkgfahc",
2224
"emsp",
2325
"ensp"
2426
]

src/popup/components/footer/upgrade.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getLatestVersion } from "@src/api/version"
99
import packageInfo from "@src/package"
1010
import { t } from "@popup/locale"
1111
import { UPDATE_PAGE } from "@util/constant/url"
12-
import { IS_FIREFOX } from "@util/constant/environment"
12+
import { IS_FIREFOX, IS_FROM_STORE } from "@util/constant/environment"
1313

1414
function showUpgradeButton(latestVersion: string) {
1515
const upgrade = document.getElementById('upgrade-container')
@@ -34,4 +34,10 @@ function showUpgradeButton(latestVersion: string) {
3434
}
3535
}
3636

37-
getLatestVersion().then(latestVersion => latestVersion && packageInfo.version !== latestVersion && showUpgradeButton(latestVersion))
37+
getLatestVersion()
38+
.then(latestVersion => latestVersion
39+
&& packageInfo.version !== latestVersion
40+
// Must from store
41+
&& IS_FROM_STORE
42+
&& showUpgradeButton(latestVersion)
43+
)

src/util/constant/environment.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* https://opensource.org/licenses/MIT
66
*/
77

8+
import { CHROME_ID, EDGE_ID, FIREFOX_ID } from "./meta"
9+
810
const { userAgent } = navigator
911
let isFirefox = false
1012
let isChrome = false
@@ -33,3 +35,12 @@ export const IS_CHROME: boolean = isChrome
3335
* @since 0.8.0
3436
*/
3537
export const IS_OPERA: boolean = isOpera
38+
39+
const id = chrome.runtime.id
40+
41+
/**
42+
* @since 0.9.6
43+
*/
44+
export const IS_FROM_STORE = (isChrome && id === CHROME_ID)
45+
|| (isEdge && id === EDGE_ID)
46+
|| (isFirefox && id === FIREFOX_ID)

src/util/constant/meta.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright (c) 2022 Hengyang Zhang
3+
*
4+
* This software is released under the MIT License.
5+
* https://opensource.org/licenses/MIT
6+
*/
7+
8+
/**
9+
* @since 0.9.6
10+
*/
11+
export const CHROME_ID = "dkdhhcbjijekmneelocdllcldcpmekmm"
12+
13+
/**
14+
* @since 0.9.6
15+
*/
16+
export const FIREFOX_ID = "{a8cf72f7-09b7-4cd4-9aaa-7a023bf09916}"
17+
18+
/**
19+
* @since 0.9.6
20+
*/
21+
export const EDGE_ID = "fepjgblalcnepokjblgbgmapmlkgfahc"

0 commit comments

Comments
 (0)