Merged with changes in develop & fixed conflicts.

This commit is contained in:
shpuld 2017-03-09 12:45:12 +02:00
commit d99b9bdac1
12 changed files with 154 additions and 64 deletions

View file

@ -28,10 +28,17 @@ before_script:
# - node_modules/ # - node_modules/
stages: stages:
- lint
- build - build
- test - test
- deploy - deploy
lint:
stage: lint
script:
- yarn
- npm run lint
test: test:
stage: test stage: test
script: script:

View file

@ -11,7 +11,9 @@ const Attachment = {
return { return {
nsfwImage, nsfwImage,
hideNsfwLocal: this.$store.state.config.hideNsfw, hideNsfwLocal: this.$store.state.config.hideNsfw,
showHidden: false showHidden: false,
loading: false,
img: document.createElement('img')
} }
}, },
computed: { computed: {
@ -20,6 +22,13 @@ const Attachment = {
}, },
hidden () { hidden () {
return this.nsfw && this.hideNsfwLocal && !this.showHidden return this.nsfw && this.hideNsfwLocal && !this.showHidden
},
autoHeight () {
if (this.type === 'image' && this.nsfw) {
return {
'min-height': '311px'
}
}
} }
}, },
methods: { methods: {
@ -29,13 +38,18 @@ const Attachment = {
} }
}, },
toggleHidden () { toggleHidden () {
let img = document.createElement('img') if (this.img.onload) {
img.src = this.attachment.url this.img.onload()
img.onload = () => { } else {
this.loading = true
this.img.src = this.attachment.url
this.img.onload = () => {
this.loading = false
this.showHidden = !this.showHidden this.showHidden = !this.showHidden
} }
} }
} }
}
} }
export default Attachment export default Attachment

View file

