Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Existing List Properties and New List Preset #884

Merged
merged 8 commits into from
Jul 10, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
cleanups
juliepanda committed Jul 5, 2017
commit 278d80185e4cc11923ea2da1e8470f566ff3b66d
9 changes: 6 additions & 3 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -13,11 +13,14 @@
// import 'file-loader?name=[name].[ext]!../.htaccess';

// Check for ServiceWorker support before trying to install it
// if (process.env.NODE_ENV === 'production') {
// if ('serviceWorker' in navigator) {
// if (process.env.NODE_ENV === 'development') {
// if ('serviceWorker' in navigator && 'PushManager' in window) {
// navigator.serviceWorker.register('/serviceworker.js')
// .then(
// registration => console.log('ServiceWorker registration successful with scope: ', registration.scope),
// registration => {
// console.log('ServiceWorker registration successful with scope: ', registration.scope);
// window.swRegistration = registration;
// },
// err => console.log('ServiceWorker registration failed: ', err)
// ).catch(err => {
// // Registration failed
16 changes: 4 additions & 12 deletions js/components/Lists/actions.js
Original file line number Diff line number Diff line change
@@ -111,9 +111,7 @@ export function fetchLists() {
dispatch(requestLists());
return api.get(`/lists?limit=${PAGE_LIMIT}&offset=${OFFSET}&order=-Created`)
.then(response => {
const res = normalize(response, {
data: arrayOf(listSchema),
});
const res = normalize(response, {data: arrayOf(listSchema)});
const newOffset = response.data.length < PAGE_LIMIT ? null : OFFSET + PAGE_LIMIT;
return dispatch(receiveLists(res.entities.lists, res.result.data, newOffset));
})
@@ -129,9 +127,7 @@ export function fetchPublicLists() {
dispatch(requestLists());
return api.get(`/lists/public?limit=${PAGE_LIMIT}&offset=${OFFSET}`)
.then(response => {
const res = normalize(response, {
data: arrayOf(listSchema),
});
const res = normalize(response, {data: arrayOf(listSchema)});
const newOffset = response.data.length < PAGE_LIMIT ? null : OFFSET + PAGE_LIMIT;
return dispatch({
type: listConstant.RECEIVE_MULTIPLE,
@@ -175,9 +171,7 @@ export function fetchTagLists(tagQuery) {
dispatch(requestLists());
return api.get(`/lists?q=tag:${tagQuery}&limit=${PAGE_LIMIT}&offset=${OFFSET}`)
.then(response => {
const res = normalize(response, {
data: arrayOf(listSchema),
});
const res = normalize(response, {data: arrayOf(listSchema)});
const newOffset = response.data.length < PAGE_LIMIT ? null : OFFSET + PAGE_LIMIT;
return dispatch({
type: listConstant.RECEIVE_MULTIPLE,
@@ -200,9 +194,7 @@ export function fetchArchivedLists() {
dispatch(requestLists());
return api.get(`/lists/archived?limit=${PAGE_LIMIT}&offset=${OFFSET}&order=-Created`)
.then(response => {
const res = normalize(response, {
data: arrayOf(listSchema),
});
const res = normalize(response, {data: arrayOf(listSchema)});
const newOffset = response.data.length < PAGE_LIMIT ? null : OFFSET + PAGE_LIMIT;
return dispatch({
type: listConstant.RECEIVE_MULTIPLE,
60 changes: 60 additions & 0 deletions js/components/UserProfile/BasicSettings.jsx
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import {ToggleableEditInputHOC, ToggleableEditInput} from '../ToggleableEditInpu
import {fromJS, is} from 'immutable';
import {grey500} from 'material-ui/styles/colors';
import RaisedButton from 'material-ui/RaisedButton';
import Toggle from 'material-ui/Toggle';

import {actions as loginActions} from 'components/Login';

@@ -43,9 +44,26 @@ class BasicSettings extends Component {
this.state = {
immuperson: fromJS(this.props.person),
newPerson: fromJS(this.props.person),
notifySubscribed: false
};
// this.onToggle = this.onToggle.bind(this);
// this.onSubscribe = this.onSubscribe.bind(this);
// this.onUnsubscribe = this.onUnsubscribe.bind(this);
}

// componentWillMount() {
// navigator.serviceWorker.ready.then(swRegistration => {
// swRegistration.pushManager.getSubscription()
// .then(subscription => {
// const isSubscribed = !(subscription === null);
// console.log('subscription');
// console.log(isSubscribed);
// this.setState({notifySubscribed: isSubscribed});
// });
// window.swRegistration = swRegistration;
// });
// }

componentWillUnmount() {
if (!is(this.state.immuperson, this.state.newPerson)) {
const newPerson = this.state.newPerson;
@@ -59,6 +77,38 @@ class BasicSettings extends Component {
}
}

// onToggle(e, isToggled) {
// if (isToggled) this.onSubscribe();
// else this.onUnsubscribe();
// }

// onSubscribe() {
// window.swRegistration.pushManager
// .subscribe({userVisibleOnly: true})
// .then(subscription => {
// console.log(subscription);
// this.setState({notifySubscribed: true});
// })
// .catch(e => {
// console.log('Push Notify subscription denied by user');
// });
// }

// onUnsubscribe() {
// window.swRegistration.pushManager.getSubscription()
// .then(subscription => {
// if (!subscription) {
// this.setState({notifySubscribed: false});
// }
// subscription.unsubscribe()
// .then(_ => this.setState({notifySubscribed: false}));
// })
// .then(e => {
// console.log('failed to subscribe');
// });
// }


render() {
const {person} = this.props;
const state = this.state;
@@ -105,6 +155,16 @@ class BasicSettings extends Component {
/>}
</div>
</div>
{/*
<div className='row vertical-center' style={inputHeight}>
<div className='large-4 medium-5 columns'>
<span style={spanStyle}>Browser Notifications</span>
</div>
<div className='large-6 medium-7 columns'>
<Toggle toggled={state.notifySubscribed} onToggle={this.onToggle} />
</div>
</div>
*/}
</div>
</div>
);
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -30,5 +30,5 @@
"start_url": "index.html",
"display": "standalone",
"orientation": "portrait",
"background_color": "#FFFFFF"
"background_color": "#FFFFFF",
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -6,13 +6,14 @@
"alertifyjs": "^1.10.0",
"axios": "^0.9.1",
"classnames": "^2.2.5",
"draft-convert": "^1.4.3",
"draft-convert": "^1.4.7",
"draft-js": "^0.10.0",
"es6-promise": "^4.0.5",
"fontfaceobserver": "^1.5.1",
"fuse.js": "^2.6.2",
"fuzzy": "^0.1.1",
"hopscotch": "^0.2.6",
"ifvisible.js": "^1.0.6",
"immutability-helper": "^2.2.2",
"immutable": "^3.8.1",
"install": "^0.8.1",
@@ -25,7 +26,6 @@
"moment": "^2.14.1",
"moment-timezone": "^0.5.9",
"normalizr": "^2.2.1",
"npm": "^3.10.6",
"numbro": "^1.9.3",
"object-assign": "^4.1.0",
"pikaday": "^1.4.0",
@@ -70,8 +70,7 @@
"regression": "^1.2.1",
"sanitize-html": "^1.14.1",
"tlds": "^1.157.0",
"validator": "^5.5.0",
"zeroclipboard": "^2.2.0"
"validator": "^5.5.0"
},
"devDependencies": {
"appcache-webpack-plugin": "^1.2.0",
155 changes: 97 additions & 58 deletions serviceworker.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,100 @@
var CACHE_NAME = 'react-boilerplate-cache-v1';
// The files we want to cache
var urlsToCache = [
// '/',
'/css/main.css'
// '/js/bundle.js'
];

// Set the callback for the install step
self.addEventListener('install', function(event) {
// Perform install steps
self.addEventListener('push', function(event) {
console.log('Received a push message', event);

// var title = 'Yay a message.';
// var body = 'We have received a push message.';
// var tag = 'simple-push-demo-notification-tag';

// event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
console.log('Opened cache');
return cache.addAll(urlsToCache);
});
});
// self.registration.showNotification(title, {
// body: body,
// tag: tag
// })
// );
function log(argument) {
console.log(argument);
}

function notification(args) {
var notifications = JSON.parse(args.data);
for (var i = notifications.length - 1; i >= 0; i--) {
self.registration.showNotification('Tabulae Notification', {
body: notifications[i].message,
});
}
}

// Set the callback when the files get fetched
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
// Cached files available, return those
if (response) {
return response;
}

// IMPORTANT: Clone the request. A request is a stream and
// can only be consumed once. Since we are consuming this
// once by cache and once by the browser for fetch, we need
// to clone the response
var fetchRequest = event.request.clone();

// Start request again since there are no files in the cache
return fetch(fetchRequest).then(function(response) {
// If response is invalid, throw error
if (!response || response.status !== 200 || response.type !== 'basic') {
return response;
}

// IMPORTANT: Clone the response. A response is a stream
// and because we want the browser to consume the response
// as well as the cache consuming the response, we need
// to clone it so we have 2 stream.
var responseToCache = response.clone();

// Otherwise cache the downloaded files
caches.open(CACHE_NAME)
.then(function(cache) {
cache.put(event.request, responseToCache);
});

// And return the network response
return response;
}
);
})
);
event.waitUntil(
fetch('/users/me/token')
.then(response => {
const channel = new goog.appengine.Channel(response.token);
const socket = channel.open();
socket.onopen = log;
socket.onmessage = args => notification(args);
socket.onerror = log;
socket.onclose = log;
}));
});


// var CACHE_NAME = 'react-boilerplate-cache-v1';
// // The files we want to cache
// var urlsToCache = [
// // '/',
// '/css/main.css'
// // '/js/bundle.js'
// ];

// // Set the callback for the install step
// self.addEventListener('install', function(event) {
// // Perform install steps
// // event.waitUntil(
// caches.open(CACHE_NAME)
// .then(function(cache) {
// console.log('Opened cache');
// return cache.addAll(urlsToCache);
// });
// });

// // Set the callback when the files get fetched
// self.addEventListener('fetch', function(event) {
// event.respondWith(
// caches.match(event.request)
// .then(function(response) {
// // Cached files available, return those
// if (response) {
// return response;
// }

// // IMPORTANT: Clone the request. A request is a stream and
// // can only be consumed once. Since we are consuming this
// // once by cache and once by the browser for fetch, we need
// // to clone the response
// var fetchRequest = event.request.clone();

// // Start request again since there are no files in the cache
// return fetch(fetchRequest).then(function(response) {
// // If response is invalid, throw error
// if (!response || response.status !== 200 || response.type !== 'basic') {
// return response;
// }

// // IMPORTANT: Clone the response. A response is a stream
// // and because we want the browser to consume the response
// // as well as the cache consuming the response, we need
// // to clone it so we have 2 stream.
// var responseToCache = response.clone();

// // Otherwise cache the downloaded files
// caches.open(CACHE_NAME)
// .then(function(cache) {
// cache.put(event.request, responseToCache);
// });

// // And return the network response
// return response;
// }
// );
// })
// );
// });