decord/source/modules/friend_groups/FriendGroupsStore.tsx

181 lines
5.3 KiB
TypeScript
Raw Normal View History

// Module ID: 13758
// Function ID: 13759
// Name: FriendGroupsStore
// Dependencies: [7732, 6667, 4255, 1371, 504, 573, 2]
2026-07-23 10:11:24 +00:00
// Module 13758 (FriendGroupsStore)
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import UserAffinitiesV2Store from "UserAffinitiesV2Store" /* 7732 */;
import ConsentStore from "ConsentStore" /* 6667 */;
import RelationshipStore from "RelationshipStore" /* 4255 */;
import UserStore from "UserStore" /* 1371 */;
2026-07-20 16:05:17 +00:00
let items = [];
2026-07-29 08:29:29 +00:00
let c5 = false;
2026-08-24 06:08:38 +00:00
const PersistedStore = initializeDefault.PersistedStore;
2026-07-29 08:29:29 +00:00
class FriendGroupsStore extends PersistedStore {
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = FriendGroupsStore.prototype;
prototype["initialize"] = function initialize(groups) {
this.waitFor(ConsentStore, RelationshipStore, UserAffinitiesV2Store, UserStore);
2026-07-29 08:29:29 +00:00
if (null != groups) {
groups = groups.groups;
if (groups == null) {
groups = [];
}
items = groups;
2026-07-29 08:29:29 +00:00
let flag = groups.isInitialized;
if (flag == null) {
flag = false;
2026-07-20 16:05:17 +00:00
}
c5 = flag;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
prototype["getGroups"] = function getGroups() {
return items;
2026-07-29 08:29:29 +00:00
};
prototype["getGroup"] = function getGroup(arg0) {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
let found = items.find((id) => id.id === closure_0);
2026-07-29 08:29:29 +00:00
if (found == null) {
found = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return found;
};
prototype["getGroupIds"] = function getGroupIds() {
return items.map((id) => id.id);
2026-07-29 08:29:29 +00:00
};
prototype["getUserGroups"] = function getUserGroups(arg0) {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
return items.filter((userIds) => {
2026-07-29 08:29:29 +00:00
userIds = userIds.userIds;
2026-08-24 06:08:38 +00:00
return userIds.includes(closure_0);
2026-07-29 08:29:29 +00:00
});
};
prototype["isGroupEmpty"] = function isGroupEmpty(arg0) {
const group = this.getGroup(arg0);
let tmp2 = null == group;
if (!tmp2) {
tmp2 = 0 === group.userIds.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp2;
};
prototype["isInitialized"] = function isInitialized() {
return c5;
};
prototype["getState"] = function getState() {
return { groups: items, isInitialized };
2026-07-29 08:29:29 +00:00
};
FriendGroupsStore.displayName = "FriendGroupsStore";
FriendGroupsStore.persistKey = "FriendGroupsStoreV2";
const friendGroupsStore = new FriendGroupsStore(DispatcherDefault, {
2026-07-20 16:05:17 +00:00
POST_CONNECTION_OPEN: function handleInitializeFriendGroups() {
2026-07-29 08:29:29 +00:00
if (!c5) {
if (items.length <= 0) {
items = [];
2026-07-29 08:29:29 +00:00
c5 = true;
2026-07-20 16:05:17 +00:00
}
}
return false;
},
CREATE_FRIEND_GROUP: function handleCreateFriendGroup(groupId) {
groupId = groupId.groupId;
const someResult = items.some((id) => id.id === groupId);
2026-07-29 08:29:29 +00:00
let flag = !someResult;
if (!someResult) {
const obj = { id: groupId, name: groupId.name, userIds: [] };
items.push(obj);
2026-07-20 16:05:17 +00:00
flag = true;
}
return flag;
},
UPDATE_FRIEND_GROUP: function handleUpdateFriendGroup(groupId) {
groupId = groupId.groupId;
const findIndexResult = items.findIndex((id) => id.id === groupId);
2026-07-20 16:05:17 +00:00
let flag = -1 !== findIndexResult;
if (flag) {
const obj = {};
const merged = Object.assign(items[findIndexResult]);
2026-07-29 08:29:29 +00:00
obj.name = groupId.name;
items[findIndexResult] = obj;
2026-07-20 16:05:17 +00:00
flag = true;
}
return flag;
},
DELETE_FRIEND_GROUP: function handleDeleteFriendGroup(groupId) {
groupId = groupId.groupId;
const found = items.filter((id) => id.id !== groupId);
items = found;
return found.length !== items.length;
2026-07-20 16:05:17 +00:00
},
2026-07-29 08:29:29 +00:00
REORDER_FRIEND_GROUPS: function handleReorderFriendGroups(arg0) {
items = [];
2026-07-29 08:29:29 +00:00
const map = new Map(items.map((id) => {
2026-08-24 06:08:38 +00:00
items = [id.id, id];
2026-07-29 08:29:29 +00:00
return items;
}));
while (tmp !== undefined) {
value = map.get(tmp2);
2026-07-29 08:29:29 +00:00
if (null != value) {
let arr = items.push(tmp4);
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let flag = items.length === items.length;
2026-07-20 16:05:17 +00:00
if (flag) {
flag = true;
}
return flag;
},
ADD_USERS_TO_GROUP: function handleAddUsersToGroup(arg0) {
({ groupId: UserAffinitiesV2Store, userIds } = arg0);
2026-07-23 10:11:24 +00:00
let set;
const findIndexResult = items.findIndex((id) => id.id === UserAffinitiesV2Store);
2026-07-20 16:05:17 +00:00
if (-1 === findIndexResult) {
return false;
} else {
const _Set = Set;
2026-07-23 10:11:24 +00:00
set = new Set(tmp11.userIds);
const found = userIds.filter((item) => !set.has(item));
2026-07-20 16:05:17 +00:00
let flag = 0 !== found.length;
if (flag) {
const obj = {};
const merged = Object.assign(tmp11);
items = [];
2026-07-20 16:05:17 +00:00
HermesBuiltin.arraySpread(found, HermesBuiltin.arraySpread(tmp11.userIds, 0));
2026-07-29 08:29:29 +00:00
obj.userIds = items;
items[findIndexResult] = obj;
2026-07-20 16:05:17 +00:00
flag = true;
}
return flag;
}
},
REMOVE_USERS_FROM_GROUP: function handleRemoveUsersFromGroup(arg0) {
({ groupId: UserAffinitiesV2Store, userIds } = arg0);
2026-07-23 10:11:24 +00:00
let set;
const findIndexResult = items.findIndex((id) => id.id === UserAffinitiesV2Store);
2026-07-20 16:05:17 +00:00
if (-1 === findIndexResult) {
return false;
} else {
const _Set = Set;
2026-07-23 10:11:24 +00:00
set = new Set(userIds);
const userIds1 = tmp3.userIds;
const found = userIds1.filter((item) => !set.has(item));
2026-07-29 08:29:29 +00:00
let flag = found.length !== tmp3.userIds.length;
2026-07-20 16:05:17 +00:00
if (flag) {
const obj = {};
2026-07-29 08:29:29 +00:00
const merged = Object.assign(tmp3);
obj.userIds = found;
items[findIndexResult] = obj;
2026-07-20 16:05:17 +00:00
flag = true;
}
return flag;
}
}
});
const size = fn(2);
const result = size.fileFinishedImporting("modules/friend_groups/FriendGroupsStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default friendGroupsStore;