-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from pierroberto/donate
Donate button
- Loading branch information
Showing
19 changed files
with
213 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,64 @@ | ||
|
||
//BOOKMARKS ACTIONS | ||
export const refreshBookmark = (data, time) => ({ | ||
type: 'REFRESH', | ||
type: "REFRESH", | ||
urlList: data, | ||
expiry: time | ||
}) | ||
}); | ||
|
||
export const deleteAllBookmark = () => ({ | ||
type: 'DELETE-ALL', | ||
}) | ||
type: "DELETE-ALL" | ||
}); | ||
|
||
export const deleteOneBookmark = (url) => ({ | ||
type: 'DELETE-ONE', | ||
export const deleteOneBookmark = url => ({ | ||
type: "DELETE-ONE", | ||
url: url | ||
}) | ||
}); | ||
|
||
export const addBookmark = (url) => ({ | ||
type: 'ADD', | ||
export const addBookmark = url => ({ | ||
type: "ADD", | ||
urlList: url, | ||
expiry: new Date().getTime() | ||
}) | ||
}); | ||
|
||
export const addFromButton = (flag) => ({ | ||
type: 'DELETE-ONE', | ||
export const addFromButton = flag => ({ | ||
type: "DELETE-ONE", | ||
addFromButton: flag | ||
}) | ||
}); | ||
|
||
export const searchBookmark = (text) => ({ | ||
type: 'SEARCH', | ||
export const searchBookmark = text => ({ | ||
type: "SEARCH", | ||
textSearched: text | ||
}) | ||
}); | ||
|
||
export const emptySearch = () => ({ | ||
type: 'EMPTY-SEARCH' | ||
}) | ||
type: "EMPTY-SEARCH" | ||
}); | ||
|
||
//SETTINGS actions | ||
|
||
export const toggleButton = (flag) => ({ | ||
type: 'TOGGLE-BUTTON', | ||
export const toggleButton = flag => ({ | ||
type: "TOGGLE-BUTTON", | ||
toggleButton: flag | ||
}) | ||
}); | ||
|
||
export const expireDate = (date) => ({ | ||
type: 'UPDATE-DATE', | ||
export const expireDate = date => ({ | ||
type: "UPDATE-DATE", | ||
expireDate: date | ||
}) | ||
}); | ||
|
||
export const toggleButtonHistory = (flag) => ({ | ||
type: 'TOGGLE-BUTTON-HISTORY', | ||
export const toggleButtonHistory = flag => ({ | ||
type: "TOGGLE-BUTTON-HISTORY", | ||
toggleButtonHistory: flag | ||
}) | ||
|
||
}); | ||
|
||
// ANIMATION ACTIONS | ||
|
||
export const buttonCog = (flag) => ({ | ||
type: 'TOGGLE-COG', | ||
export const buttonCog = flag => ({ | ||
type: "TOGGLE-COG", | ||
buttonCog: flag | ||
}) | ||
}); | ||
|
||
export const toggleSearch = (classValue) => ({ | ||
type: 'TOGGLE-SEARCH', | ||
export const toggleSearch = classValue => ({ | ||
type: "TOGGLE-SEARCH", | ||
toggleSearch: classValue | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import store from './store'; | ||
import store from "./store"; | ||
|
||
store.subscribe (() => { | ||
store.getState().bookmark.tabs.map(infoTab => { | ||
chrome.alarms.create(infoTab.tab[0].url, {when: infoTab.expiry + store.getState().settings.expireDate}) | ||
store.subscribe(() => { | ||
store.getState().bookmark.tabs.map(infoTab => { | ||
chrome.alarms.create(infoTab.tab[0].url, { | ||
when: infoTab.expiry + store.getState().settings.expireDate | ||
}); | ||
}); | ||
}); | ||
|
||
chrome.alarms.onAlarm.addListener(function (data) { | ||
chrome.alarms.onAlarm.addListener(function(data) { | ||
const elementExpired = store.getState().bookmark.tabs.filter(el => { | ||
return el.tab[0].url === data.name | ||
}) | ||
store.dispatch({type:'EXPIRY', url: elementExpired[0].tab[0].url}) | ||
}) | ||
return el.tab[0].url === data.name; | ||
}); | ||
store.dispatch({ type: "EXPIRY", url: elementExpired[0].tab[0].url }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
export const saveState = (state) => { | ||
export const saveState = state => { | ||
try { | ||
const serializedState = JSON.stringify(state); | ||
localStorage.setItem('state', serializedState); | ||
localStorage.setItem("state", serializedState); | ||
} catch (e) { | ||
console.error('Error saving state', e); | ||
console.error("Error saving state", e); | ||
} | ||
} | ||
}; | ||
|
||
export const loadState = () => { | ||
try { | ||
const serializedState = localStorage.getItem('state'); | ||
if(serializedState === null) { | ||
const serializedState = localStorage.getItem("state"); | ||
if (serializedState === null) { | ||
return undefined; | ||
} | ||
return JSON.parse(serializedState); | ||
} catch (e) { | ||
|
||
} | ||
} | ||
} catch (e) {} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import {combineReducers} from 'redux'; | ||
import bookmark from './reducers/bookmarks'; | ||
import settings from './reducers/settings'; | ||
import animation from './reducers/animations'; | ||
import { combineReducers } from "redux"; | ||
import bookmark from "./reducers/bookmarks"; | ||
import settings from "./reducers/settings"; | ||
import animation from "./reducers/animations"; | ||
|
||
export default combineReducers ({ | ||
bookmark : bookmark, | ||
settings : settings, | ||
animation: animation, | ||
}) | ||
export default combineReducers({ | ||
bookmark: bookmark, | ||
settings: settings, | ||
animation: animation | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
|
||
const defaultState = { | ||
buttonCog: false | ||
} | ||
}; | ||
|
||
const animation = (state=defaultState,action) => { | ||
const animation = (state = defaultState, action) => { | ||
switch (action.type) { | ||
case 'TOGGLE-COG': | ||
case "TOGGLE-COG": | ||
return { | ||
...state, | ||
buttonCog: action.buttonCog | ||
} | ||
case 'TOGGLE-SEARCH': | ||
}; | ||
case "TOGGLE-SEARCH": | ||
return { | ||
...state, | ||
toggleSearch: action.toggleSearch | ||
} | ||
}; | ||
default: | ||
return state; | ||
} | ||
|
||
} | ||
}; | ||
|
||
export default animation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
|
||
const defaultState = { | ||
button: false, | ||
buttonHystory: true, | ||
expireDate: 86400000 // 1 day | ||
}; | ||
|
||
} | ||
|
||
const settings = (state=defaultState,action) => { | ||
const settings = (state = defaultState, action) => { | ||
switch (action.type) { | ||
case 'TOGGLE-BUTTON': | ||
case "TOGGLE-BUTTON": | ||
return { | ||
...state, | ||
button: action.toggleButton | ||
} | ||
case 'TOGGLE-BUTTON-HISTORY': | ||
}; | ||
case "TOGGLE-BUTTON-HISTORY": | ||
return { | ||
...state, | ||
buttonHistory: action.toggleButtonHistory | ||
} | ||
case 'UPDATE-DATE': | ||
}; | ||
case "UPDATE-DATE": | ||
return { | ||
...state, | ||
expireDate: action.expireDate | ||
} | ||
|
||
}; | ||
} | ||
return state | ||
} | ||
return state; | ||
}; | ||
|
||
export default settings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import { applyMiddleware, createStore } from 'redux' | ||
import { wrapStore, alias } from 'react-chrome-redux' | ||
import { createLogger } from 'redux-logger' | ||
import thunk from 'redux-thunk' | ||
import reducer from './reducers' | ||
import throttle from 'lodash/throttle'; | ||
import { saveState, loadState } from './localStorage'; | ||
const store = createStore( | ||
reducer, | ||
loadState() | ||
); | ||
import { applyMiddleware, createStore } from "redux"; | ||
import { wrapStore, alias } from "react-chrome-redux"; | ||
import { createLogger } from "redux-logger"; | ||
import thunk from "redux-thunk"; | ||
import reducer from "./reducers"; | ||
import throttle from "lodash/throttle"; | ||
import { saveState, loadState } from "./localStorage"; | ||
const store = createStore(reducer, loadState()); | ||
|
||
store.subscribe(throttle(() => { | ||
saveState({ | ||
bookmark: store.getState().bookmark, | ||
settings: store.getState().settings, | ||
animation: store.getState().animation | ||
}) | ||
}), 1000); | ||
store.subscribe( | ||
throttle(() => { | ||
saveState({ | ||
bookmark: store.getState().bookmark, | ||
settings: store.getState().settings, | ||
animation: store.getState().animation | ||
}); | ||
}), | ||
1000 | ||
); | ||
|
||
wrapStore(store, { | ||
portName: 'COUNTING', | ||
}) | ||
portName: "COUNTING" | ||
}); | ||
|
||
export default store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.