refactor MobilePostStatusModal using new PostStatusModal

This commit is contained in:
taehoon 2019-09-19 13:52:20 -04:00
parent f4bbf1d4e2
commit a9f33272a8
2 changed files with 4 additions and 53 deletions

View File

@ -1,14 +1,9 @@
import PostStatusForm from '../post_status_form/post_status_form.vue'
import { debounce } from 'lodash' import { debounce } from 'lodash'
const MobilePostStatusModal = { const MobilePostStatusModal = {
components: {
PostStatusForm
},
data () { data () {
return { return {
hidden: false, hidden: false,
postFormOpen: false,
scrollingDown: false, scrollingDown: false,
inputActive: false, inputActive: false,
oldScrollPos: 0, oldScrollPos: 0,
@ -28,8 +23,8 @@ const MobilePostStatusModal = {
window.removeEventListener('resize', this.handleOSK) window.removeEventListener('resize', this.handleOSK)
}, },
computed: { computed: {
currentUser () { isLoggedIn () {
return this.$store.state.users.currentUser return !!this.$store.state.users.currentUser
}, },
isHidden () { isHidden () {
return this.autohideFloatingPostButton && (this.hidden || this.inputActive) return this.autohideFloatingPostButton && (this.hidden || this.inputActive)
@ -57,17 +52,7 @@ const MobilePostStatusModal = {
window.removeEventListener('scroll', this.handleScrollEnd) window.removeEventListener('scroll', this.handleScrollEnd)
}, },
openPostForm () { openPostForm () {
this.postFormOpen = true this.$store.dispatch('openPostStatusModal')
this.hidden = true
const el = this.$el.querySelector('textarea')
this.$nextTick(function () {
el.focus()
})
},
closePostForm () {
this.postFormOpen = false
this.hidden = false
}, },
handleOSK () { handleOSK () {
// This is a big hack: we're guessing from changed window sizes if the // This is a big hack: we're guessing from changed window sizes if the

View File

@ -1,23 +1,5 @@
<template> <template>
<div v-if="currentUser"> <div v-if="isLoggedIn">
<div
v-show="postFormOpen"
class="post-form-modal-view modal-view"
@click="closePostForm"
>
<div
class="post-form-modal-panel panel"
@click.stop=""
>
<div class="panel-heading">
{{ $t('post_status.new_status') }}
</div>
<PostStatusForm
class="panel-body"
@posted="closePostForm"
/>
</div>
</div>
<button <button
class="new-status-button" class="new-status-button"
:class="{ 'hidden': isHidden }" :class="{ 'hidden': isHidden }"
@ -33,22 +15,6 @@
<style lang="scss"> <style lang="scss">
@import '../../_variables.scss'; @import '../../_variables.scss';
.post-form-modal-view {
align-items: flex-start;
}
.post-form-modal-panel {
flex-shrink: 0;
margin-top: 25%;
margin-bottom: 2em;
width: 100%;
max-width: 700px;
@media (orientation: landscape) {
margin-top: 8%;
}
}
.new-status-button { .new-status-button {
width: 5em; width: 5em;
height: 5em; height: 5em;