-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Render Stream Descriptions from the Backend - Frontend and UI Update #11480
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,12 +242,6 @@ exports.get_subscriber_count = function (stream_name) { | |
return sub.subscribers.num_items(); | ||
}; | ||
|
||
exports.render_stream_description = function (sub) { | ||
if (sub.description !== undefined) { | ||
sub.rendered_description = marked(sub.description).replace('<p>', '').replace('</p>', ''); | ||
} | ||
}; | ||
|
||
exports.update_calculated_fields = function (sub) { | ||
sub.is_admin = page_params.is_admin; | ||
// Admin can change any stream's name & description either stream is public or | ||
|
@@ -268,7 +262,9 @@ exports.update_calculated_fields = function (sub) { | |
!sub.invite_only; | ||
sub.preview_url = hash_util.by_stream_uri(sub.stream_id); | ||
sub.can_add_subscribers = !page_params.is_guest && (!sub.invite_only || sub.subscribed); | ||
exports.render_stream_description(sub); | ||
if (sub.rendered_description !== undefined) { | ||
sub.rendered_description = sub.rendered_description.replace('<p>', '').replace('</p>', ''); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I think that's fine, what I don't like about this model is that we strip the I think we could potentially address this in other ways, though -- e.g. either making the UI layer insert the edit widget inside the |
||
exports.update_subscribers_count(sub); | ||
}; | ||
|
||
|
@@ -499,6 +495,7 @@ exports.create_sub_from_server_data = function (stream_name, attrs) { | |
push_notifications: page_params.enable_stream_push_notifications, | ||
email_notifications: page_params.enable_stream_email_notifications, | ||
description: '', | ||
rendered_description: '', | ||
}); | ||
|
||
exports.set_subscribers(sub, subscriber_user_ids); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ideally we'd avoid adding feature-specific code in this generic library. How about we make this a hook function and extend the
map
thing at the top to have a dict rather than just a function inside?E.g.
As a sidenote, a larger refactor for this component might want to include extracting this little sub-mobile to e.g.
static/js/editable_section.js
-- there's no need for it to be inclick_handlers.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timabbott, I'm not too sure of what you're suggesting I do here. For the time being, I've added an extra (temporary) commit to this PR, based on what I think you've asked for me to do. If this isn't what you suggested (which I strongly suspect is the case), could you please clarify what exactly you're suggesting (regarding the hook function and extension of the map object)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what I'd had in mind! The benefit of this
map
model in general is that our generate content-editable component doesn't end up cluttered with individual bits of feature-specific conditionals, which makes it easier to reuse it for future features (or replace it with some other library, if we ever want to go that route).