diff --git a/bin/svgs.js b/bin/svgs.js index f99d5ed..19ee38b 100644 --- a/bin/svgs.js +++ b/bin/svgs.js @@ -44,5 +44,6 @@ module.exports = [ { id: 'fa-angle-right', src: 'src/thirdparty/font-awesome-svg-png/white/svg/angle-right.svg' }, { id: 'fa-search-minus', src: 'src/thirdparty/font-awesome-svg-png/white/svg/search-minus.svg' }, { id: 'fa-search-plus', src: 'src/thirdparty/font-awesome-svg-png/white/svg/search-plus.svg' }, - { id: 'fa-share-square-o', src: 'src/thirdparty/font-awesome-svg-png/white/svg/share-square-o.svg' } + { id: 'fa-share-square-o', src: 'src/thirdparty/font-awesome-svg-png/white/svg/share-square-o.svg' }, + { id: 'fa-flag', src: 'src/thirdparty/font-awesome-svg-png/white/svg/flag.svg' } ] diff --git a/src/routes/_actions/getRecentStatusesForAccount.js b/src/routes/_actions/getRecentStatusesForAccount.js new file mode 100644 index 0000000..9845604 --- /dev/null +++ b/src/routes/_actions/getRecentStatusesForAccount.js @@ -0,0 +1,7 @@ +import { store } from '../_store/store' +import { getTimeline } from '../_api/timelines' + +export async function getRecentStatusesForAccount (accountId) { + const { currentInstance, accessToken } = store.get() + return getTimeline(currentInstance, accessToken, `account/${accountId}`, null, null, 20) +} diff --git a/src/routes/_actions/report.js b/src/routes/_actions/report.js new file mode 100644 index 0000000..55aef1f --- /dev/null +++ b/src/routes/_actions/report.js @@ -0,0 +1,6 @@ +import { importShowReportDialog } from '../_components/dialog/asyncDialogs' + +export async function reportStatusOrAccount ({ status, account }) { + let showReportDialog = await importShowReportDialog() + showReportDialog({ status, account }) +} diff --git a/src/routes/_actions/reportStatuses.js b/src/routes/_actions/reportStatuses.js new file mode 100644 index 0000000..fc67bf7 --- /dev/null +++ b/src/routes/_actions/reportStatuses.js @@ -0,0 +1,13 @@ +import { store } from '../_store/store' +import { toast } from '../_components/toast/toast' +import { report } from '../_api/report' + +export async function reportStatuses (account, statusIds, comment, forward) { + let { currentInstance, accessToken } = store.get() + try { + await report(currentInstance, accessToken, account.id, statusIds, comment, forward) + toast.say('Submitted report') + } catch (e) { + toast.say('Failed to report: ' + (e.message || '')) + } +} diff --git a/src/routes/_api/report.js b/src/routes/_api/report.js new file mode 100644 index 0000000..97afeab --- /dev/null +++ b/src/routes/_api/report.js @@ -0,0 +1,12 @@ +import { auth, basename } from './utils' +import { post } from '../_utils/ajax' + +export async function report (instanceName, accessToken, accountId, statusIds, comment, forward) { + let url = `${basename(instanceName)}/api/v1/reports` + return post(url, { + account_id: accountId, + status_ids: statusIds, + comment, + forward + }, auth(accessToken)) +} diff --git a/src/routes/_components/dialog/asyncDialogs.js b/src/routes/_components/dialog/asyncDialogs.js index 0620010..feae882 100644 --- a/src/routes/_components/dialog/asyncDialogs.js +++ b/src/routes/_components/dialog/asyncDialogs.js @@ -39,3 +39,7 @@ export const importShowMediaDialog = () => import( export const importShowMuteDialog = () => import( /* webpackChunkName: 'showMuteDialog' */ './creators/showMuteDialog' ).then(getDefault) + +export const importShowReportDialog = () => import( + /* webpackChunkName: 'showReportDialog' */ './creators/showReportDialog' + ).then(getDefault) diff --git a/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html b/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html index fa4aa57..7774936 100644 --- a/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html +++ b/src/routes/_components/dialog/components/AccountProfileOptionsDialog.html @@ -21,6 +21,7 @@ import { setDomainBlocked } from '../../../_actions/setDomainBlocked' import { copyText } from '../../../_actions/copyText' import { composeNewStatusMentioning } from '../../../_actions/mention' import { toggleMute } from '../../../_actions/toggleMute' +import { reportStatusOrAccount } from '../../../_actions/report' export default { oncreate, @@ -75,11 +76,12 @@ export default { ? `Unhide ${domain}` : `Hide ${domain}` ), + reportLabel: ({ acct }) => `Report @${acct}`, items: ({ blockLabel, blocking, blockIcon, muteLabel, muteIcon, followLabel, followIcon, following, followRequested, accountId, verifyCredentialsId, acct, isUser, showReblogsLabel, - domain, blockDomainLabel + domain, blockDomainLabel, reportLabel }) => ([ !isUser && { key: 'mention', @@ -111,6 +113,11 @@ export default { label: blockDomainLabel, icon: '#fa-ban' }, + !isUser && { + key: 'report', + label: reportLabel, + icon: '#fa-flag' + }, { key: 'copy', label: 'Copy link to account', @@ -137,12 +144,14 @@ export default { return this.onBlockDomainClicked() case 'copy': return this.onCopyClicked() + case 'report': + return this.onReport() } }, async onMentionClicked () { let { account } = this.get() - await composeNewStatusMentioning(account) this.close() + await composeNewStatusMentioning(account) }, async onFollowClicked () { let { accountId, following } = this.get() @@ -174,6 +183,11 @@ export default { let { url } = account this.close() await copyText(url) + }, + async onReport () { + let { account } = this.get() + this.close() + await reportStatusOrAccount({ account }) } }, components: { diff --git a/src/routes/_components/dialog/components/GenericConfirmationDialog.html b/src/routes/_components/dialog/components/GenericConfirmationDialog.html index a090c71..c6b8c57 100644 --- a/src/routes/_components/dialog/components/GenericConfirmationDialog.html +++ b/src/routes/_components/dialog/components/GenericConfirmationDialog.html @@ -2,6 +2,7 @@ {id} {label} {title} + {className} background="var(--main-bg)" >