@ -1,15 +1,14 @@
<template> <template>
<div class="attachment" :class="type"> <div class="attachment" :class="{[type]: true, loading}" :style="autoHeight">
<a class="image-attachment" v-if="hidden" v-on:click.prevent="toggleHidden()"> <a class="image-attachment" v-if="hidden" @click.prevent="toggleHidden()">
<img :key="nsfwImage" :src="nsfwImage"></img> <img :key="nsfwImage" :src="nsfwImage"/>
</a> </a>
<div class="hider" v-if="nsfw && hideNsfwLocal && !hidden"> <div class="hider" v-if="nsfw && hideNsfwLocal && !hidden">
<a href="#" @click.prevent="toggleHidden()">Hide</a> <a href="#" @click.prevent="toggleHidden()">Hide</a>
</div> </div>
<a class="image-attachment" v-if="type === 'image' && !hidden" <a v-if="type === 'image' && !hidden" class="image-attachment" :href="attachment.url" target="_blank">
:href="attachment.url" target="_blank"> <img class="base05-border" referrerpolicy="no-referrer" :src="attachment.large_thumb_url || attachment.url"/>
<img class="base05-border" referrerpolicy="no-referrer" :src="attachment.large_thumb_url || attachment.url"></img>
</a> </a>
<video v-if="type === 'video' && !hidden" :src="attachment.url" controls></video> <video v-if="type === 'video' && !hidden" :src="attachment.url" controls></video>
@ -18,7 +17,7 @@
<div @click.prevent="linkClicked" v-if="type === 'html' && attachment.oembed" class="oembed"> <div @click.prevent="linkClicked" v-if="type === 'html' && attachment.oembed" class="oembed">
<div v-if="attachment.thumb_url" class="image"> <div v-if="attachment.thumb_url" class="image">
<img :src="attachment.thumb_url"></img> <img :src="attachment.thumb_url"/>
</div> </div>
<div class="text"> <div class="text">
<h1><a :href="attachment.url">{{attachment.oembed.title}}</a></h1> <h1><a :href="attachment.url">{{attachment.oembed.title}}</a></h1>
@ -45,6 +44,10 @@
display: flex; display: flex;
} }
&.loading {
cursor: progress;
}
.hider { .hider {
position: absolute; position: absolute;
margin: 10px; margin: 10px;
@ -111,7 +114,6 @@
flex: 1; flex: 1;
img { img {
width: 100%;
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
border-radius: 5px; border-radius: 5px;

View file

@ -1,5 +1,10 @@
const FavoriteButton = { const FavoriteButton = {
props: [ 'status' ], props: ['status'],
data () {
return {
animated: false
}
},
methods: { methods: {
favorite () { favorite () {
if (!this.status.favorited) { if (!this.status.favorited) {
@ -7,13 +12,18 @@ const FavoriteButton = {
} else { } else {
this.$store.dispatch('unfavorite', {id: this.status.id}) this.$store.dispatch('unfavorite', {id: this.status.id})
} }
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
} }
}, },
computed: { computed: {
classes () { classes () {
return { return {
'icon-star-empty': !this.status.favorited, 'icon-star-empty': !this.status.favorited,
'icon-star': this.status.favorited 'icon-star': this.status.favorited,
'animate-spin': this.animated
} }
} }
} }

View file

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<i :class='classes' class='favorite-button fa' v-on:click.prevent='favorite()'></i> <i :class='classes' class='favorite-button fa' @click.prevent='favorite()'/>
<span v-if='status.fave_num > 0'>{{status.fave_num}}</span> <span v-if='status.fave_num > 0'>{{status.fave_num}}</span>
</div> </div>
</template> </template>
@ -10,6 +10,7 @@
<style lang='scss'> <style lang='scss'>
.favorite-button { .favorite-button {
cursor: pointer; cursor: pointer;
animation-duration: 0.6s;
&:hover { &:hover {
color: orange; color: orange;
} }
@ -17,4 +18,5 @@
.icon-star { .icon-star {
color: orange; color: orange;
} }
</style> </style>

View file

@ -1,13 +1,21 @@
const LoginForm = { const LoginForm = {
data: () => ({ data: () => ({
user: {} user: {},
authError: false
}), }),
computed: { computed: {
loggingIn () { return this.$store.state.users.loggingIn } loggingIn () { return this.$store.state.users.loggingIn }
}, },
methods: { methods: {
submit () { submit () {
this.$store.dispatch('loginUser', this.user) this.$store.dispatch('loginUser', this.user).then(
() => {},
(error) => {
this.authError = error
this.user.username = ''
this.user.password = ''
}
)
} }
} }
} }

View file

@ -17,6 +17,9 @@
<div class='form-group'> <div class='form-group'>
<button :disabled="loggingIn" type='submit' class='btn btn-default base05 base01-background'>Submit</button> <button :disabled="loggingIn" type='submit' class='btn btn-default base05 base01-background'>Submit</button>
</div> </div>
<div v-if="authError" class='form-group'>
<div class='error base05'>{{authError}}</div>
</div>
</form> </form>
</div> </div>
</div> </div>
@ -39,6 +42,14 @@
margin-top: 1.0em; margin-top: 1.0em;
min-height: 28px; min-height: 28px;
} }
.error {
border-radius: 5px;
text-align: center;
background-color: rgba(255, 48, 16, 0.65);
min-height: 28px;
line-height: 28px;
}
} }
</style> </style>

View file

@ -1,24 +1,24 @@
<template> <template>
<div class="nav-panel"> <div class="nav-panel">
<div class="panel panel-default base01-background"> <div class="panel panel-default base02-background">
<ul class="base03-border"> <ul class="base03-border">
<li v-if='currentUser'> <li v-if='currentUser'>
<router-link to='/main/friends'> <router-link class="base01-background" to='/main/friends'>
Timeline Timeline
</router-link> </router-link>
</li> </li>
<li v-if='currentUser'> <li v-if='currentUser'>
<router-link :to="{ name: 'mentions', params: { username: currentUser.screen_name } }"> <router-link class="base01-background" :to="{ name: 'mentions', params: { username: currentUser.screen_name } }">
Mentions Mentions
</router-link> </router-link>
</li> </li>
<li> <li>
<router-link to='/main/public'> <router-link class="base01-background" to='/main/public'>
Public Timeline Public Timeline
</router-link> </router-link>
</li> </li>
<li> <li>
<router-link to='/main/all'> <router-link class="base01-background" to='/main/all'>
The Whole Known Network The Whole Known Network
</router-link> </router-link>
</li> </li>
@ -30,7 +30,6 @@
<script src="./nav_panel.js" ></script> <script src="./nav_panel.js" ></script>
<style lang="scss"> <style lang="scss">
.nav-panel ul { .nav-panel ul {
list-style: none; list-style: none;
margin: 0; margin: 0;
@ -40,7 +39,15 @@
.nav-panel li { .nav-panel li {
border-bottom: 1px solid; border-bottom: 1px solid;
border-color: inherit; border-color: inherit;
padding: 0.8em 0.85em; padding: 0;
&:first-child a {
border-top-right-radius: 10px;
border-top-left-radius: 10px;
}
&:last-child a {
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
} }
.nav-panel li:last-child { .nav-panel li:last-child {
@ -49,10 +56,16 @@
.nav-panel a { .nav-panel a {
display: block; display: block;
width: 100%; padding: 0.8em 0.85em;
&:hover {
background-color: transparent;
}
&.router-link-active { &.router-link-active {
font-weight: bold font-weight: bolder;
background-color: transparent;
&:hover {
text-decoration: underline;
}
} }
} }

View file

@ -1,16 +1,26 @@
const RetweetButton = { const RetweetButton = {
props: [ 'status' ], props: ['status'],
data () {
return {
animated: false
}
},
methods: { methods: {
retweet () { retweet () {
if (!this.status.repeated) { if (!this.status.repeated) {
this.$store.dispatch('retweet', {id: this.status.id}) this.$store.dispatch('retweet', {id: this.status.id})
} }
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
} }
}, },
computed: { computed: {
classes () { classes () {
return { return {
'retweeted': this.status.repeated 'retweeted': this.status.repeated,
'animate-spin': this.animated
} }
} }
} }

View file

@ -11,12 +11,12 @@
@import '../../_variables.scss'; @import '../../_variables.scss';
.icon-retweet { .icon-retweet {
cursor: pointer; cursor: pointer;
animation-duration: 0.6s;
&:hover { &:hover {
color: $green; color: $green;
} }
} }
.retweeted { .retweeted {
cursor: auto;
color: $green; color: $green;
} }
</style> </style>

View file

@ -67,6 +67,7 @@ const users = {
}) })
}, },
loginUser (store, userCredentials) { loginUser (store, userCredentials) {
return new Promise((resolve, reject) => {
const commit = store.commit const commit = store.commit
commit('beginLogin') commit('beginLogin')
store.rootState.api.backendInteractor.verifyCredentials(userCredentials) store.rootState.api.backendInteractor.verifyCredentials(userCredentials)
@ -94,12 +95,23 @@ const users = {
store.rootState.api.backendInteractor.fetchFriends() store.rootState.api.backendInteractor.fetchFriends()
.then((friends) => commit('addNewUsers', friends)) .then((friends) => commit('addNewUsers', friends))
}) })
} else {
// Authentication failed
commit('endLogin')
if (response.status === 401) {
reject('Wrong username or password')
} else {
reject('An error occurred, please try again')
}
} }
commit('endLogin') commit('endLogin')
resolve()
}) })
.catch((error) => { .catch((error) => {
console.log(error) console.log(error)
commit('endLogin') commit('endLogin')
reject('Failed to connect to server, try again')
})
}) })
} }
} }

View file

@ -5,6 +5,8 @@ import apiService from '../api/api.service.js'
const update = ({store, statuses, timeline, showImmediately}) => { const update = ({store, statuses, timeline, showImmediately}) => {
const ccTimeline = camelCase(timeline) const ccTimeline = camelCase(timeline)
setError({store, timeline, value: false})
store.dispatch('addNewStatuses', { store.dispatch('addNewStatuses', {
timeline: ccTimeline, timeline: ccTimeline,
statuses, statuses,
@ -33,9 +35,8 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
} }
return apiService.fetchTimeline(args) return apiService.fetchTimeline(args)
.then((statuses) => update({store, statuses, timeline, showImmediately})) .then((statuses) => update({store, statuses, timeline, showImmediately}),
.then(() => setError({store, timeline, value: false})) () => setError({store, timeline, value: true}))
.catch(() => setError({store, timeline, value: true}))
} }
const startFetching = ({ timeline = 'friends', credentials, store }) => { const startFetching = ({ timeline = 'friends', credentials, store }) => {