decord/source/modules/friend_suggestions/FriendSuggestionStore.tsx

160 lines
5.5 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 5415
// Function ID: 5416
2026-07-29 08:29:29 +00:00
// Name: initialize
2026-08-24 06:08:38 +00:00
// Dependencies: [1930, 1922, 12, 5416, 5417, 589, 709, 2]
2026-07-29 08:29:29 +00:00
// Exports: transformFriendSuggestions
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
// Module 5415 (initialize)
import applyDefault from "apply" /* 12 */;
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import _modDef5416 from "module_5416" /* 5416 */;
import maybeDispatchDevOnlyDummyFriendSuggestionsDefault from "maybeDispatchDevOnlyDummyFriendSuggestions" /* 5417 */;
import closure_2 from "createdAt" /* 1930 */;
import closure_3 from "mergeGuildAvatar" /* 1922 */;
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
let closure_4 = {};
let c5 = 0;
let c6 = false;
let c7 = false;
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class FriendSuggestionStore extends Store {
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = FriendSuggestionStore.prototype;
prototype["initialize"] = function initialize() {
2026-08-24 06:08:38 +00:00
this.waitFor(closure_3);
2026-07-29 08:29:29 +00:00
};
prototype["getSuggestionCount"] = function getSuggestionCount() {
return c5;
};
prototype["getSuggestions"] = function getSuggestions() {
const entries = Object.entries(closure_4);
return entries.map((arg0) => {
[, tmp] = arg0;
return tmp;
});
};
prototype["getSuggestion"] = function getSuggestion(id) {
return table[id];
};
FriendSuggestionStore.displayName = "FriendSuggestionStore";
2026-08-24 06:08:38 +00:00
const friendSuggestionStore = new FriendSuggestionStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
CONNECTION_OPEN: function handleConnectionOpen(friendSuggestionCount) {
2026-08-24 06:08:38 +00:00
closure_4 = {};
2026-07-20 16:05:17 +00:00
friendSuggestionCount = friendSuggestionCount.friendSuggestionCount;
if (friendSuggestionCount > 0) {
2026-08-24 06:08:38 +00:00
c7 = true;
2026-07-29 08:29:29 +00:00
let flag2 = !c6;
if (!c6) {
flag2 = true;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag2) {
c6 = true;
c7 = false;
2026-08-24 06:08:38 +00:00
const response = _modDef5416.fetch();
const obj = _modDef5416;
2026-07-20 16:05:17 +00:00
}
} else {
2026-08-24 06:08:38 +00:00
maybeDispatchDevOnlyDummyFriendSuggestionsDefault();
2026-07-20 16:05:17 +00:00
}
},
FRIEND_SUGGESTION_CREATE: function handleFriendSuggestionCreate(suggestion) {
2026-07-29 08:29:29 +00:00
suggestion = suggestion.suggestion;
if (null != suggestion.contact_names) {
if (suggestion.contact_names.length >= 2) {
const contact_names = suggestion.contact_names;
const substr = contact_names.slice(0, 2);
}
let obj = { key: null, name: null, user: null, mutualFriendsCount: null, contactNames: null };
obj[0] = suggestion.suggested_user.id;
2026-08-24 06:08:38 +00:00
const firstResult = applyDefault.first(suggestion.reasons);
2026-07-29 08:29:29 +00:00
let name;
if (firstResult != null) {
name = firstResult.name;
}
obj[1] = name;
2026-08-24 06:08:38 +00:00
const tmp9 = new closure_2(suggestion.suggested_user);
2026-07-29 08:29:29 +00:00
obj[2] = tmp9;
obj[3] = suggestion.mutual_friends_count;
obj[4] = [];
if (null != obj[obj.key]) {
return false;
} else {
closure_5 = closure_5 + 1;
obj = {};
const merged = Object.assign(obj);
obj[obj.key] = obj;
}
2026-08-24 06:08:38 +00:00
const obj2 = applyDefault;
2026-07-20 16:05:17 +00:00
}
},
FRIEND_SUGGESTION_DELETE: function handleFriendSuggestionDelete(arg0) {
2026-07-29 08:29:29 +00:00
const diff = closure_5 - 1;
closure_5 = diff;
closure_5 = Math.max(0, diff);
2026-07-23 10:11:24 +00:00
delete tmp2[tmp];
2026-07-20 16:05:17 +00:00
},
LOAD_FRIEND_SUGGESTIONS_SUCCESS: function handleLoadFriendSuggestionsSuccess(suggestions) {
2026-08-24 06:08:38 +00:00
c6 = false;
let obj = applyDefault;
const mapped = applyDefault.chain(suggestions.suggestions).map((contact_names) => {
2026-07-29 08:29:29 +00:00
if (null != contact_names.contact_names) {
if (contact_names.contact_names.length >= 2) {
contact_names = contact_names.contact_names;
const substr = contact_names.slice(0, 2);
}
const obj = { key: null, name: null, user: null, mutualFriendsCount: null, contactNames: null };
obj[0] = contact_names.suggested_user.id;
const firstResult = callback(table[2]).first(contact_names.reasons);
let name;
if (firstResult != null) {
name = firstResult.name;
}
obj[1] = name;
2026-08-24 06:08:38 +00:00
const tmp9 = new closure_2(contact_names.suggested_user);
2026-07-29 08:29:29 +00:00
obj[2] = tmp9;
obj[3] = contact_names.mutual_friends_count;
obj[4] = [];
return obj;
}
});
2026-08-24 06:08:38 +00:00
const chainResult = applyDefault.chain(suggestions.suggestions);
closure_4 = mapped.keyBy((key) => key.key).value();
2026-07-29 08:29:29 +00:00
const iter = mapped.keyBy((key) => key.key);
2026-08-24 06:08:38 +00:00
applyDefault.keys(closure_4).length;
2026-07-20 16:05:17 +00:00
},
LOAD_FRIEND_SUGGESTIONS_FAILURE: function handleLoadFriendSuggestionsFailure() {
2026-08-24 06:08:38 +00:00
c6 = false;
closure_4 = {};
2026-07-20 16:05:17 +00:00
}
});
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/friend_suggestions/FriendSuggestionStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default friendSuggestionStore;
export const transformFriendSuggestions = function transformFriendSuggestions(arg0) {
2026-08-24 06:08:38 +00:00
const obj = applyDefault;
const mapped = applyDefault.chain(arg0).map((contact_names) => {
2026-07-29 08:29:29 +00:00
if (null != contact_names.contact_names) {
if (contact_names.contact_names.length >= 2) {
contact_names = contact_names.contact_names;
const substr = contact_names.slice(0, 2);
}
const obj = { key: null, name: null, user: null, mutualFriendsCount: null, contactNames: null };
obj[0] = contact_names.suggested_user.id;
const firstResult = callback(table[2]).first(contact_names.reasons);
let name;
if (firstResult != null) {
name = firstResult.name;
}
obj[1] = name;
2026-08-24 06:08:38 +00:00
const tmp9 = new closure_2(contact_names.suggested_user);
2026-07-29 08:29:29 +00:00
obj[2] = tmp9;
obj[3] = contact_names.mutual_friends_count;
obj[4] = [];
return obj;
}
});
2026-08-24 06:08:38 +00:00
const chainResult = applyDefault.chain(arg0);
2026-07-29 08:29:29 +00:00
return mapped.keyBy((key) => key.key).value();
};