mirror of
https://github.com/flarum/core.git
synced 2025-08-06 00:17:31 +02:00
feat(pm): delete own messages (#4180)
This commit is contained in:
@@ -12,6 +12,7 @@ export type SettingDropdownOption = {
|
||||
export interface ISettingDropdownAttrs extends ISelectDropdownAttrs {
|
||||
setting?: string;
|
||||
options: Array<SettingDropdownOption>;
|
||||
default: any;
|
||||
}
|
||||
|
||||
export default class SettingDropdown<CustomAttrs extends ISettingDropdownAttrs = ISettingDropdownAttrs> extends SelectDropdown<CustomAttrs> {
|
||||
@@ -33,7 +34,7 @@ export default class SettingDropdown<CustomAttrs extends ISettingDropdownAttrs =
|
||||
return super.view({
|
||||
...vnode,
|
||||
children: this.attrs.options.map(({ value, label }) => {
|
||||
const active = app.data.settings[this.attrs.setting!] === value;
|
||||
const active = (app.data.settings[this.attrs.setting!] ?? this.attrs.default) === value;
|
||||
|
||||
return (
|
||||
<Button icon={active ? 'fas fa-check' : true} onclick={saveSettings.bind(this, { [this.attrs.setting!]: value })} active={active}>
|
||||
|
@@ -391,4 +391,12 @@ export default abstract class PaginatedListState<T extends Model, P extends Pagi
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
remove(model: T): void {
|
||||
const page = this.pages.find((pg) => pg.items.includes(model));
|
||||
|
||||
if (page) {
|
||||
page.items = page.items.filter((item) => item !== model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,8 +20,9 @@ const PostControls = {
|
||||
controls(post, context) {
|
||||
const items = new ItemList();
|
||||
|
||||
['user', 'moderation', 'destructive'].forEach((section) => {
|
||||
const controls = this[section + 'Controls'](post, context).toArray();
|
||||
Object.entries(this.sections()).forEach(([section, method]) => {
|
||||
const controls = method.call(this, post, context).toArray();
|
||||
|
||||
if (controls.length) {
|
||||
controls.forEach((item) => items.add(item.itemName, item));
|
||||
items.add(section + 'Separator', <Separator />);
|
||||
@@ -31,6 +32,14 @@ const PostControls = {
|
||||
return items;
|
||||
},
|
||||
|
||||
sections() {
|
||||
return {
|
||||
user: this.userControls,
|
||||
moderation: this.moderationControls,
|
||||
destructive: this.destructiveControls,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Get controls for a post pertaining to the current user (e.g. report).
|
||||
*
|
||||
|
Reference in New Issue
Block a user