Skip to content

Commit

Permalink
Merge releases/0.8.0 into release - hotfix 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkus Decker committed Mar 20, 2016
2 parents 0ce9f9a + a929864 commit 03d43b2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
9 changes: 9 additions & 0 deletions index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ html(lang='en')
#js-disabled-warn.alert.alert-danger(role='alert')
strong Javascript is disabled!
| Looks like you have JavaScript disabled in your browser. Please enable it to enjoy our service.

if opts.livereload
script( src="/webpack-dev-server.js" )

script.
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-62517081-1', 'auto');
ga('require', 'autotrack');
ga('send', 'pageview');
script(async src='https://www.google-analytics.com/analytics.js')

script(src='[[ app-*.js ]]')
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"dependencies": {
"autotrack": "^0.6.3",
"babel-core": "^5.8.25",
"babel-loader": "^5.3.2",
"babel-polyfill": "^6.0.16",
Expand Down
5 changes: 2 additions & 3 deletions src/components/dev.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ export default (props) => (

<p>[x] v 0.6 React frontend<br/>
[x] v 0.7 Add real-time updates to the frontend<br/>
[ &nbsp;] v 0.8 Add support for private groups<br/>
[x] v 0.8 Add support for private groups<br/>
[ &nbsp;] v 0.9 Migrate to Postgres<br/>
[ &nbsp;] v 1.0 Support for search and #hashtags</p>

<p>Please <a href="mailto:[email protected]">contact us</a> to join
our team of volunteers.</p>
<p><a href="https://dev.freefeed.net" target="_blank">Join</a> our team of volunteers!</p>

<p>P.S. We welcome contributions of features outside of the core ones
outlined above, however we feel that the core has higher priority
Expand Down
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ReactDOM from 'react-dom'
import {Router, Route, IndexRoute, browserHistory} from 'react-router'
import {Provider} from 'react-redux'
import {syncHistoryWithStore} from 'react-router-redux'
import Autotrack from 'autotrack'

import configureStore from './redux/configure-store'
import * as ActionCreators from './redux/action-creators'
Expand Down
66 changes: 40 additions & 26 deletions src/redux/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,30 @@ const initFeed = {
isHiddenRevealed: false
}

const hidePostInFeed = function(state, postId) {
// Add it to hiddenEntries, but don't remove from visibleEntries just yet
// (for the sake of "Undo"). And check first if it's already in hiddenEntries,
// since realtime event might come first.
const itsAlreadyThere = (state.hiddenEntries.indexOf(postId) > -1)
if (itsAlreadyThere) {
return state
}
return {...state,
hiddenEntries: [postId, ...state.hiddenEntries]
}
}

const unhidePostInFeed = function(state, postId) {
// Remove it from hiddenEntries and add to visibleEntries
// (but check first if it's already in there, since this might be an "Undo" happening,
// and/or realtime event might come first).
const itsStillThere = (state.visibleEntries.indexOf(postId) > -1)
return {...state,
visibleEntries: (itsStillThere ? state.visibleEntries : [...state.visibleEntries, postId]),
hiddenEntries: _.without(state.hiddenEntries, postId)
}
}

export function feedViewState(state = initFeed, action) {
if (ActionHelpers.isFeedRequest(action)){
return state
Expand Down Expand Up @@ -209,35 +233,16 @@ export function feedViewState(state = initFeed, action) {
return initFeed
}
case response(ActionTypes.HIDE_POST): {
// Add it to hiddenEntries, but don't remove from visibleEntries just yet
// (for the sake of "Undo")
const postId = action.request.postId
return {...state,
hiddenEntries: [postId, ...state.hiddenEntries]
}
return hidePostInFeed(state, action.request.postId)
}
case ActionTypes.REALTIME_POST_HIDE: {
return {...state,
hiddenEntries: [action.postId, ...state.hiddenEntries]
}
return hidePostInFeed(state, action.postId)
}
case response(ActionTypes.UNHIDE_POST): {
// Remove it from hiddenEntries and add to visibleEntries
// (but check first if it's already in there, since this might be an "Undo" happening)
const postId = action.request.postId
const itsStillThere = (state.visibleEntries.indexOf(postId) > -1)
return {...state,
visibleEntries: (itsStillThere ? state.visibleEntries : [...state.visibleEntries, postId]),
hiddenEntries: _.without(state.hiddenEntries, postId)
}
return unhidePostInFeed(state, action.request.postId)
}
case ActionTypes.REALTIME_POST_UNHIDE: {
const postId = action.postId
const itsStillThere = (state.visibleEntries.indexOf(postId) > -1)
return {...state,
visibleEntries: (itsStillThere ? state.visibleEntries : [...state.visibleEntries, postId]),
hiddenEntries: _.without(state.hiddenEntries, postId)
}
return unhidePostInFeed(state, action.postId)
}
case ActionTypes.TOGGLE_HIDDEN_POSTS: {
return {...state,
Expand Down Expand Up @@ -1393,7 +1398,7 @@ function getValidRecipients(state) {
}

const canSendDirect = function(subUser) {
return (_.find(state.subscribers || [], { 'id': subUser.id }) !== null)
return (_.findIndex(state.users.subscribers || [], { 'id': subUser.id }) > -1)
}

const validRecipients = _.filter(subscriptions, (sub) => {
Expand Down Expand Up @@ -1628,10 +1633,19 @@ export function managedGroups(state = [], action) {
return state
}

const findByIds = (collection, ids) => {
return _.filter(collection, (item) => _.contains(ids, item.id))
}

const subscriptionRequests = (whoamiPayload) => {
const subscriptionRequestsIds = whoamiPayload.users.subscriptionRequests || []
return findByIds(whoamiPayload.requests || [], subscriptionRequestsIds).map(userParser)
}

export function userRequests(state = [], action) {
switch (action.type) {
case response(ActionTypes.WHO_AM_I): {
return (action.payload.requests || []).map(userParser)
return subscriptionRequests(action.payload)
}
case response(ActionTypes.ACCEPT_USER_REQUEST):
case response(ActionTypes.REJECT_USER_REQUEST): {
Expand Down Expand Up @@ -1662,7 +1676,7 @@ export function groupRequestsCount(state = 0, action) {
export function userRequestsCount(state = 0, action) {
switch (action.type) {
case response(ActionTypes.WHO_AM_I): {
return (action.payload.requests || []).length
return subscriptionRequests(action.payload).length
}
case response(ActionTypes.ACCEPT_USER_REQUEST):
case response(ActionTypes.REJECT_USER_REQUEST): {
Expand Down

0 comments on commit 03d43b2

Please sign in to comment.