@@ -70,6 +70,7 @@ struct toJs_impl<group_info> {
7070 obj[" authData" ] = toJs (env, info.auth_data );
7171 obj[" invitePending" ] = toJs (env, info.invited );
7272 obj[" kicked" ] = toJs (env, info.kicked ());
73+ obj[" destroyed" ] = toJs (env, info.isDestroyed ());
7374
7475 return obj;
7576 }
@@ -103,6 +104,9 @@ void UserGroupsWrapper::Init(Napi::Env env, Napi::Object exports) {
103104 InstanceMethod (" getGroup" , &UserGroupsWrapper::getGroup),
104105 InstanceMethod (" getAllGroups" , &UserGroupsWrapper::getAllGroups),
105106 InstanceMethod (" setGroup" , &UserGroupsWrapper::setGroup),
107+ InstanceMethod (" markGroupKicked" , &UserGroupsWrapper::markGroupKicked),
108+ InstanceMethod (" markGroupInvited" , &UserGroupsWrapper::markGroupInvited),
109+ InstanceMethod (" markGroupDestroyed" , &UserGroupsWrapper::markGroupDestroyed),
106110 InstanceMethod (" eraseGroup" , &UserGroupsWrapper::eraseGroup),
107111
108112 });
@@ -316,13 +320,6 @@ Napi::Value UserGroupsWrapper::setGroup(const Napi::CallbackInfo& info) {
316320 group_info.invited = *invited;
317321 }
318322
319- if (auto kicked =
320- maybeNonemptyBoolean (obj.Get (" kicked" ), " UserGroupsWrapper::setGroup kicked" )) {
321- if (*kicked) {
322- group_info.setKicked ();
323- }
324- }
325-
326323 if (auto secretKey = maybeNonemptyBuffer (
327324 obj.Get (" secretKey" ), " UserGroupsWrapper::setGroup secretKey" )) {
328325 group_info.secretkey = *secretKey;
@@ -343,6 +340,45 @@ Napi::Value UserGroupsWrapper::setGroup(const Napi::CallbackInfo& info) {
343340 });
344341}
345342
343+ Napi::Value UserGroupsWrapper::markGroupKicked (const Napi::CallbackInfo& info) {
344+ return wrapResult (info, [&] {
345+ auto groupPk = getStringArgs<1 >(info);
346+
347+ auto group = config.get_group (groupPk);
348+ if (group) {
349+ group->markKicked ();
350+ config.set (*group);
351+ }
352+ return config.get_or_construct_group (groupPk);
353+ });
354+ }
355+
356+ Napi::Value UserGroupsWrapper::markGroupInvited (const Napi::CallbackInfo& info) {
357+ return wrapResult (info, [&] {
358+ auto groupPk = getStringArgs<1 >(info);
359+
360+ auto group = config.get_group (groupPk);
361+ if (group) {
362+ group->markInvited ();
363+ config.set (*group);
364+ }
365+ return config.get_or_construct_group (groupPk);
366+ });
367+ }
368+
369+ Napi::Value UserGroupsWrapper::markGroupDestroyed (const Napi::CallbackInfo& info) {
370+ return wrapResult (info, [&] {
371+ auto groupPk = getStringArgs<1 >(info);
372+
373+ auto group = config.get_group (groupPk);
374+ if (group) {
375+ group->markDestroyed ();
376+ config.set (*group);
377+ }
378+ return config.get_or_construct_group (groupPk);
379+ });
380+ }
381+
346382Napi::Value UserGroupsWrapper::eraseGroup (const Napi::CallbackInfo& info) {
347383 return wrapResult (info, [&] { return config.erase_group (getStringArgs<1 >(info)); });
348384}
0 commit comments