Remove status and spoiler text from state for performance
This commit is contained in:
parent
e104ac0e6b
commit
60406740dc
|
@ -92,6 +92,8 @@ export default {
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
status: '',
|
||||||
|
spoiler: '',
|
||||||
showContentWarning: false,
|
showContentWarning: false,
|
||||||
visibilityList: Visibility
|
visibilityList: Visibility
|
||||||
}
|
}
|
||||||
|
@ -110,6 +112,7 @@ export default {
|
||||||
blockSubmit: state => state.blockSubmit,
|
blockSubmit: state => state.blockSubmit,
|
||||||
visibility: state => state.visibility,
|
visibility: state => state.visibility,
|
||||||
sensitive: state => state.sensitive,
|
sensitive: state => state.sensitive,
|
||||||
|
initialStatus: state => state.initialStatus,
|
||||||
visibilityIcon: (state) => {
|
visibilityIcon: (state) => {
|
||||||
switch (state.visibility) {
|
switch (state.visibility) {
|
||||||
case Visibility.Public.value:
|
case Visibility.Public.value:
|
||||||
|
@ -143,22 +146,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
status: {
|
|
||||||
get () {
|
|
||||||
return this.$store.state.TimelineSpace.Modals.NewToot.status
|
|
||||||
},
|
|
||||||
set (value) {
|
|
||||||
this.$store.commit('TimelineSpace/Modals/NewToot/updateStatus', value)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
spoiler: {
|
|
||||||
get () {
|
|
||||||
return this.$store.state.TimelineSpace.Modals.NewToot.spoiler
|
|
||||||
},
|
|
||||||
set (value) {
|
|
||||||
this.$store.commit('TimelineSpace/Modals/NewToot/updateSpoiler', value)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
pinedHashtag: {
|
pinedHashtag: {
|
||||||
get () {
|
get () {
|
||||||
return this.$store.state.TimelineSpace.Modals.NewToot.pinedHashtag
|
return this.$store.state.TimelineSpace.Modals.NewToot.pinedHashtag
|
||||||
|
@ -172,6 +159,8 @@ export default {
|
||||||
newTootModal: function (newState, oldState) {
|
newTootModal: function (newState, oldState) {
|
||||||
if (!oldState && newState) {
|
if (!oldState && newState) {
|
||||||
this.showContentWarning = false
|
this.showContentWarning = false
|
||||||
|
this.spoiler = ''
|
||||||
|
this.status = this.initialStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,13 +10,12 @@ const NewToot = {
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
modalOpen: false,
|
modalOpen: false,
|
||||||
status: '',
|
initialStatus: '',
|
||||||
replyToMessage: null,
|
replyToMessage: null,
|
||||||
blockSubmit: false,
|
blockSubmit: false,
|
||||||
attachedMedias: [],
|
attachedMedias: [],
|
||||||
visibility: Visibility.Public.value,
|
visibility: Visibility.Public.value,
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
spoiler: '',
|
|
||||||
attachedMediaId: 0,
|
attachedMediaId: 0,
|
||||||
pinedHashtag: false,
|
pinedHashtag: false,
|
||||||
hashtags: []
|
hashtags: []
|
||||||
|
@ -28,8 +27,8 @@ const NewToot = {
|
||||||
setReplyTo (state, message) {
|
setReplyTo (state, message) {
|
||||||
state.replyToMessage = message
|
state.replyToMessage = message
|
||||||
},
|
},
|
||||||
updateStatus (state, status) {
|
updateInitialStatus (state, status) {
|
||||||
state.status = status
|
state.initialStatus = status
|
||||||
},
|
},
|
||||||
changeBlockSubmit (state, value) {
|
changeBlockSubmit (state, value) {
|
||||||
state.blockSubmit = value
|
state.blockSubmit = value
|
||||||
|
@ -55,9 +54,6 @@ const NewToot = {
|
||||||
changeSensitive (state, value) {
|
changeSensitive (state, value) {
|
||||||
state.sensitive = value
|
state.sensitive = value
|
||||||
},
|
},
|
||||||
updateSpoiler (state, value) {
|
|
||||||
state.spoiler = value
|
|
||||||
},
|
|
||||||
updateMediaId (state, value) {
|
updateMediaId (state, value) {
|
||||||
state.attachedMediaId = value
|
state.attachedMediaId = value
|
||||||
},
|
},
|
||||||
|
@ -93,8 +89,8 @@ const NewToot = {
|
||||||
const mentionAccounts = [message.account.acct].concat(message.mentions.map(a => a.acct))
|
const mentionAccounts = [message.account.acct].concat(message.mentions.map(a => a.acct))
|
||||||
.filter((a, i, self) => self.indexOf(a) === i)
|
.filter((a, i, self) => self.indexOf(a) === i)
|
||||||
.filter((a) => a !== rootState.TimelineSpace.account.username)
|
.filter((a) => a !== rootState.TimelineSpace.account.username)
|
||||||
|
commit('updateInitialStatus', `${mentionAccounts.map(m => `@${m}`).join(' ')} `)
|
||||||
commit('changeModal', true)
|
commit('changeModal', true)
|
||||||
commit('updateStatus', `${mentionAccounts.map(m => `@${m}`).join(' ')} `)
|
|
||||||
let value = Visibility.Public.value
|
let value = Visibility.Public.value
|
||||||
Object.keys(Visibility).map((key, index) => {
|
Object.keys(Visibility).map((key, index) => {
|
||||||
const target = Visibility[key]
|
const target = Visibility[key]
|
||||||
|
@ -105,20 +101,19 @@ const NewToot = {
|
||||||
commit('changeVisibilityValue', value)
|
commit('changeVisibilityValue', value)
|
||||||
},
|
},
|
||||||
openModal ({ dispatch, commit, state, rootState }) {
|
openModal ({ dispatch, commit, state, rootState }) {
|
||||||
commit('changeModal', true)
|
|
||||||
if (!state.replyToMessage && state.pinedHashtag) {
|
if (!state.replyToMessage && state.pinedHashtag) {
|
||||||
commit('updateStatus', state.hashtags.map(t => ` #${t.name}`).join())
|
commit('updateInitialStatus', state.hashtags.map(t => ` #${t.name}`).join())
|
||||||
}
|
}
|
||||||
|
commit('changeModal', true)
|
||||||
dispatch('fetchVisibility')
|
dispatch('fetchVisibility')
|
||||||
},
|
},
|
||||||
closeModal ({ commit }) {
|
closeModal ({ commit }) {
|
||||||
commit('changeModal', false)
|
commit('changeModal', false)
|
||||||
commit('updateStatus', '')
|
commit('updateInitialStatus', '')
|
||||||
commit('setReplyTo', null)
|
commit('setReplyTo', null)
|
||||||
commit('changeBlockSubmit', false)
|
commit('changeBlockSubmit', false)
|
||||||
commit('clearAttachedMedias')
|
commit('clearAttachedMedias')
|
||||||
commit('changeSensitive', false)
|
commit('changeSensitive', false)
|
||||||
commit('updateSpoiler', '')
|
|
||||||
commit('changeVisibilityValue', Visibility.Public.value)
|
commit('changeVisibilityValue', Visibility.Public.value)
|
||||||
},
|
},
|
||||||
uploadImage ({ state, commit, rootState }, image) {
|
uploadImage ({ state, commit, rootState }, image) {
|
||||||
|
|
Loading…
Reference in New Issue