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

[Subscriptions] User setting to automatically follow discussions you start/reply to #310

Closed
tobyzerner opened this issue Aug 29, 2015 · 3 comments

Comments

@tobyzerner
Copy link
Contributor

From @tobscure on July 28, 2015 6:46

What needs to be done:

  • Register a new bool preference (followAfterReply) using the RegisterUserPreferences event.
  • Extend the core SettingsPage component's settingsItems method to add a new child to the notifications fieldset. That child should be a Switch which saves the followAfterReply preference.
  • Listen for the PostWasPosted event and check the preference. If it's true, follow the discussion.

Copied from original issue: flarum/subscriptions#1

@tobyzerner tobyzerner changed the title User setting to automatically follow discussions you start/reply to [Subscriptions] User setting to automatically follow discussions you start/reply to Aug 29, 2015
@tobyzerner tobyzerner mentioned this issue Aug 29, 2015
53 tasks
@tobyzerner tobyzerner added this to the 0.1.0-beta.4 milestone Sep 4, 2015
@petermein
Copy link
Contributor

I started working on this issue. Its almost done but i have question about the implementation.

Referencing: flarum/subscriptions#6

Lets see subscriptions are managed in the subscriptions extension. I added 2 listeners here to add the setting and to listen to a new post. This works fine.
But now i want to add a setting to the settings page, this is also not that hard but the settings page is part of the core. So i would like to add some sort of addition to the settings page from an extension. Is there i method for this?

Example on how i implemented the settings now:

Add a new section to the settings list

    items.add('forum',
      FieldSet.component({
        label: app.translator.trans('core.forum.settings.forum'),
        className: 'Settings-forum',
        children: this.forumItems().toArray()
      })
    );

Implement the items under the heading

  forumItems() {
    const items = new ItemList();

    items.add('followAfterReply',
      Switch.component({
        children: app.translator.trans('core.forum.settings.follow_after_reply'),
        state: this.user.preferences().followAfterReply,
        onchange: (value, component) => {
          this.preferenceSaver('followAfterReply')(value, component);
        }
      })
    );

    return items;
  }

Everything works but i would like to move everything to the subscription extension.

@tobyzerner
Copy link
Contributor Author

@petermein Looking great so far! Thanks for taking this on.

I just committed a small change to core which will allow you to slow this switch into the "notifications" settings fieldset, right beneath the grid. I think this is the best place for it.

You'll want to create a new file in js/forum/src (something like addSubscriptionSettings.js) with something like:

import { extend } from 'flarum/extend';
import SettingsPage from `flarum/components/SettingsPage`;

extend(SettingsPage.prototype, 'notificationsItems', function(items) {
  items.add('followAfterReply', ...);
});

And don't forget to import it into main.js :)

@tobyzerner tobyzerner self-assigned this Dec 21, 2015
@petermein
Copy link
Contributor

Update the subscriptions PR, but i don't like the ordering of the settings items.
There is something with priority but im not sure yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants