Merge pull request #469 from h3poteto/iss-461
closes #461 Add toot visibility setting and use it in new toot modal
This commit is contained in:
commit
bc0f320708
18
src/constants/visibility.js
Normal file
18
src/constants/visibility.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export default {
|
||||||
|
Public: {
|
||||||
|
name: 'public',
|
||||||
|
value: 0
|
||||||
|
},
|
||||||
|
Unlisted: {
|
||||||
|
name: 'unlisted',
|
||||||
|
value: 1
|
||||||
|
},
|
||||||
|
Private: {
|
||||||
|
name: 'private',
|
||||||
|
value: 2
|
||||||
|
},
|
||||||
|
Direct: {
|
||||||
|
name: 'direct',
|
||||||
|
value: 3
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import storage from 'electron-json-storage'
|
import storage from 'electron-json-storage'
|
||||||
import objectAssignDeep from 'object-assign-deep'
|
import objectAssignDeep from 'object-assign-deep'
|
||||||
|
import Visibility from '../constants/visibility'
|
||||||
|
|
||||||
const Base = {
|
const Base = {
|
||||||
general: {
|
general: {
|
||||||
@ -9,7 +10,8 @@ const Base = {
|
|||||||
},
|
},
|
||||||
theme: 'white',
|
theme: 'white',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
displayNameStyle: 0
|
displayNameStyle: 0,
|
||||||
|
tootVisibility: Visibility.Public.value
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
collapse: false
|
collapse: false
|
||||||
|
@ -34,6 +34,26 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="toot">
|
||||||
|
<h3>Toot</h3>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="title">Default Visibility:</td>
|
||||||
|
<td class="status">
|
||||||
|
<el-select v-model="tootVisibility" placeholder="visibility">
|
||||||
|
<el-option
|
||||||
|
v-for="v in visibilities"
|
||||||
|
:key="v.value"
|
||||||
|
:label="v.name"
|
||||||
|
:value="v.value">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
<div class="sounds">
|
<div class="sounds">
|
||||||
<h3>Sounds</h3>
|
<h3>Sounds</h3>
|
||||||
<table>
|
<table>
|
||||||
@ -64,6 +84,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
import Visibility from '../../../constants/visibility'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'general',
|
name: 'general',
|
||||||
@ -82,6 +103,11 @@ export default {
|
|||||||
name: 'username',
|
name: 'username',
|
||||||
value: 2
|
value: 2
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
visibilities: [
|
||||||
|
Visibility.Public,
|
||||||
|
Visibility.Unlisted,
|
||||||
|
Visibility.Private
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -106,6 +132,14 @@ export default {
|
|||||||
this.$store.dispatch('Preferences/General/updateDisplayNameStyle', value)
|
this.$store.dispatch('Preferences/General/updateDisplayNameStyle', value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
tootVisibility: {
|
||||||
|
get () {
|
||||||
|
return this.$store.state.Preferences.General.general.tootVisibility
|
||||||
|
},
|
||||||
|
set (value) {
|
||||||
|
this.$store.dispatch('Preferences/General/updateTootVisibility', value)
|
||||||
|
}
|
||||||
|
},
|
||||||
sound_fav_rb: {
|
sound_fav_rb: {
|
||||||
get () {
|
get () {
|
||||||
return this.$store.state.Preferences.General.general.sound.fav_rb
|
return this.$store.state.Preferences.General.general.sound.fav_rb
|
||||||
@ -146,52 +180,40 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
#general {
|
#general {
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
text-align: right;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
width: 50%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.appearance {
|
.appearance {
|
||||||
color: var(--theme-secondary-color);
|
color: var(--theme-secondary-color);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
.toot {
|
||||||
width: 100%;
|
color: var(--theme-secondary-color);
|
||||||
}
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
td {
|
|
||||||
padding: 16px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
text-align: right;
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status {
|
|
||||||
width: 50%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sounds {
|
.sounds {
|
||||||
color: var(--theme-secondary-color);
|
color: var(--theme-secondary-color);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
padding: 16px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
text-align: right;
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status {
|
|
||||||
width: 50%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
import Visibility from '../../../../constants/visibility'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'new-toot',
|
name: 'new-toot',
|
||||||
@ -79,13 +80,13 @@ export default {
|
|||||||
sensitive: state => state.TimelineSpace.Modals.NewToot.sensitive,
|
sensitive: state => state.TimelineSpace.Modals.NewToot.sensitive,
|
||||||
visibilityIcon: (state) => {
|
visibilityIcon: (state) => {
|
||||||
switch (state.TimelineSpace.Modals.NewToot.visibility) {
|
switch (state.TimelineSpace.Modals.NewToot.visibility) {
|
||||||
case 'public':
|
case Visibility.Public.value:
|
||||||
return 'globe'
|
return 'globe'
|
||||||
case 'unlisted':
|
case Visibility.Unlisted.value:
|
||||||
return 'unlock'
|
return 'unlock'
|
||||||
case 'private':
|
case Visibility.Private.value:
|
||||||
return 'lock'
|
return 'lock'
|
||||||
case 'direct':
|
case Visibility.Direct.value:
|
||||||
return 'envelope'
|
return 'envelope'
|
||||||
default:
|
default:
|
||||||
return 'globe'
|
return 'globe'
|
||||||
@ -146,9 +147,12 @@ export default {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const visibilityKey = Object.keys(Visibility).find((key) => {
|
||||||
|
return Visibility[key].value === this.visibility
|
||||||
|
})
|
||||||
let form = {
|
let form = {
|
||||||
status: this.status,
|
status: this.status,
|
||||||
visibility: this.visibility,
|
visibility: Visibility[visibilityKey].name,
|
||||||
sensitive: this.sensitive,
|
sensitive: this.sensitive,
|
||||||
spoiler_text: this.spoiler
|
spoiler_text: this.spoiler
|
||||||
}
|
}
|
||||||
@ -209,7 +213,7 @@ export default {
|
|||||||
this.$store.commit('TimelineSpace/Modals/NewToot/removeMedia', media)
|
this.$store.commit('TimelineSpace/Modals/NewToot/removeMedia', media)
|
||||||
},
|
},
|
||||||
changeVisibility (level) {
|
changeVisibility (level) {
|
||||||
this.$store.commit('TimelineSpace/Modals/NewToot/changeVisibility', level)
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/changeVisibility', level)
|
||||||
},
|
},
|
||||||
changeSensitive () {
|
changeSensitive () {
|
||||||
this.$store.commit('TimelineSpace/Modals/NewToot/changeSensitive', !this.sensitive)
|
this.$store.commit('TimelineSpace/Modals/NewToot/changeSensitive', !this.sensitive)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
|
import Visibility from '../../../constants/visibility'
|
||||||
|
|
||||||
const General = {
|
const General = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
@ -10,7 +11,8 @@ const General = {
|
|||||||
},
|
},
|
||||||
theme: 'white',
|
theme: 'white',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
displayNameStyle: 0
|
displayNameStyle: 0,
|
||||||
|
tootVisibility: Visibility.Public.value
|
||||||
},
|
},
|
||||||
loading: false
|
loading: false
|
||||||
},
|
},
|
||||||
@ -94,6 +96,23 @@ const General = {
|
|||||||
commit('updateGeneral', conf.general)
|
commit('updateGeneral', conf.general)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
updateTootVisibility ({ dispatch, commit, state }, value) {
|
||||||
|
const newGeneral = Object.assign({}, state.general, {
|
||||||
|
tootVisibility: value
|
||||||
|
})
|
||||||
|
const config = {
|
||||||
|
general: newGeneral
|
||||||
|
}
|
||||||
|
ipcRenderer.send('save-preferences', config)
|
||||||
|
ipcRenderer.once('error-save-preferences', (event, err) => {
|
||||||
|
ipcRenderer.removeAllListeners('response-save-preferences')
|
||||||
|
})
|
||||||
|
ipcRenderer.once('response-save-preferences', (event, conf) => {
|
||||||
|
ipcRenderer.removeAllListeners('error-save-preferences')
|
||||||
|
dispatch('App/loadPreferences', null, { root: true })
|
||||||
|
commit('updateGeneral', conf.general)
|
||||||
|
})
|
||||||
|
},
|
||||||
updateSound ({ commit, state }, sound) {
|
updateSound ({ commit, state }, sound) {
|
||||||
commit('changeLoading', true)
|
commit('changeLoading', true)
|
||||||
const newSound = Object.assign({}, state.general.sound, sound)
|
const newSound = Object.assign({}, state.general.sound, sound)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import Mastodon from 'megalodon'
|
import Mastodon from 'megalodon'
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
|
import Visibility from '../../../../constants/visibility'
|
||||||
|
|
||||||
const NewToot = {
|
const NewToot = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
@ -9,7 +10,7 @@ const NewToot = {
|
|||||||
replyToMessage: null,
|
replyToMessage: null,
|
||||||
blockSubmit: false,
|
blockSubmit: false,
|
||||||
attachedMedias: [],
|
attachedMedias: [],
|
||||||
visibility: 'public',
|
visibility: Visibility.Public.value,
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
spoiler: '',
|
spoiler: '',
|
||||||
attachedMediaId: 0
|
attachedMediaId: 0
|
||||||
@ -36,7 +37,22 @@ const NewToot = {
|
|||||||
removeMedia (state, media) {
|
removeMedia (state, media) {
|
||||||
state.attachedMedias = state.attachedMedias.filter(m => m.id !== media.id)
|
state.attachedMedias = state.attachedMedias.filter(m => m.id !== media.id)
|
||||||
},
|
},
|
||||||
changeVisibility (state, value) {
|
/**
|
||||||
|
* changeVisibility
|
||||||
|
* Update visibility using Visibility constants
|
||||||
|
* @param state vuex state object
|
||||||
|
* @param visibility Visibility constants object
|
||||||
|
**/
|
||||||
|
changeVisibility (state, visibility) {
|
||||||
|
state.visibility = visibility.value
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* changeVisibilityValue
|
||||||
|
* Update visibility using direct value
|
||||||
|
* @param state vuex state object
|
||||||
|
* @param value visibility value
|
||||||
|
**/
|
||||||
|
changeVisibilityValue (state, value) {
|
||||||
state.visibility = value
|
state.visibility = value
|
||||||
},
|
},
|
||||||
changeSensitive (state, value) {
|
changeSensitive (state, value) {
|
||||||
@ -64,17 +80,21 @@ const NewToot = {
|
|||||||
return res.data
|
return res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
openReply ({ commit, rootState }, message) {
|
openReply ({ dispatch, commit, rootState }, message) {
|
||||||
commit('setReplyTo', message)
|
commit('setReplyTo', message)
|
||||||
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('changeModal', true)
|
commit('changeModal', true)
|
||||||
commit('updateStatus', `${mentionAccounts.map(m => `@${m}`).join(' ')} `)
|
commit('updateStatus', `${mentionAccounts.map(m => `@${m}`).join(' ')} `)
|
||||||
commit('changeVisibility', message.visibility)
|
dispatch('changeVisibility', message.visibility)
|
||||||
},
|
},
|
||||||
openModal ({ commit }) {
|
openModal ({ dispatch, commit }) {
|
||||||
commit('changeModal', true)
|
commit('changeModal', true)
|
||||||
|
ipcRenderer.send('get-preferences')
|
||||||
|
ipcRenderer.once('response-get-preferences', (event, conf) => {
|
||||||
|
commit('changeVisibilityValue', conf.general.tootVisibility)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
closeModal ({ commit }) {
|
closeModal ({ commit }) {
|
||||||
commit('changeModal', false)
|
commit('changeModal', false)
|
||||||
@ -84,7 +104,7 @@ const NewToot = {
|
|||||||
commit('clearAttachedMedias')
|
commit('clearAttachedMedias')
|
||||||
commit('changeSensitive', false)
|
commit('changeSensitive', false)
|
||||||
commit('updateSpoiler', '')
|
commit('updateSpoiler', '')
|
||||||
commit('changeVisibility', 'public')
|
commit('changeVisibility', Visibility.Public)
|
||||||
},
|
},
|
||||||
uploadImage ({ state, commit, rootState }, image) {
|
uploadImage ({ state, commit, rootState }, image) {
|
||||||
commit('changeBlockSubmit', true)
|
commit('changeBlockSubmit', true)
|
||||||
@ -115,6 +135,18 @@ const NewToot = {
|
|||||||
},
|
},
|
||||||
resetMediaId ({ commit }) {
|
resetMediaId ({ commit }) {
|
||||||
commit('updateMediaId', 0)
|
commit('updateMediaId', 0)
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* changeVisibility
|
||||||
|
* @param commit vuex commit object
|
||||||
|
* @param level visibility level string object
|
||||||
|
**/
|
||||||
|
changeVisibility ({ commit }, level) {
|
||||||
|
Object.keys(Visibility).map((key, index) => {
|
||||||
|
if (Visibility[key].name === level) {
|
||||||
|
commit('changeVisibility', Visibility[key])
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user