1
0
mirror of https://github.com/flarum/core.git synced 2025-10-23 04:36:08 +02:00

Put m.stream in flarum/utils/stream (#2316)

This commit is contained in:
Alexander Skvortsov
2020-09-27 23:49:33 -04:00
committed by GitHub
parent 6860b24b70
commit cc875f3e95
16 changed files with 52 additions and 39 deletions

View File

@@ -1,5 +1,6 @@
import Modal from '../../common/components/Modal';
import Button from '../../common/components/Button';
import Stream from '../../common/utils/Stream';
/**
* The `ChangeEmailModal` component shows a modal dialog which allows the user
@@ -21,14 +22,14 @@ export default class ChangeEmailModal extends Modal {
*
* @type {function}
*/
this.email = m.stream(app.session.user.email());
this.email = Stream(app.session.user.email());
/**
* The value of the password input.
*
* @type {function}
*/
this.password = m.stream('');
this.password = Stream('');
}
className() {

View File

@@ -1,5 +1,6 @@
import ComposerBody from './ComposerBody';
import extractText from '../../common/utils/extractText';
import Stream from '../../common/utils/Stream';
/**
* The `DiscussionComposer` component displays the composer content for starting
@@ -26,7 +27,7 @@ export default class DiscussionComposer extends ComposerBody {
oninit(vnode) {
super.oninit(vnode);
this.composer.fields.title = this.composer.fields.title || m.stream('');
this.composer.fields.title = this.composer.fields.title || Stream('');
/**
* The value of the title input.

View File

@@ -4,6 +4,7 @@ import GroupBadge from '../../common/components/GroupBadge';
import Group from '../../common/models/Group';
import extractText from '../../common/utils/extractText';
import ItemList from '../../common/utils/ItemList';
import Stream from '../../common/utils/Stream';
/**
* The `EditUserModal` component displays a modal dialog with a login form.
@@ -14,17 +15,17 @@ export default class EditUserModal extends Modal {
const user = this.attrs.user;
this.username = m.stream(user.username() || '');
this.email = m.stream(user.email() || '');
this.isEmailConfirmed = m.stream(user.isEmailConfirmed() || false);
this.setPassword = m.stream(false);
this.password = m.stream(user.password() || '');
this.username = Stream(user.username() || '');
this.email = Stream(user.email() || '');
this.isEmailConfirmed = Stream(user.isEmailConfirmed() || false);
this.setPassword = Stream(false);
this.password = Stream(user.password() || '');
this.groups = {};
app.store
.all('groups')
.filter((group) => [Group.GUEST_ID, Group.MEMBER_ID].indexOf(group.id()) === -1)
.forEach((group) => (this.groups[group.id()] = m.stream(user.groups().indexOf(group) !== -1)));
.forEach((group) => (this.groups[group.id()] = Stream(user.groups().indexOf(group) !== -1)));
}
className() {

View File

@@ -1,6 +1,7 @@
import Modal from '../../common/components/Modal';
import Button from '../../common/components/Button';
import extractText from '../../common/utils/extractText';
import Stream from '../../common/utils/Stream';
/**
* The `ForgotPasswordModal` component displays a modal which allows the user to
@@ -19,7 +20,7 @@ export default class ForgotPasswordModal extends Modal {
*
* @type {Function}
*/
this.email = m.stream(this.attrs.email || '');
this.email = Stream(this.attrs.email || '');
/**
* Whether or not the password reset email was sent successfully.

View File

@@ -5,6 +5,7 @@ import Button from '../../common/components/Button';
import LogInButtons from './LogInButtons';
import extractText from '../../common/utils/extractText';
import ItemList from '../../common/utils/ItemList';
import Stream from '../../common/utils/Stream';
/**
* The `LogInModal` component displays a modal dialog with a login form.
@@ -23,21 +24,21 @@ export default class LogInModal extends Modal {
*
* @type {Function}
*/
this.identification = m.stream(this.attrs.identification || '');
this.identification = Stream(this.attrs.identification || '');
/**
* The value of the password input.
*
* @type {Function}
*/
this.password = m.stream(this.attrs.password || '');
this.password = Stream(this.attrs.password || '');
/**
* The value of the remember me input.
*
* @type {Function}
*/
this.remember = m.stream(!!this.attrs.remember);
this.remember = Stream(!!this.attrs.remember);
}
className() {

View File

@@ -1,5 +1,6 @@
import Modal from '../../common/components/Modal';
import Button from '../../common/components/Button';
import Stream from '../../common/utils/Stream';
/**
* The 'RenameDiscussionModal' displays a modal dialog with an input to rename a discussion
@@ -10,7 +11,7 @@ export default class RenameDiscussionModal extends Modal {
this.discussion = this.attrs.discussion;
this.currentTitle = this.attrs.currentTitle;
this.newTitle = m.stream(this.currentTitle);
this.newTitle = Stream(this.currentTitle);
}
className() {

View File

@@ -4,6 +4,7 @@ import Button from '../../common/components/Button';
import LogInButtons from './LogInButtons';
import extractText from '../../common/utils/extractText';
import ItemList from '../../common/utils/ItemList';
import Stream from '../../common/utils/Stream';
/**
* The `SignUpModal` component displays a modal dialog with a singup form.
@@ -24,21 +25,21 @@ export default class SignUpModal extends Modal {
*
* @type {Function}
*/
this.username = m.stream(this.attrs.username || '');
this.username = Stream(this.attrs.username || '');
/**
* The value of the email input.
*
* @type {Function}
*/
this.email = m.stream(this.attrs.email || '');
this.email = Stream(this.attrs.email || '');
/**
* The value of the password input.
*
* @type {Function}
*/
this.password = m.stream(this.attrs.password || '');
this.password = Stream(this.attrs.password || '');
}
className() {

View File

@@ -1,4 +1,5 @@
import subclassOf from '../../common/utils/subclassOf';
import Stream from '../../common/utils/Stream';
import ReplyComposer from '../components/ReplyComposer';
class ComposerState {
@@ -74,7 +75,7 @@ class ComposerState {
this.onExit = null;
this.fields = {
content: m.stream(''),
content: Stream(''),
};
/**