Skip to content

Commit

Permalink
fix: wrong update url bug (#139)
Browse files Browse the repository at this point in the history
* fix update behavior

* Update common.ts

remove debug code
  • Loading branch information
LiuChangFreeman authored Jun 2, 2021
1 parent 1d96189 commit f01027e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hypertrons-crx",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"description": "Hypertrons Chrome Extension",
"license": "Apache",
Expand Down
6 changes: 4 additions & 2 deletions src/components/OptionsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const OptionsPage: React.FC = () => {
const [notificationId, setNotificationId] = useState(0);
const [notification, setNotification] = useState("");
const [updateStatus, setUpdateStatus] = useState(UpdateStatus.undefine);
const [updateUrl, setUpdateUrl] = useState("https://github.com/hypertrons/hypertrons-crx/releases");

const options: IChoiceGroupOption[] = [
{
Expand Down Expand Up @@ -98,8 +99,9 @@ const OptionsPage: React.FC = () => {
const checkUpdateManually = async () => {
setUpdateStatus(UpdateStatus.undefine);
setCheckingUpdate(true);
const [currentVersion, latestVersion] = await checkUpdate();
const [currentVersion, latestVersion,updateUrl] = await checkUpdate();
if (compareVersion(currentVersion, latestVersion) === -1) {
setUpdateUrl(updateUrl);
setUpdateStatus(UpdateStatus.yes);
}
else {
Expand Down Expand Up @@ -335,7 +337,7 @@ const OptionsPage: React.FC = () => {
isMultiline={false}
>
{getMessageI18n("options_update_btn_updateStatusYes")}
<Link href="https://github.com/hypertrons/hypertrons-crx/" target="_blank" underline>
<Link href={updateUrl} target="_blank" underline>
{getMessageI18n("options_update_btn_getUpdate")}
</Link>
</MessageBar>
Expand Down
10 changes: 9 additions & 1 deletion src/services/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ export const checkUpdate= async ()=>{
if(browserType==="Edge"){
latestVersion=updateInformation["edge"]["latest_version"];
updateUrl=updateInformation["edge"]["url"];
// edge can also install crx from chrome store
if("update_url" in details){
const update_url=details["update_url"]
if(update_url.search("google")!==-1){
latestVersion=updateInformation["chrome"]["latest_version"];
updateUrl=updateInformation["chrome"]["url"];
}
}
}
else{
latestVersion=updateInformation["chrome"]["latest_version"];
Expand All @@ -31,4 +39,4 @@ export const checkUpdate= async ()=>{
export const checkIsTokenAvailabe= async (token:string)=>{
const response = await fetch(`https://api.github.com/user`,{headers: { "Authorization":`token ${token}` }});
return await response.json();
}
}

0 comments on commit f01027e

Please sign in to comment.