mirror of https://github.com/zulip/zulip.git
Smarter template invocation on settings page.
Rather than calling the template generating code once per subscription, let's just do it in a batch when possible. With about 100 subscriptions, the "fetch" call takes about 800ms to render (while testing locally) both before and after this change, which is somewhat disappointing. But this *is* cleaner! (imported from commit 9ba8819524da86c00a2508349be0ea0ddd48606b)
This commit is contained in:
parent
e7b74060d2
commit
cd237c3429
|
@ -1,4 +1,6 @@
|
|||
{{! Client-side Mustache template for rendering subscriptions.}}
|
||||
{{#each subscriptions}}
|
||||
{{#with this}}
|
||||
<tr>
|
||||
<td>
|
||||
<input class="colorpicker" type="text" value="{{color}}" />
|
||||
|
@ -10,3 +12,5 @@
|
|||
value="{{subscription}}">Unsubscribe</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
|
|
|
@ -89,7 +89,7 @@ function add_to_stream_list(stream_name) {
|
|||
.click(function (event) {exports.unsubscribe(stream_name);});
|
||||
} else {
|
||||
$('#subscriptions_table').prepend(templates.subscription({
|
||||
subscription: stream_name,color: "c2c2c2"}));
|
||||
subscriptions: [{subscription: stream_name, color: "c2c2c2"}]}));
|
||||
draw_colorpicker(stream_name);
|
||||
}
|
||||
}
|
||||
|
@ -139,13 +139,16 @@ exports.fetch = function () {
|
|||
success: function (data) {
|
||||
$('#subscriptions_table tr').remove();
|
||||
if (data) {
|
||||
var subscriptions = [];
|
||||
$.each(data.subscriptions, function (index, data) {
|
||||
var stream_name = data[0];
|
||||
var color = data[1];
|
||||
stream_colors[stream_name] = color;
|
||||
$('#subscriptions_table').append(templates.subscription({
|
||||
subscription: stream_name, color: color}));
|
||||
draw_colorpicker(stream_name);
|
||||
subscriptions.push({subscription: stream_name, color: color});
|
||||
});
|
||||
$('#subscriptions_table').append(templates.subscription({subscriptions: subscriptions}));
|
||||
$.each(subscriptions, function (index, data) {
|
||||
draw_colorpicker(data.subscription);
|
||||
});
|
||||
}
|
||||
$('#streams').focus().select();
|
||||
|
|
Loading…
Reference in New Issue