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
tobscure opened this Issue Aug 29, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@tobscure
Member

tobscure commented Aug 29, 2015

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

@tobscure tobscure changed the title from User setting to automatically follow discussions you start/reply to to [Subscriptions] User setting to automatically follow discussions you start/reply to Aug 29, 2015

@tobscure tobscure referenced this issue Aug 29, 2015

Closed

v0.1.0 roadmap (old) #74

19 of 53 tasks complete

@tobscure tobscure added this to the 0.1.0-beta.4 milestone Sep 4, 2015

@justjavac justjavac referenced this issue Sep 7, 2015

Open

Flarum v0.1.0 开发路线图 #3

18 of 53 tasks complete
@petermein

This comment has been minimized.

Show comment
Hide comment
@petermein

petermein Dec 17, 2015

Contributor

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

Referencing: flarum/flarum-ext-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.

Contributor

petermein commented Dec 17, 2015

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

Referencing: flarum/flarum-ext-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.

@tobscure

This comment has been minimized.

Show comment
Hide comment
@tobscure

tobscure Dec 21, 2015

Member

@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 :)

Member

tobscure commented Dec 21, 2015

@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 :)

@tobscure tobscure self-assigned this Dec 21, 2015

@petermein

This comment has been minimized.

Show comment
Hide comment
@petermein

petermein Dec 26, 2015

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.

Contributor

petermein commented Dec 26, 2015

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