Skip to content

Commit

Permalink
fix: redraw page when deleting file (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca authored Nov 10, 2024
1 parent 6710366 commit 70bb0d6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions js/src/forum/components/UploadsUserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,41 @@ import type Mithril from 'mithril';
import User from 'flarum/common/models/User';
import FileListState from '../../common/states/FileListState';

import type File from '../../common/models/File';

export default class UploadsUserPage extends UserPage {
oninit(vnode: Mithril.Vnode) {
fileState!: FileListState;

oninit(vnode: Mithril.Vnode<this>) {
super.oninit(vnode);

this.user = null;
this.fileState = new FileListState();

this.loadUser(m.route.param('username'));
}

content() {
const fileState = new FileListState();
if (app.session.user && (app.session.user.viewOthersMediaLibrary() || this.user === app.session.user)) {
return (
this.user &&
UserFileList.component({
user: this.user,
selectable: false,
downloadOnClick: true,
fileState,
fileState: this.fileState,
onDelete: this.onDelete.bind(this),
})
);
} else {
return null;
}
}

onDelete(file: File) {
this.fileState.removeFromList(file);
}

show(user: User) {
super.show(user);
this.user = user;
Expand Down

0 comments on commit 70bb0d6

Please sign in to comment.