Skip to content

Commit

Permalink
Merge pull request #98 from jeongm-in/refactorings-before-release
Browse files Browse the repository at this point in the history
Refactorings before release
  • Loading branch information
Bartleby2718 authored Jul 11, 2019
2 parents c59d606 + 2593e4b commit 57349f3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
5 changes: 4 additions & 1 deletion public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"saveSuccessful": {
"message": "Page was saved successfully."
},
"optionsPage": {
"message": "WebMark Options"
},
"optionsGeneralCardTitle": {
"message": "General Settings"
},
Expand All @@ -41,4 +44,4 @@
"optionsAboutCardContentTeamLinkTitle": {
"message": "Homepage"
}
}
}
5 changes: 4 additions & 1 deletion public/_locales/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"saveSuccessful": {
"message": "성공적으로 저장했어요."
},
"optionsPage": {
"message": "웹마크 설정"
},
"optionsGeneralCardTitle": {
"message": "일반 설정"
},
Expand All @@ -41,4 +44,4 @@
"optionsAboutCardContentTeamLinkTitle": {
"message": "홈페이지"
}
}
}
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_extensionName__",
"version": "0.1.0",
"version": "1.0.0",
"description": "__MSG_extensionDescription__",
"default_locale": "en",
"permissions": [
Expand Down
2 changes: 2 additions & 0 deletions src/Option.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import OptionPage from './components/OptionPage';
/*global chrome*/

document.title = chrome.i18n.getMessage('optionsPage');
document.body.style.backgroundColor = "#DDD";

ReactDOM.render(
Expand Down
4 changes: 0 additions & 4 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@ chrome.runtime.onInstalled.addListener(
[FOLDER_ID_KEY],
(result) => {
if (Object.keys(result).length === 0) {
console.log('webmarkFolderId not found.');
createWebmarkFolder();
}
else {
console.log('webmarkFolderId found.');
let webmarkFolderId: string = result[FOLDER_ID_KEY];
chrome.bookmarks.get(
webmarkFolderId,
() => {
if (chrome.runtime.lastError) {
console.log('webmark folder not found.');
createWebmarkFolder();
chrome.storage.sync.remove(FOLDER_ID_KEY);
return;
}
console.log('webmark folder found.');
}
);
};
Expand Down
17 changes: 0 additions & 17 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@ export let saveClicked = (): void => {
[FOLDER_ID_KEY],
function (result) {
if (Object.keys(result).length === 0) {
console.log('webmarkFolderId not found.');
createWebmarkFolder(saveClicked);
}
else {
console.log('webmarkFolderId found.');
let webmarkFolderId: string = result![FOLDER_ID_KEY];
chrome.bookmarks.get(
webmarkFolderId,
function () {
if (chrome.runtime.lastError) {
console.log('webmark folder not found.');
createWebmarkFolder(saveClicked);
chrome.storage.sync.remove(FOLDER_ID_KEY);
return;
}
console.log('webmark folder found.');
getCurrentUrlAndSave(webmarkFolderId);
}
);
Expand All @@ -35,24 +31,20 @@ export let loadClicked = (): void => {
[FOLDER_ID_KEY],
function (result) {
if (Object.keys(result).length === 0) {
console.log('webmarkFolderId not found.');
createWebmarkFolder();
showNotice(FOLDER_EMPTY);
return;
}
console.log('webmarkFolderId found.');
let webmarkFolderId: string = result![FOLDER_ID_KEY];
chrome.bookmarks.get(
webmarkFolderId,
function () {
if (chrome.runtime.lastError) {
console.log('webmark folder not found.');
createWebmarkFolder();
showNotice(FOLDER_EMPTY);
chrome.storage.sync.remove(FOLDER_ID_KEY);
return;
}
console.log('webmark folder found.');
loadRandomUrlFromFolder(webmarkFolderId);
}
);
Expand All @@ -70,7 +62,6 @@ export let createWebmarkFolder = (callback?: () => void): void => {
{
[FOLDER_ID_KEY]: newFolder.id,
}, function () {
console.log('set webmarkFolderId to ' + newFolder.id);
if (callback !== undefined) {
callback();
}
Expand Down Expand Up @@ -115,7 +106,6 @@ let saveIfNotAlreadyThere = (webmarkFolderId: string, url: string, title: string
showNotice(PAGE_ALREADY_EXISTS);
}
else {
console.log('Same page not found in the folder.');
saveWithConfidence(webmarkFolderId, url, title);
}
}
Expand All @@ -131,7 +121,6 @@ let saveWithConfidence = (webmarkFolderId: string, url: string, title: string):
},
() => {
showNotice(SAVE_SUCCESSFUL);
console.log(url + ' saved to folder.');
}
);
}
Expand Down Expand Up @@ -189,12 +178,8 @@ let showNotice = (title: string, message: string = ''): void => {
'title': title, // required
'message': message, // required
'eventTime': Date.now(),
},
function (notificationId: string) {
console.log(notificationId + ' notification sent.');
}
);
console.log('Showed message ("' + title + '") to user.');
}

let loadInCurrentTab = (url: string): void => {
Expand All @@ -203,7 +188,6 @@ let loadInCurrentTab = (url: string): void => {
'url': url,
}
);
console.log('Opened ' + url + ' in the current tab.');
}

let loadInNewTab = (url: string): void => {
Expand All @@ -212,5 +196,4 @@ let loadInNewTab = (url: string): void => {
'url': url,
}
);
console.log('Opened ' + url + ' in a new tab.');
}

0 comments on commit 57349f3

Please sign in to comment.