diff options
| -rw-r--r-- | build/webpack.base.conf.js | 3 | ||||
| -rw-r--r-- | src/App.scss | 27 | ||||
| -rw-r--r-- | src/boot/routes.js | 2 | ||||
| -rw-r--r-- | src/components/login_form/login_form.js | 22 | ||||
| -rw-r--r-- | src/components/login_form/login_form.vue | 21 | ||||
| -rw-r--r-- | src/components/registration/registration.vue | 18 | ||||
| -rw-r--r-- | src/components/status/status.js | 12 | ||||
| -rw-r--r-- | src/components/user_profile/user_profile.js | 11 | ||||
| -rw-r--r-- | src/components/user_profile/user_profile.vue | 4 | ||||
| -rw-r--r-- | src/modules/statuses.js | 6 | ||||
| -rw-r--r-- | src/modules/users.js | 2 | ||||
| -rw-r--r-- | test/unit/specs/modules/statuses.spec.js | 9 | ||||
| -rw-r--r-- | test/unit/specs/modules/users.spec.js | 11 |
13 files changed, 104 insertions, 44 deletions
diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index ea46ce6f..e07bb7a2 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -95,7 +95,8 @@ module.exports = { }, plugins: [ new ServiceWorkerWebpackPlugin({ - entry: path.join(__dirname, '..', 'src/sw.js') + entry: path.join(__dirname, '..', 'src/sw.js'), + filename: 'sw-pleroma.js' }) ] } diff --git a/src/App.scss b/src/App.scss index ed06bbbc..ba8770e2 100644 --- a/src/App.scss +++ b/src/App.scss @@ -654,6 +654,33 @@ nav { border-radius: var(--inputRadius, $fallback--inputRadius); } +@keyframes shakeError { + 0% { + transform: translateX(0); + } + 15% { + transform: translateX(0.375rem); + } + 30% { + transform: translateX(-0.375rem); + } + 45% { + transform: translateX(0.375rem); + } + 60% { + transform: translateX(-0.375rem); + } + 75% { + transform: translateX(0.375rem); + } + 90% { + transform: translateX(-0.375rem); + } + 100% { + transform: translateX(0); + } +} + @media all and (max-width: 959px) { .mobile-hidden { display: none; diff --git a/src/boot/routes.js b/src/boot/routes.js index 9dba532a..cfbcb1fe 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -39,7 +39,7 @@ export default (store) => { { name: 'dms', path: '/users/:username/dms', component: DMs }, { name: 'settings', path: '/settings', component: Settings }, { name: 'registration', path: '/registration', component: Registration }, - { name: 'registration', path: '/registration/:token', component: Registration }, + { name: 'registration-token', path: '/registration/:token', component: Registration }, { name: 'friend-requests', path: '/friend-requests', component: FollowRequests }, { name: 'user-settings', path: '/user-settings', component: UserSettings }, { name: 'notifications', path: '/:username/notifications', component: Notifications }, diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index 013222a8..fb6dc651 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -22,19 +22,29 @@ const LoginForm = { oauth: this.$store.state.oauth, instance: this.$store.state.instance.server } + this.clearError() oauthApi.getOrCreateApp(data).then((app) => { oauthApi.getTokenWithCredentials( { app, instance: data.instance, username: this.user.username, - password: this.user.password}) - .then((result) => { - this.$store.commit('setToken', result.access_token) - this.$store.dispatch('loginUser', result.access_token) - this.$router.push({name: 'friends'}) - }) + password: this.user.password + } + ).then((result) => { + if (result.error) { + this.authError = result.error + this.user.password = '' + return + } + this.$store.commit('setToken', result.access_token) + this.$store.dispatch('loginUser', result.access_token) + this.$router.push({name: 'friends'}) + }) }) + }, + clearError () { + this.authError = false } } } diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue index 12971882..27a8e48a 100644 --- a/src/components/login_form/login_form.vue +++ b/src/components/login_form/login_form.vue @@ -33,6 +33,13 @@ </div> </div> </form> + + <div v-if="authError" class='form-group'> + <div class='alert error'> + {{authError}} + <i class="button-icon icon-cancel" @click="clearError"></i> + </div> + </div> </div> </div> </template> @@ -48,10 +55,6 @@ width: 10em; } - .error { - text-align: center; - } - .register { flex: 1 1; } @@ -64,4 +67,14 @@ justify-content: space-between; } } + +.login { + .error { + text-align: center; + + animation-name: shakeError; + animation-duration: 0.4s; + animation-timing-function: ease-in-out; + } +} </style> diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue index 25c1a9d0..cf9bf5d9 100644 --- a/src/components/registration/registration.vue +++ b/src/components/registration/registration.vue @@ -147,24 +147,6 @@ $validations-cRed: #f04124; margin-bottom: 1em; } - @keyframes shakeError { - 0% { - transform: translateX(0); } - 15% { - transform: translateX(0.375rem); } - 30% { - transform: translateX(-0.375rem); } - 45% { - transform: translateX(0.375rem); } - 60% { - transform: translateX(-0.375rem); } - 75% { - transform: translateX(0.375rem); } - 90% { - transform: translateX(-0.375rem); } - 100% { - transform: translateX(0); } } - .form-group--error { animation-name: shakeError; animation-duration: .6s; diff --git a/src/components/status/status.js b/src/components/status/status.js index 681d0373..558125df 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -32,7 +32,7 @@ const Status = { userExpanded: false, preview: null, showPreview: false, - showingTall: false, + showingTall: this.inConversation && this.focused, expandingSubject: typeof this.$store.state.config.collapseMessageWithSubject === 'undefined' ? !this.$store.state.instance.collapseMessageWithSubject : !this.$store.state.config.collapseMessageWithSubject, @@ -126,7 +126,7 @@ const Status = { return lengthScore > 20 }, isReply () { - return !!this.status.in_reply_to_status_id + return !!(this.status.in_reply_to_status_id && this.status.in_reply_to_user_id) }, replyToName () { const user = this.$store.state.users.usersObject[this.status.in_reply_to_user_id] @@ -266,11 +266,11 @@ const Status = { toggleShowMore () { if (this.showingTall) { this.showingTall = false - } else if (this.expandingSubject) { + } else if (this.expandingSubject && this.status.summary) { this.expandingSubject = false } else if (this.hideTallStatus) { this.showingTall = true - } else if (this.hideSubjectStatus) { + } else if (this.hideSubjectStatus && this.status.summary) { this.expandingSubject = true } }, @@ -303,8 +303,10 @@ const Status = { 'highlight': function (id) { if (this.status.id === id) { let rect = this.$el.getBoundingClientRect() - if (rect.top < 100) { + if (rect.top < 140) { window.scrollBy(0, rect.top - 200) + } else if (rect.top < window.innerHeight && rect.height >= (window.innerHeight - 50)) { + window.scrollBy(0, rect.top - 50) } else if (rect.bottom > window.innerHeight - 50) { window.scrollBy(0, rect.bottom - window.innerHeight + 50) } diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 7414e573..991062cd 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -8,8 +8,8 @@ const UserProfile = { this.$store.commit('clearTimeline', { timeline: 'favorites' }) this.$store.commit('clearTimeline', { timeline: 'media' }) this.$store.dispatch('startFetching', ['user', this.fetchBy]) - this.$store.dispatch('startFetching', ['favorites', this.fetchBy]) this.$store.dispatch('startFetching', ['media', this.fetchBy]) + this.startFetchFavorites() if (!this.user.id) { this.$store.dispatch('fetchUser', this.fetchBy) } @@ -74,6 +74,11 @@ const UserProfile = { fetchFriends () { const id = this.userId this.$store.dispatch('addFriends', { id }) + }, + startFetchFavorites () { + if (this.isUs) { + this.$store.dispatch('startFetching', ['favorites', this.fetchBy]) + } } }, watch: { @@ -89,8 +94,8 @@ const UserProfile = { this.$store.commit('clearTimeline', { timeline: 'favorites' }) this.$store.commit('clearTimeline', { timeline: 'media' }) this.$store.dispatch('startFetching', ['user', this.fetchBy]) - this.$store.dispatch('startFetching', ['favorites', this.fetchBy]) this.$store.dispatch('startFetching', ['media', this.fetchBy]) + this.startFetchFavorites() }, userId () { if (!this.isExternal) { @@ -103,8 +108,8 @@ const UserProfile = { this.$store.commit('clearTimeline', { timeline: 'favorites' }) this.$store.commit('clearTimeline', { timeline: 'media' }) this.$store.dispatch('startFetching', ['user', this.fetchBy]) - this.$store.dispatch('startFetching', ['favorites', this.fetchBy]) this.$store.dispatch('startFetching', ['media', this.fetchBy]) + this.startFetchFavorites() }, user () { if (this.user.id && !this.user.followers) { diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index 74cd9c53..f9b964ce 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -20,8 +20,8 @@ <i class="icon-spin3 animate-spin"></i> </div> </div> - <Timeline :label="$t('user_card.media')" :embedded="true" :title="$t('user_profile.media_title')" timeline-name="media" :timeline="media" :user-id="fetchBy" /> - <Timeline v-if="isUs" :label="$t('user_card.favorites')" :embedded="true" :title="$t('user_profile.favorites_title')" timeline-name="favorites" :timeline="favorites"/> + <Timeline :label="$t('user_card.media')" :embedded="true" :title="$t('user_card.media')" timeline-name="media" :timeline="media" :user-id="fetchBy" /> + <Timeline v-if="isUs" :label="$t('user_card.favorites')" :embedded="true" :title="$t('user_card.favorites')" timeline-name="favorites" :timeline="favorites"/> </tab-switcher> </div> <div v-else class="panel user-profile-placeholder"> diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 3d6ea2f7..04ec4dbc 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -2,7 +2,7 @@ import { remove, slice, each, find, maxBy, minBy, merge, last, isArray } from 'l import apiService from '../services/api/api.service.js' // import parse from '../services/status_parser/status_parser.js' -const emptyTl = () => ({ +const emptyTl = (userId = 0) => ({ statuses: [], statusesObject: {}, faves: [], @@ -14,7 +14,7 @@ const emptyTl = () => ({ loading: false, followers: [], friends: [], - userId: 0, + userId, flushMarker: 0 }) @@ -319,7 +319,7 @@ export const mutations = { each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status }) }, clearTimeline (state, { timeline }) { - state.timelines[timeline] = emptyTl() + state.timelines[timeline] = emptyTl(state.timelines[timeline].userId) }, setFavorited (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] diff --git a/src/modules/users.js b/src/modules/users.js index d83f0dd8..181946b4 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -91,7 +91,7 @@ export const getters = { userById: state => id => state.users.find(user => user.id === id), userByName: state => name => - state.users.find(user => user.screen_name === name) + state.users.find(user => user.screen_name.toLowerCase() === name.toLowerCase()) } export const defaultState = { diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index 33628b9b..01d2ce06 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -240,6 +240,15 @@ describe('The Statuses module', () => { expect(state.timelines.public.visibleStatuses[0].favorited).to.eql(true) }) + it('keeps userId when clearing user timeline', () => { + const state = cloneDeep(defaultState) + state.timelines.user.userId = 123 + + mutations.clearTimeline(state, { timeline: 'user' }) + + expect(state.timelines.user.userId).to.eql(123) + }) + describe('notifications', () => { it('removes a notification when the notice gets removed', () => { const user = { id: '1' } diff --git a/test/unit/specs/modules/users.spec.js b/test/unit/specs/modules/users.spec.js index b0f3c51e..4d49ee24 100644 --- a/test/unit/specs/modules/users.spec.js +++ b/test/unit/specs/modules/users.spec.js @@ -45,6 +45,17 @@ describe('The users module', () => { const expected = { screen_name: 'Guy', id: '1' } expect(getters.userByName(state)(name)).to.eql(expected) }) + + it('returns user with matching screen_name with different case', () => { + const state = { + users: [ + { screen_name: 'guy', id: '1' } + ] + } + const name = 'Guy' + const expected = { screen_name: 'guy', id: '1' } + expect(getters.userByName(state)(name)).to.eql(expected) + }) }) describe('getUserById', () => { |
