Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7168ea
commit a503778
Showing
13 changed files
with
397 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# HackerNews |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# ProductHunt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,4 +63,3 @@ io.on('connection', (socket) => { | |
}); | ||
|
||
io.listen(process.env.PORT || 3000); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<template> | ||
<f7-page navbar-fixed name="groupChat"> | ||
<f7-navbar :title="conversationtTitle" back-link="Back" sliding></f7-navbar> | ||
<f7-messages scrollMessagesOnlyOnEdge class="chats"> | ||
<f7-message v-for="message in messages" | ||
:key="message.id" | ||
:text="message.text" | ||
:label="message.label" | ||
:date="message.date" | ||
:name="message.name" | ||
:avatar="getAvatar(message)" | ||
:type="message.type" | ||
:username="message.name" | ||
:day="message.day" | ||
:time="message.time" | ||
></f7-message> | ||
</f7-messages> | ||
<f7-messagebar placeholder="Say something.." @input="keyPress" @submit="onSubmit"> | ||
<span slot="send-link"><i style="font-size:1.8em;" class="fa fa-paper-plane fa-2x"></i></span> | ||
</f7-messagebar> | ||
</f7-page> | ||
</template> | ||
|
||
<script> | ||
import { mapGetters } from 'vuex'; | ||
export default { | ||
data() { | ||
return { | ||
messages: [] | ||
} | ||
}, | ||
props: ['id'], | ||
methods: { | ||
keyPress: function(event) { | ||
if (this.sendWithEnter) { | ||
if (event.split('\n').length > 1) { | ||
this.onSubmit(event.split('\n')[0], this.$f7.messagebar('.messagebar').clear) | ||
} | ||
} | ||
}, | ||
onSubmit: function(text, clear) { | ||
if (text.trim().length === 0) return; | ||
let message = { | ||
id: this.$store.state.user.id, | ||
name: this.$store.state.user.username, | ||
avatar: `https://api.adorable.io/avatars/60/${this.$store.state.user.username}`, | ||
text: text, | ||
date: (function () { | ||
var now = new Date(); | ||
var hours = now.getHours(); | ||
var minutes = now.getMinutes(); | ||
return hours + ':' + minutes; | ||
})() | ||
}; | ||
this.$store.dispatch('sendMessage', message); | ||
message.to = this.$store.state.currentConversation.id | ||
message.country = this.$store.state.currentConversation.country | ||
message.isTrend = true | ||
this.$socket.emit('message', message) | ||
clear(); | ||
}, | ||
getAvatar(message) { | ||
return `https://api.adorable.io/avatars/60/${message.name}`; | ||
} | ||
}, | ||
computed: { | ||
...mapGetters([ | ||
'conversation', | ||
'conversationtTitle', | ||
'sendWithEnter', | ||
]) | ||
}, | ||
created() { | ||
try { | ||
this.$store.dispatch('currentConversation', this.id); | ||
this.messages = this.$store.state.currentConversation.messages | ||
} catch (e) { | ||
console.log(e); | ||
} finally { | ||
console.log('Chat created'); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style media="screen"> | ||
.chats { | ||
padding-bottom: 40px; | ||
} | ||
.messages-content { | ||
background: #EEEEEE; | ||
} | ||
.message-sent .message-text { | ||
background-color: #00ADB5; | ||
} | ||
.message-received .message-text { | ||
background-color: #393E46; | ||
color: #EEEEEE; | ||
} | ||
</style> |
Oops, something went wrong.