Fix default value given to Msg.from
- `{}` is not falsey so Handlebars would try to render the block (see http://handlebarsjs.com/builtin_helpers.html#conditionals), therefore with a `nick` of `undefined`, which breaks `colorClass` (doing `undefined.length) - There does not seem to be a way to check for empty objects in Handlebars (sigh) so checking `from.nick` seems like the most reliable way to check for a non-empty value. Alternatively, we could use a helper to check `{}` but meh.
This commit is contained in:
parent
36e0ce46b4
commit
c0d348a678
@ -1,4 +1,4 @@
|
||||
{{#if from}}
|
||||
{{#if from.nick}}
|
||||
{{> ../user_name from}}
|
||||
has changed the topic to:
|
||||
{{else}}
|
||||
|
@ -3,7 +3,7 @@
|
||||
{{tz time}}
|
||||
</span>
|
||||
<span class="from">
|
||||
{{#if from}}
|
||||
{{#if from.nick}}
|
||||
{{> user_name from}}
|
||||
{{/if}}
|
||||
</span>
|
||||
|
@ -7,7 +7,7 @@ var id = 0;
|
||||
class Msg {
|
||||
constructor(attr) {
|
||||
_.defaults(this, attr, {
|
||||
from: "",
|
||||
from: {},
|
||||
id: id++,
|
||||
previews: [],
|
||||
text: "",
|
||||
|
Loading…
Reference in New Issue
Block a user