mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
USER auto refresh
This commit is contained in:
@@ -33,12 +33,14 @@ export default class ArticleNavigator extends React.Component {
|
|||||||
|
|
||||||
let activeFolder = findWhere(activeUser.Folders, {id: status.folderId})
|
let activeFolder = findWhere(activeUser.Folders, {id: status.folderId})
|
||||||
|
|
||||||
let folders = activeUser.Folders.map((folder, index) => {
|
let folders = activeUser.Folders != null
|
||||||
return (
|
? activeUser.Folders.map((folder, index) => {
|
||||||
<button key={'folder-' + folder.id} className={activeFolder != null && activeFolder.id === folder.id ? 'active' : ''}>
|
return (
|
||||||
<FolderMark id={folder.id}/> {folder.name} {folder.public ? <i className='fa fa-fw fa-lock'/> : null}</button>
|
<button key={'folder-' + folder.id} className={activeFolder != null && activeFolder.id === folder.id ? 'active' : ''}>
|
||||||
)
|
<FolderMark id={folder.id}/> {folder.name} {folder.public ? <i className='fa fa-fw fa-lock'/> : null}</button>
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
: []
|
||||||
|
|
||||||
let members = Array.isArray(activeUser.Members) ? activeUser.Members.sort((a, b) => {
|
let members = Array.isArray(activeUser.Members) ? activeUser.Members.sort((a, b) => {
|
||||||
return new Date(a._pivot_createdAt) - new Date(b._pivot_createdAt)
|
return new Date(a._pivot_createdAt) - new Date(b._pivot_createdAt)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const UNSYNCED = 'UNSYNCED'
|
|||||||
export function updateUser (user) {
|
export function updateUser (user) {
|
||||||
return {
|
return {
|
||||||
type: USER_UPDATE,
|
type: USER_UPDATE,
|
||||||
data: user
|
data: { user }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ function getInitialArticles () {
|
|||||||
function currentUser (state, action) {
|
function currentUser (state, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case USER_UPDATE:
|
case USER_UPDATE:
|
||||||
let user = action.data
|
let user = action.data.user
|
||||||
|
|
||||||
return auth.user(user)
|
return auth.user(user)
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { API_URL } from '../config'
|
|||||||
import socketio from 'socket.io-client'
|
import socketio from 'socket.io-client'
|
||||||
import auth from './auth'
|
import auth from './auth'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import { updateArticle, destroyArticle } from './actions'
|
import { updateUser, updateArticle, destroyArticle } from './actions'
|
||||||
|
|
||||||
export const CONN = 'CONN'
|
export const CONN = 'CONN'
|
||||||
export const ALERT = 'ALERT'
|
export const ALERT = 'ALERT'
|
||||||
@@ -27,6 +27,8 @@ io.on(ALERT, function (data) {
|
|||||||
|
|
||||||
io.on(USER_UPDATE, function (data) {
|
io.on(USER_UPDATE, function (data) {
|
||||||
console.log(USER_UPDATE, data)
|
console.log(USER_UPDATE, data)
|
||||||
|
let { user } = data
|
||||||
|
store.dispatch(updateUser(user))
|
||||||
})
|
})
|
||||||
|
|
||||||
io.on(ARTICLE_UPDATE, function (data) {
|
io.on(ARTICLE_UPDATE, function (data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user