Skip to content

Commit eb38ed8

Browse files
authored
Merge pull request #31 from session-foundation/fix-profile-ts-disabled-state
fix: allow profile update to be used when current ts is 0
2 parents c6fa347 + 54e5b89 commit eb38ed8

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-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.7",
5+
"version": "0.5.8",
66
"license": "GPL-3.0",
77
"author": {
88
"name": "Oxen Project",

src/contacts_config.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ void ContactsConfigWrapper::set(const Napi::CallbackInfo& info) {
145145

146146
// if the saved profile info is older than the new one, update it and the profile fields
147147
// provided
148-
if (contact.profile_updated < newProfileUpdateSeconds) {
148+
if (contact.profile_updated.time_since_epoch().count() == 0 ||
149+
contact.profile_updated < newProfileUpdateSeconds) {
149150
contact.profile_updated = newProfileUpdateSeconds;
150151

151152
if (auto name = maybeNonemptyString(obj.Get("name"), "contacts.set name"))

src/groups/meta_group_wrapper.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,11 @@ void MetaGroupWrapper::memberSetProfileDetails(const Napi::CallbackInfo& info) {
649649
auto updatedAtSeconds =
650650
toCppSysSeconds(argsAsObj.Get("profileUpdatedSeconds"), "memberSetProfileDetails");
651651

652-
// if the profile details provided are more recent that the ones saved, update them
653-
if (m && updatedAtSeconds > m->profile_updated) {
652+
// if the profile details provided are more recent that the ones saved, update them.
653+
// we also allow anything when our current value is 0, as it means we haven't got an updated
654+
// profileDetails yet
655+
if (m && (updatedAtSeconds > m->profile_updated ||
656+
m->profile_updated.time_since_epoch().count() == 0)) {
654657
m->profile_updated = updatedAtSeconds;
655658

656659
auto profilePicture = profile_pic_from_object(argsAsObj.Get("profilePicture"));

0 commit comments

Comments
 (0)