ChanViewer: Show "" instead of "undefined" for missing thread subjects

This broke due to a change in JsonValue API. JsonValue::to_string() now
returns the value serialized to a string, which may become "undefined".

You kinda want JsonValue::as_string(), but that is only callable when
the JsonValue *is* a string. Thankfully there is now as_string_or(alt).
This commit is contained in:
Andreas Kling 2019-08-07 22:04:07 +02:00
parent 9889d170b9
commit 351c354680
Notes: sideshowbarker 2024-07-19 12:49:59 +09:00

View file

@ -126,9 +126,9 @@ GVariant ThreadCatalogModel::data(const GModelIndex& index, Role role) const
case Column::ThreadNumber:
return thread.get("no").to_u32();
case Column::Subject:
return thread.get("sub").to_string();
return thread.get("sub").as_string_or({});
case Column::Text:
return thread.get("com").to_string();
return thread.get("com").as_string_or({});
case Column::ReplyCount:
return thread.get("replies").to_u32();
case Column::ImageCount: