Move file sharing into a separate tab
This commit is contained in:
@@ -17,15 +17,6 @@ const chatmessages = (state = [], action) =>
|
||||
return [ ...state, message ];
|
||||
}
|
||||
|
||||
case 'ADD_NEW_USER_FILE':
|
||||
{
|
||||
const { file } = action.payload;
|
||||
|
||||
const message = createNewFile(file, 'client', 'Me', undefined);
|
||||
|
||||
return [ ...state, message ];
|
||||
}
|
||||
|
||||
case 'ADD_NEW_RESPONSE_MESSAGE':
|
||||
{
|
||||
const { message } = action.payload;
|
||||
|
||||
@@ -8,16 +8,4 @@ export function createNewMessage(text, sender, name, picture)
|
||||
sender,
|
||||
picture
|
||||
};
|
||||
}
|
||||
|
||||
export function createNewFile(file, sender, name, picture)
|
||||
{
|
||||
return {
|
||||
type : 'file',
|
||||
file,
|
||||
time : Date.now(),
|
||||
name,
|
||||
sender,
|
||||
picture
|
||||
};
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import notifications from './notifications';
|
||||
import chatmessages from './chatmessages';
|
||||
import chatbehavior from './chatbehavior';
|
||||
import toolarea from './toolarea';
|
||||
import sharing from './sharing';
|
||||
|
||||
const reducers = combineReducers(
|
||||
{
|
||||
@@ -19,7 +20,8 @@ const reducers = combineReducers(
|
||||
notifications,
|
||||
chatmessages,
|
||||
chatbehavior,
|
||||
toolarea
|
||||
toolarea,
|
||||
sharing
|
||||
});
|
||||
|
||||
export default reducers;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const sharing = (state = [], action) =>
|
||||
{
|
||||
switch (action.type)
|
||||
{
|
||||
case 'SEND_FILE':
|
||||
return [ ...state, { ...action.payload, me: true }];
|
||||
|
||||
case 'ADD_FILE':
|
||||
return [ ...state, action.payload ];
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default sharing;
|
||||
@@ -214,13 +214,11 @@ export const sendChatMessage = (text, name, picture) =>
|
||||
};
|
||||
};
|
||||
|
||||
export const sendChatFile = (magnet, name, picture) =>
|
||||
export const sendFile = (file, name, picture) =>
|
||||
{
|
||||
const message = createNewFile(magnet, 'response', name, picture);
|
||||
|
||||
return {
|
||||
type : 'SEND_CHAT_MESSAGE',
|
||||
payload : { message }
|
||||
type: 'SEND_FILE',
|
||||
payload: { file, name, picture }
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -231,6 +231,12 @@ export default ({ dispatch, getState }) => (next) =>
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'SEND_FILE':
|
||||
{
|
||||
client.sendFile(action.payload);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
|
||||
@@ -441,6 +441,14 @@ export const dropMessages = () =>
|
||||
};
|
||||
};
|
||||
|
||||
export const addFile = (payload) =>
|
||||
{
|
||||
return {
|
||||
type: 'ADD_FILE',
|
||||
payload
|
||||
};
|
||||
};
|
||||
|
||||
export const setPicture = (picture) =>
|
||||
({
|
||||
type : 'SET_PICTURE',
|
||||
|
||||
Reference in New Issue
Block a user