Skip to content

Commit 90f64ef

Browse files
authored
Merge pull request #29 from Bilb/fix-clear-description
fix: logic to clear description with empty string
2 parents f94e468 + acd6343 commit 90f64ef

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"main": "index.js",
33
"name": "libsession_util_nodejs",
44
"description": "Wrappers for the Session Util Library",
5-
"version": "0.5.4",
5+
"version": "0.5.5",
66
"license": "GPL-3.0",
77
"author": {
88
"name": "Oxen Project",

src/groups/meta_group_wrapper.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,16 @@ Napi::Value MetaGroupWrapper::infoSet(const Napi::CallbackInfo& info) {
428428
this->meta_group->info->set_profile_pic(profilePic);
429429
}
430430

431-
if (auto description = maybeNonemptyString(
432-
obj.Get("description"), "MetaGroupWrapper::setInfo description")) {
433-
this->meta_group->info->set_description_truncated(*description);
431+
// Note: maybeNonemptyString returns nullopt when the string is null, undefined or empty.
432+
// in the context of infoSet, `description` is a bit of a custom one as:
433+
// - null/undefined means no change to the current value stored,
434+
// - empty string means set to empty string (i.e. clear it).
435+
// Because of this custom behavior, we need those manual checks in place.
436+
if (auto description = obj.Get("description")) {
437+
if (description.IsString()) {
438+
this->meta_group->info->set_description_truncated(
439+
description.ToString().Utf8Value());
440+
}
434441
}
435442

436443
return this->infoGet(info);

0 commit comments

Comments
 (0)