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

Add ability to mute keywords from chat #413

Merged
merged 4 commits into from
Nov 13, 2024
Merged

Conversation

zeykafx
Copy link
Contributor

@zeykafx zeykafx commented Nov 10, 2024

This PR adds the ability for users to mute specific keywords in the chat.
It adds a section in the chat settings. Besides the bottom sheet with a text field, there is a switch that makes the app only match whole words instead of words containing the keyword (for example, if someone wants to mute "W"s but doesn't want words with "w" to be filtered).

Related to issue #400

demo_muted_words_1731245646.mp4

Copy link

vercel bot commented Nov 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
frostyapp ⬜️ Ignored (Inspect) Visit Preview Nov 13, 2024 2:39am

lib/screens/settings/stores/settings_store.dart Outdated Show resolved Hide resolved
lib/screens/settings/stores/settings_store.dart Outdated Show resolved Hide resolved
lib/screens/settings/stores/settings_store.dart Outdated Show resolved Hide resolved
lib/screens/channel/chat/stores/chat_store.dart Outdated Show resolved Hide resolved
Created a json converter to to serialize the observable list of muted keywords, this required a static method for the default value. Also moved the logic for the muted keyword widget to the widget itself
@zeykafx
Copy link
Contributor Author

zeykafx commented Nov 11, 2024

I made the SettingsMutedWords widget stateful and moved the logic from the store there. While I was at it, I added a JSON converter to convert the observable list to a normal list (for JSON serialization). This required a static method that returns an observable list as the default value. This change removed the hack needed when using a normal list.

@tommyxchow tommyxchow self-requested a review November 12, 2024 02:31
Copy link
Owner

@tommyxchow tommyxchow left a comment

Choose a reason for hiding this comment

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

Pretty cool solution but for this case and simplicity, I think we should just use a normal list/array, then instead of mutating the list/array, re-assign it in an immutable style so that Mobx will detect that the variable changed.

lib/screens/settings/stores/settings_store.dart Outdated Show resolved Hide resolved
lib/screens/settings/widgets/settings_muted_words.dart Outdated Show resolved Hide resolved
lib/screens/settings/stores/settings_store.dart Outdated Show resolved Hide resolved
@zeykafx
Copy link
Contributor Author

zeykafx commented Nov 12, 2024

Sounds good, I’ve made the changes. It was indeed a bit overkill, perhaps!

@tommyxchow tommyxchow self-requested a review November 13, 2024 02:40
Copy link
Owner

@tommyxchow tommyxchow left a comment

Choose a reason for hiding this comment

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

Looks great, thank you so much!

@tommyxchow tommyxchow merged commit a761902 into tommyxchow:main Nov 13, 2024
2 checks passed
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