Initial work for file sharing using WebTorrent

This commit is contained in:
Torjus
2018-07-26 15:29:52 +02:00
parent 4f8c896a43
commit 7efaf092c8
9 changed files with 1306 additions and 107 deletions
+12 -2
View File
@@ -1,6 +1,7 @@
import
{
createNewMessage
createNewMessage,
createNewFile
} from './helper';
const chatmessages = (state = [], action) =>
@@ -11,7 +12,16 @@ const chatmessages = (state = [], action) =>
{
const { text } = action.payload;
const message = createNewMessage(text, 'client', 'Me');
const message = createNewMessage(text, 'client', 'Me', undefined);
return [ ...state, message ];
}
case 'ADD_NEW_USER_FILE':
{
const { file } = action.payload;
const message = createNewFile(file, 'client', 'Me', undefined);
return [ ...state, message ];
}
+12
View File
@@ -8,4 +8,16 @@ 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
};
}