diff --git a/src/routes/_actions/mute.js b/src/routes/_actions/mute.js index 5c38702..549bc06 100644 --- a/src/routes/_actions/mute.js +++ b/src/routes/_actions/mute.js @@ -4,12 +4,12 @@ import { toast } from '../_components/toast/toast' import { updateLocalRelationship } from './accounts' import { emit } from '../_utils/eventBus' -export async function setAccountMuted (accountId, mute, toastOnSuccess) { +export async function setAccountMuted (accountId, mute, notifications, toastOnSuccess) { let { currentInstance, accessToken } = store.get() try { let relationship if (mute) { - relationship = await muteAccount(currentInstance, accessToken, accountId) + relationship = await muteAccount(currentInstance, accessToken, accountId, notifications) } else { relationship = await unmuteAccount(currentInstance, accessToken, accountId) } diff --git a/src/routes/_actions/toggleMute.js b/src/routes/_actions/toggleMute.js new file mode 100644 index 0000000..4db5930 --- /dev/null +++ b/src/routes/_actions/toggleMute.js @@ -0,0 +1,10 @@ +import { importShowMuteDialog } from '../_components/dialog/asyncDialogs' +import { setAccountMuted } from './mute' + +export async function toggleMute (account, mute) { + if (mute) { + (await importShowMuteDialog())(account) + } else { + await setAccountMuted(account.id, mute, /* notifications */ false, /* toastOnSuccess */ true) + } +} diff --git a/src/routes/_api/mute.js b/src/routes/_api/mute.js index c090313..64d22e8 100644 --- a/src/routes/_api/mute.js +++ b/src/routes/_api/mute.js @@ -1,9 +1,9 @@ import { auth, basename } from './utils' import { post, WRITE_TIMEOUT } from '../_utils/ajax' -export async function muteAccount (instanceName, accessToken, accountId) { +export async function muteAccount (instanceName, accessToken, accountId, notifications) { let url = `${basename(instanceName)}/api/v1/accounts/${accountId}/mute` - return post(url, null, auth(accessToken), { timeout: WRITE_TIMEOUT }) + return post(url, { notifications }, auth(accessToken), { timeout: WRITE_TIMEOUT }) } export async function unmuteAccount (instanceName, accessToken, accountId) { diff --git a/src/routes/_components/dialog/asyncDialogs.js b/src/routes/_components/dialog/asyncDialogs.js index eb1b950..0620010 100644 --- a/src/routes/_components/dialog/asyncDialogs.js +++ b/src/routes/_components/dialog/asyncDialogs.js @@ -8,8 +8,8 @@ export const importShowComposeDialog = () => import( /* webpackChunkName: 'showComposeDialog' */ './creators/showComposeDialog' ).then(getDefault) -export const importShowConfirmationDialog = () => import( - /* webpackChunkName: 'showConfirmationDialog' */ './creators/showConfirmationDialog' +export const importShowTextConfirmationDialog = () => import( + /* webpackChunkName: 'showTextConfirmationDialog' */ './creators/showTextConfirmationDialog' ).then(getDefault) export const importShowEmojiDialog = () => import( @@ -35,3 +35,7 @@ export const importShowShortcutHelpDialog = () => import( export const importShowMediaDialog = () => import( /* webpackChunkName: 'showMediaDialog' */ './creators/showMediaDialog' ).then(getDefault) + +export const importShowMuteDialog = () => import( + /* webpackChunkName: 'showMuteDialog' */ './creators/showMuteDialog' + ).then(getDefault) diff --git a/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html b/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html index 0b449ce..fa4aa57 100644 --- a/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html +++ b/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html @@ -15,12 +15,12 @@ import { show } from '../helpers/showDialog' import { close } from '../helpers/closeDialog' import { oncreate } from '../helpers/onCreateDialog' import { setAccountBlocked } from '../../../_actions/block' -import { setAccountMuted } from '../../../_actions/mute' import { setAccountFollowed } from '../../../_actions/follow' import { setShowReblogs } from '../../../_actions/setShowReblogs' import { setDomainBlocked } from '../../../_actions/setDomainBlocked' import { copyText } from '../../../_actions/copyText' import { composeNewStatusMentioning } from '../../../_actions/mention' +import { toggleMute } from '../../../_actions/toggleMute' export default { oncreate, @@ -155,9 +155,9 @@ export default { await setAccountBlocked(accountId, !blocking, true) }, async onMuteClicked () { - let { accountId, muting } = this.get() + let { account, muting } = this.get() this.close() - await setAccountMuted(accountId, !muting, true) + await toggleMute(account, !muting) }, async onShowReblogsClicked () { let { accountId, showingReblogs } = this.get() diff --git a/src/routes/_components/dialog/components/ConfirmationDialog.html b/src/routes/_components/dialog/components/ConfirmationDialog.html index 120485c..9fde2ff 100644 --- a/src/routes/_components/dialog/components/ConfirmationDialog.html +++ b/src/routes/_components/dialog/components/ConfirmationDialog.html @@ -1,18 +1,21 @@
-

- {text} -

+ {#if component} + + {:else} +

{text}

+ {/if}
@@ -44,6 +47,15 @@ on('destroyDialog', this, this.onDestroyDialog) onCreateDialog.call(this) }, + data: () => ({ + component: void 0, + text: void 0, + onPositive: void 0, + onNegative: void 0, + title: '', + positiveText: 'OK', + negativeText: 'Cancel' + }), methods: { show, close, @@ -58,10 +70,12 @@ return } if (positiveResult) { + this.fire('positive') if (onPositive) { onPositive() } } else { + this.fire('negative') if (onNegative) { onNegative() } @@ -79,4 +93,4 @@ ModalDialog } } - \ No newline at end of file + diff --git a/src/routes/_components/dialog/components/GenericConfirmationDialog.html b/src/routes/_components/dialog/components/GenericConfirmationDialog.html new file mode 100644 index 0000000..a090c71 --- /dev/null +++ b/src/routes/_components/dialog/components/GenericConfirmationDialog.html @@ -0,0 +1,75 @@ + +
+ +
+ + +
+
+
+ + diff --git a/src/routes/_components/dialog/components/MuteDialog.html b/src/routes/_components/dialog/components/MuteDialog.html new file mode 100644 index 0000000..5815935 --- /dev/null +++ b/src/routes/_components/dialog/components/MuteDialog.html @@ -0,0 +1,60 @@ + +
+

+ Mute @{account.acct} ? +

+
+ + +
+
+
+ + diff --git a/src/routes/_components/dialog/components/StatusOptionsDialog.html b/src/routes/_components/dialog/components/StatusOptionsDialog.html index 7b389b4..e58901a 100644 --- a/src/routes/_components/dialog/components/StatusOptionsDialog.html +++ b/src/routes/_components/dialog/components/StatusOptionsDialog.html @@ -16,12 +16,12 @@ import { show } from '../helpers/showDialog' import { close } from '../helpers/closeDialog' import { oncreate } from '../helpers/onCreateDialog' import { setAccountBlocked } from '../../../_actions/block' -import { setAccountMuted } from '../../../_actions/mute' import { setStatusPinnedOrUnpinned } from '../../../_actions/pin' import { setConversationMuted } from '../../../_actions/muteConversation' import { copyText } from '../../../_actions/copyText' import { deleteAndRedraft } from '../../../_actions/deleteAndRedraft' import { shareStatus } from '../../../_actions/share' +import { toggleMute } from '../../../_actions/toggleMute' export default { oncreate, @@ -183,9 +183,9 @@ export default { await setAccountBlocked(accountId, !blocking, true) }, async onMuteClicked () { - let { accountId, muting } = this.get() + let { account, muting } = this.get() this.close() - await setAccountMuted(accountId, !muting, true) + await toggleMute(account, !muting) }, async onMuteConversationClicked () { let { statusId, mutingConversation } = this.get() diff --git a/src/routes/_components/dialog/components/TextConfirmationDialog.html b/src/routes/_components/dialog/components/TextConfirmationDialog.html new file mode 100644 index 0000000..a5f78e3 --- /dev/null +++ b/src/routes/_components/dialog/components/TextConfirmationDialog.html @@ -0,0 +1,38 @@ + +

{text}

+
+ + diff --git a/src/routes/_components/dialog/creators/showMuteDialog.js b/src/routes/_components/dialog/creators/showMuteDialog.js new file mode 100644 index 0000000..6911a9f --- /dev/null +++ b/src/routes/_components/dialog/creators/showMuteDialog.js @@ -0,0 +1,16 @@ +import MuteDialog from '../components/MuteDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' + +export default function showMuteDialog (account) { + let dialog = new MuteDialog({ + target: createDialogElement(), + data: { + id: createDialogId(), + label: 'Mute dialog', + account + } + }) + dialog.show() + return dialog +} diff --git a/src/routes/_components/dialog/creators/showConfirmationDialog.js b/src/routes/_components/dialog/creators/showTextConfirmationDialog.js similarity index 59% rename from src/routes/_components/dialog/creators/showConfirmationDialog.js rename to src/routes/_components/dialog/creators/showTextConfirmationDialog.js index 6b66011..7c0d6d2 100644 --- a/src/routes/_components/dialog/creators/showConfirmationDialog.js +++ b/src/routes/_components/dialog/creators/showTextConfirmationDialog.js @@ -1,9 +1,9 @@ -import ConfirmationDialog from '../components/ConfirmationDialog.html' +import TextConfirmationDialog from '../components/TextConfirmationDialog.html' import { createDialogElement } from '../helpers/createDialogElement' import { createDialogId } from '../helpers/createDialogId' -export default function showConfirmationDialog (options) { - let dialog = new ConfirmationDialog({ +export default function showTextConfirmationDialog (options) { + let dialog = new TextConfirmationDialog({ target: createDialogElement(), data: Object.assign({ id: createDialogId(), @@ -11,4 +11,5 @@ export default function showConfirmationDialog (options) { }, options) }) dialog.show() + return dialog } diff --git a/src/routes/_components/settings/instance/InstanceActions.html b/src/routes/_components/settings/instance/InstanceActions.html index d105e33..16a08e7 100644 --- a/src/routes/_components/settings/instance/InstanceActions.html +++ b/src/routes/_components/settings/instance/InstanceActions.html @@ -21,7 +21,7 @@