Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Revert Migrate to Manifest V3 (MV3). see #23
Browse files Browse the repository at this point in the history
  • Loading branch information
razorman8669 committed Sep 8, 2021
1 parent a0880b1 commit 88ea31f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 54 deletions.
13 changes: 7 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"manifest_version": 3,
"manifest_version": 2,
"name": "Purse: Shop with Bitcoin (Beta)",
"description": "Get 5-33% off anything on Amazon with Bitcoin and Bitcoin Cash",
"version": "1.2.0",
Expand All @@ -9,14 +9,17 @@
"128": "icons/icon128.png"
},
"background": {
"service_worker": "event.js"
"scripts": [
"event.js"
],
"persistent": true
},
"externally_connectable": {
"matches": [
"https://purse.io/*"
]
},
"action": {
"browser_action": {
"default_title": "Purse: Shop with Bitcoin",
"default_popup": "popup.html"
},
Expand Down Expand Up @@ -45,7 +48,5 @@
]
}
],
"permissions": [
"storage"
]
"permissions": []
}
51 changes: 23 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"react-redux": "^7.2.5",
"redux": "^4.1.1",
"redux-thunk": "^2.2.0",
"reduxed-chrome-storage": "^2.4.7",
"styled-components": "^5.3.1",
"webext-redux": "^2.1.7"
},
Expand Down
12 changes: 6 additions & 6 deletions src/event/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function fetchUpdateList(originalAction) {
}).then(baseHandler(dispatch))
.then(async (res) => {
const text = (res.items.length) ? res.items.length.toString() : '' ;
chrome.action.setBadgeText({ text });
await dispatch(addCartItems(res.items))
chrome.browserAction.setBadgeText({ text });
await dispatch(addCartItems(res.items));
})
.catch(console.log);
};
Expand Down Expand Up @@ -57,7 +57,7 @@ function fetchCartItems(originalAction) {
if (res[0] && res[0].items) {
dispatch(addCartItems(res[0].items));
const text = (res[0].items.length) ? res[0].items.length.toString() : '' ;
chrome.action.setBadgeText({ text });
chrome.browserAction.setBadgeText({ text });
}
})
.catch(console.log);
Expand Down Expand Up @@ -110,13 +110,13 @@ function addToken(token) {

function baseHandler(dispatch) {
return function(res) {
if (res.status == 401) {
chrome.action.setBadgeText({text: ''}); // cart appears empty
if (res.status === 401) {
chrome.browserAction.setBadgeText({text: ''}); // cart appears empty
dispatch(addToken(null)); // logout
throw new Error("Logged out");
}
return res.json();
}
};
}

export { addUserInfo, addCartItems, getUserInfo, getCartItems, addToken,
Expand Down
23 changes: 10 additions & 13 deletions src/event/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { createStore, applyMiddleware } from 'redux';
import storeCreatorFactory from 'reduxed-chrome-storage';
import rootReducer from './reducers';
import thunkMiddleware from 'redux-thunk';
import { wrapStore, alias } from 'webext-redux';
import aliases from './aliases';

const options = {
createStore: createStore,
};
const asyncStoreCreator = storeCreatorFactory(options);
const store = createStore(
rootReducer,
applyMiddleware(
alias(aliases),
thunkMiddleware
)
);

asyncStoreCreator(rootReducer, applyMiddleware(alias(aliases), thunkMiddleware))
.then((store) => {
setTimeout(() => {
wrapStore(store, {
portName: 'buywithbtc',
});
});
});
wrapStore(store, {
portName: 'buywithbtc'
});

0 comments on commit 88ea31f

Please sign in to comment.