- Comming soon
+
+
General
+
+
Sounds
+
+
+
+ Favourite, Reblog action sound: |
+
+
+
+ |
+
+
+ Toot action sound: |
+
+
+
+ |
+
+
+
+
diff --git a/src/renderer/store/Preferences/General.js b/src/renderer/store/Preferences/General.js
index 6c55d116..37c9b90b 100644
--- a/src/renderer/store/Preferences/General.js
+++ b/src/renderer/store/Preferences/General.js
@@ -1,8 +1,62 @@
+import { ipcRenderer } from 'electron'
+
const General = {
namespaced: true,
- state: {},
- mutations: {},
- actions: {}
+ state: {
+ general: {
+ sound: {
+ fav_rb: true,
+ toot: true
+ }
+ },
+ loading: false
+ },
+ mutations: {
+ updateGeneral (state, conf) {
+ state.general = conf
+ },
+ changeLoading (state, value) {
+ state.loading = value
+ }
+ },
+ actions: {
+ loadGeneral ({ commit }) {
+ return new Promise((resolve, reject) => {
+ ipcRenderer.send('get-preferences')
+ ipcRenderer.once('error-get-preferences', (event, err) => {
+ ipcRenderer.removeAllListeners('response-get-preferences')
+ reject(err)
+ })
+ ipcRenderer.once('response-get-preferences', (event, conf) => {
+ ipcRenderer.removeAllListeners('error-get-preferences')
+ console.log(conf)
+ commit('updateGeneral', conf.general)
+ resolve(conf)
+ })
+ })
+ },
+ updateSound ({ commit, state }, sound) {
+ commit('changeLoading', true)
+ const newSound = Object.assign({}, state.general.sound, sound)
+ const newGeneral = Object.assign({}, state.general, {
+ sound: newSound
+ })
+ const config = {
+ general: newGeneral
+ }
+ ipcRenderer.send('save-preferences', config)
+ ipcRenderer.once('error-save-preferences', (event, err) => {
+ ipcRenderer.removeAllListeners('response-save-preferences')
+ commit('changeLoading', false)
+ })
+ ipcRenderer.once('response-save-preferences', (event, conf) => {
+ ipcRenderer.removeAllListeners('error-save-preferences')
+ console.log(conf)
+ commit('updateGeneral', conf.general)
+ commit('changeLoading', false)
+ })
+ }
+ }
}
export default General
From 5a42fa767b8413b1b7b908420ca1af2c64e43ac7 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 7 Apr 2018 22:47:15 +0900
Subject: [PATCH 2/3] refs #193 Set default preferences page is general
---
src/renderer/store/App.js | 2 +-
src/renderer/store/Preferences/General.js | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/renderer/store/App.js b/src/renderer/store/App.js
index 6a1b70c9..83c9ea7d 100644
--- a/src/renderer/store/App.js
+++ b/src/renderer/store/App.js
@@ -8,7 +8,7 @@ const App = {
actions: {
watchShortcutsEvents () {
ipcRenderer.on('open-preferences', (event) => {
- router.push('/preferences/account')
+ router.push('/preferences/general')
})
},
removeShortcutsEvents () {
diff --git a/src/renderer/store/Preferences/General.js b/src/renderer/store/Preferences/General.js
index 37c9b90b..518e28d0 100644
--- a/src/renderer/store/Preferences/General.js
+++ b/src/renderer/store/Preferences/General.js
@@ -22,15 +22,17 @@ const General = {
actions: {
loadGeneral ({ commit }) {
return new Promise((resolve, reject) => {
+ commit('changeLoading', true)
ipcRenderer.send('get-preferences')
ipcRenderer.once('error-get-preferences', (event, err) => {
ipcRenderer.removeAllListeners('response-get-preferences')
+ commit('changeLoading', false)
reject(err)
})
ipcRenderer.once('response-get-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-get-preferences')
- console.log(conf)
commit('updateGeneral', conf.general)
+ commit('changeLoading', false)
resolve(conf)
})
})
@@ -51,7 +53,6 @@ const General = {
})
ipcRenderer.once('response-save-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-save-preferences')
- console.log(conf)
commit('updateGeneral', conf.general)
commit('changeLoading', false)
})
From 5b79bc1181c23fa3f492ad326270fe8e72976240 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 7 Apr 2018 23:18:20 +0900
Subject: [PATCH 3/3] refs #193 Check preferences before sound
---
src/main/index.js | 42 ++++++++++++-------
.../TimelineSpace/Contents/Cards/Toot.js | 4 +-
.../store/TimelineSpace/Modals/NewToot.js | 2 +-
3 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/src/main/index.js b/src/main/index.js
index d19aa286..c3a560e2 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -45,6 +45,10 @@ const preferencesDBPath = process.env.NODE_ENV === 'production'
? userData + './db/preferences.json'
: 'preferences.json'
+const soundBasePath = process.env.NODE_ENV === 'development'
+ ? path.join(__dirname, '../../build/sounds/')
+ : path.join(process.resourcesPath, 'build/sounds/')
+
async function listAccounts () {
try {
const account = new Account(accountDB)
@@ -449,22 +453,32 @@ ipcMain.on('stop-public-streaming', (event, _) => {
})
// sounds
-ipcMain.on('operation-sound01', (event, _) => {
- const sound = process.env.NODE_ENV === 'development'
- ? path.join(__dirname, '../../build/sounds/operation_sound01.wav')
- : path.join(process.resourcesPath, 'build/sounds/operation_sound01.wav')
- simplayer(sound, (err) => {
- if (err) log.error(err)
- })
+ipcMain.on('fav-rt-action-sound', (event, _) => {
+ const preferences = new Preferences(preferencesDBPath)
+ preferences.load()
+ .then((conf) => {
+ if (conf.general.sound.fav_rb) {
+ const sound = path.join(soundBasePath, 'operation_sound01.wav')
+ simplayer(sound, (err) => {
+ if (err) log.error(err)
+ })
+ }
+ })
+ .catch(err => log.error(err))
})
-ipcMain.on('operation-sound02', (event, _) => {
- const sound = process.env.NODE_ENV === 'development'
- ? path.join(__dirname, '../../build/sounds/operation_sound02.wav')
- : path.join(process.resourcesPath, 'build/sounds/operation_sound02.wav')
- simplayer(sound, (err) => {
- if (err) log.error(err)
- })
+ipcMain.on('toot-action-sound', (event, _) => {
+ const preferences = new Preferences(preferencesDBPath)
+ preferences.load()
+ .then((conf) => {
+ if (conf.general.sound.toot) {
+ const sound = path.join(soundBasePath, 'operation_sound02.wav')
+ simplayer(sound, (err) => {
+ if (err) log.error(err)
+ })
+ }
+ })
+ .catch(err => log.error(err))
})
// preferences
diff --git a/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js b/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js
index 32c0f8e9..452ae3a1 100644
--- a/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js
+++ b/src/renderer/store/TimelineSpace/Contents/Cards/Toot.js
@@ -20,7 +20,7 @@ const Toot = {
// Reblog target status is in the data.reblog.
// So I send data.reblog as status for update local timeline.
commit('TimelineSpace/updateToot', data.reblog, { root: true })
- ipcRenderer.send('operation-sound01')
+ ipcRenderer.send('fav-rt-action-sound')
resolve(data.reblog)
})
})
@@ -51,7 +51,7 @@ const Toot = {
client.post(`/statuses/${message.id}/favourite`, {}, (err, data, res) => {
if (err) return reject(err)
commit('TimelineSpace/updateToot', data, { root: true })
- ipcRenderer.send('operation-sound01')
+ ipcRenderer.send('fav-rt-action-sound')
resolve(data)
})
})
diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot.js b/src/renderer/store/TimelineSpace/Modals/NewToot.js
index ace6ed27..0b3ca821 100644
--- a/src/renderer/store/TimelineSpace/Modals/NewToot.js
+++ b/src/renderer/store/TimelineSpace/Modals/NewToot.js
@@ -48,7 +48,7 @@ const NewToot = {
)
client.post('/statuses', form, (err, data, res) => {
if (err) return reject(err)
- ipcRenderer.send('operation-sound02')
+ ipcRenderer.send('toot-action-sound')
resolve(res)
})
})