2018-05-13 05:49:01 +00:00
|
|
|
import { store } from '../_store/store'
|
|
|
|
import { muteConversation, unmuteConversation } from '../_api/muteConversation'
|
|
|
|
import { toast } from '../_utils/toast'
|
2018-08-30 02:03:12 +00:00
|
|
|
import { database } from '../_database/database'
|
2018-05-13 05:49:01 +00:00
|
|
|
|
|
|
|
export async function setConversationMuted (statusId, mute, toastOnSuccess) {
|
|
|
|
let { currentInstance, accessToken } = store.get()
|
|
|
|
try {
|
|
|
|
if (mute) {
|
|
|
|
await muteConversation(currentInstance, accessToken, statusId)
|
|
|
|
} else {
|
|
|
|
await unmuteConversation(currentInstance, accessToken, statusId)
|
|
|
|
}
|
2018-08-30 02:03:12 +00:00
|
|
|
await database.setStatusMuted(currentInstance, statusId, mute)
|
2018-05-13 05:49:01 +00:00
|
|
|
if (toastOnSuccess) {
|
|
|
|
if (mute) {
|
|
|
|
toast.say('Muted conversation')
|
|
|
|
} else {
|
|
|
|
toast.say('Unmuted conversation')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
toast.say(`Unable to ${mute ? 'mute' : 'unmute'} conversation: ` + (e.message || ''))
|
|
|
|
}
|
|
|
|
}
|