Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
implement object-based tweetStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeldesu committed Aug 29, 2016
1 parent 302581e commit 5399e1c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
12 changes: 11 additions & 1 deletion app/_js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require('../../node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js')
window.app = {}
app.user = {}
app.tweets = []
app.tweetStorage = {}
app.interactions = []
app.direct_messages = []
app.themes = []
Expand Down Expand Up @@ -37,6 +38,7 @@ var vm = new Vue({
el: '#main',
data: {
tweets: app.tweets,
tweetStorage: app.tweetStorage,
interactions: app.interactions,
direct_messages: app.direct_messages,
sounds: app.sounds,
Expand Down Expand Up @@ -70,7 +72,10 @@ ipcRenderer.on('surfbird:get:tweets', function (e, tweet) {
if (tweet.retweeted_status !== undefined) {
tweet.retweeted_status.text_html = twitter.autoLink(tweet.retweeted_status.text, {'usernameIncludeSymbol': true, 'targetBlank': true})
}
app.tweets.unshift(tweet)

app.tweetStorage[tweet.id_str] = tweet
vm.$set('tweetStorage', app.tweetStorage)
app.tweets.unshift(tweet.id_str)
})

ipcRenderer.on('surfbird:get:interactions', function (e, interaction) {
Expand All @@ -82,6 +87,11 @@ ipcRenderer.on('surfbird:get:interactions', function (e, interaction) {
interaction.event.text_html = twitter.autoLink(interaction.event.text, {'usernameIncludeSymbol': true, 'targetBlank': true})
}

if (interaction.type === 'mention') {
app.tweetStorage[interaction.event.id_str] = interaction.event
vm.$set('tweetStorage', app.tweetStorage)
}

app.interactions.unshift(interaction)

if (interactionsurf) {
Expand Down
2 changes: 1 addition & 1 deletion app/_js/vue/interaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
</div>
</div>
<stream-item v-bind:content="content" v-bind:index="$index" v-else></stream-item>
<stream-item v-bind:id="content.id_str" v-bind:index="$index" v-else></stream-item>
</template>

<script>
Expand Down
7 changes: 6 additions & 1 deletion app/_js/vue/tweet/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@

<script>
export default {
props: ['content', 'index']
props: ['id', 'index'],
computed: {
content: function () {
return this.$root.tweetStorage[this.id]
}
}
}
</script>
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<compose :user.sync="user"></compose>
<div class="columns">
<column title="Home">
<stream-item v-for="tweet in tweets | orderBy 'id_str' -1 | limitBy 200" v-bind:content="tweet" v-bind:index="$index"></stream-item>
<stream-item v-for="tweet in tweets | orderBy 'id_str' -1 | limitBy 200" v-bind:id="tweet" v-bind:index="$index"></stream-item>
</column>
<column title="Interactions">
<interaction v-for="event in interactions | orderBy 'created_at' -1 | limitBy 200" v-bind:event="event.type" v-bind:content="event.event" v-bind:index="$index"></interaction>
Expand Down

0 comments on commit 5399e1c

Please sign in to comment.