Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More moderation history #2649

Merged
merged 6 commits into from
Aug 3, 2024
Merged

More moderation history #2649

merged 6 commits into from
Aug 3, 2024

Conversation

dessalines
Copy link
Member

@dessalines dessalines commented Aug 3, 2024

Description

Adds ability to view a users moderation history for their item.

Also fixed some tribute issues.

Screenshots

After

Screenshot_20240803_103300_Via_1_1

Profile page:

Screenshot_20240803_105437_Via

@SleeplessOne1917
Copy link
Member

I thought we were making this viewable from the profile page?

@dessalines
Copy link
Member Author

I suppose I could add it there also.

@dessalines dessalines marked this pull request as draft August 3, 2024 14:46
@dessalines
Copy link
Member Author

K added it to the profile page also for admins, pic above.

@dessalines dessalines marked this pull request as ready for review August 3, 2024 14:56
Comment on lines +167 to +181
// The link and translation string for the item
const { modHistoryItemLink, modHistoryItemTranslation } =
type === "post"
? {
modHistoryItemLink: `/modlog?postId=${id}`,
modHistoryItemTranslation: I18NextService.i18n.t(
"post_moderation_history",
),
}
: {
modHistoryItemLink: `/modlog?commentId=${id}`,
modHistoryItemTranslation: I18NextService.i18n.t(
"comment_moderation_history",
),
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are moderation histories for specific posts and comments something admins use? I can't imagine that any given post or comment will be removed and restored so many times that this would be useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm... Ya I think it could be useful to see things that have been removed / restored multiple times. But more importantly, there might be more recent mod actions done on a person, and you might only want to see the mod history for that item, rather than going to the person and having to scroll through. Like a year old comment or something.

Comment on lines +94 to +110
async componentDidMount() {
if (isBrowser()) {
const tribute = await setupTribute();
const textarea: any = document.getElementById(this.id);
if (textarea) {
autosize(textarea);
tribute.attach(textarea);
textarea.addEventListener("tribute-replaced", () => {
this.setState({ content: textarea.value });
autosize.update(textarea);
});

this.quoteInsert();

if (this.props.focus) {
textarea.focus();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot more than how tributes are currently handled.

Copy link
Member Author

@dessalines dessalines Aug 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works but I'm also a bit scared that because this isn't a global import anymore, it might be doing a lot of work to re-import tribute for every single comment / markdown textarea.

Copy link
Member

@SleeplessOne1917 SleeplessOne1917 Aug 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be able to cache it in memory by making it a module scoped variable in markdown.ts. You can make it TranslationType | undefined (you can import only types with import type { default as TranslationType } from "tributejs", which shouldn't cause issues at runtime), check if it already exists in setupTribute, and only do the dynamic import if it doesn't exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it now, I wasn't able to type it because it uses a lot of generics unfortunately. But I added a console debug message, and it seems to only run once, and correctly.

Copy link
Member

@SleeplessOne1917 SleeplessOne1917 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test this out locally in about an hour or so when I have time.

@SleeplessOne1917
Copy link
Member

Just tested this. It works. Gonna merge.

@SleeplessOne1917 SleeplessOne1917 enabled auto-merge (squash) August 3, 2024 18:56
@SleeplessOne1917 SleeplessOne1917 merged commit 999b083 into main Aug 3, 2024
2 checks passed
@SleeplessOne1917 SleeplessOne1917 deleted the more_moderation_history branch August 3, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants