Files
discord-decomp/stores/ConnectedAccountsStore.tsx
T
2026-11-01 12:12:55 +02:00

114 lines
3.4 KiB
TypeScript

// Metro module 4869 (f4870).
import ConnectedAccountRecord from "../records/ConnectedAccountRecord";
import { PlatformTypes } from "../Constants";
import Platforms from "../lib/Platforms";
import { fromGuildBasic } from "../utils/GuildRecordUtils";
import ConnectedAccountsActionCreators from "../actions/ConnectedAccountsActionCreators";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let $mk75138 = function() {
return (a0) => {
const r6 = c3000_4.has(a0.type);
return r6 ? !r6 : Platforms.isSupported(a0.type);
};
}, $mk75139 = function() {
return (a0) => c3000_4.has(a0.type);
};
let c3000_4 = new Set([PlatformTypes.CONTACTS]);
let c3000_5 = true;
let c3000_6 = [];
let c3000_7 = [];
let c3000_8 = {};
let c3000_9 = new Set();
let c3000_10 = {};
let c3000_11 = {};
class ConnectedAccountsStore extends Module589.Store {
static displayName = "ConnectedAccountsStore";
isJoining(a0) {
return c3000_8[a0] || false;
}
joinErrorMessage(a0) {
return c3000_11[a0];
}
isFetching() {
return c3000_5;
}
getAccounts() {
return c3000_6;
}
getLocalAccounts() {
return c3000_7;
}
getAccount(c14487_0, c14487_1) {
return c3000_6.find((item) => (c14487_0 == null || item.id === c14487_0) && item.type === c14487_1);
}
getLocalAccount(c14488_0) {
return c3000_7.find((item) => item.type === c14488_0);
}
isSuggestedAccountType(a0) {
return c3000_10[a0] || false;
}
addPendingAuthorizedState(a0) {
c3000_9.add(a0);
}
deletePendingAuthorizedState(a0) {
c3000_9.delete(a0);
}
hasPendingAuthorizedState(a0) {
return c3000_9.has(a0);
}
}
const connectedAccountsStore = new ConnectedAccountsStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
const r6 = a0.connectedAccounts.map((connectedAccount) => new ConnectedAccountRecord(connectedAccount));
c3000_6 = r6.filter($mk75138());
c3000_7 = r6.filter($mk75139());
c3000_5 = false;
},
USER_CONNECTIONS_UPDATE: function handleConnectionsUpdate(a0) {
if (a0.local && a0.accounts != null) {
const r15 = a0.accounts.map((account) => new ConnectedAccountRecord({
...account,
integrations: account.integrations.map((integration) => ({
...integration,
guild: fromGuildBasic({
...integration.guild,
features: []
})
}))
}));
c3000_6 = r15.filter($mk75138());
c3000_7 = r15.filter($mk75139());
c3000_5 = false;
} else {
ConnectedAccountsActionCreators.fetch();
}
},
USER_CONNECTIONS_INTEGRATION_JOINING: function handleJoining(a0) {
c3000_8[a0.integrationId] = a0.joining;
},
USER_CONNECTION_UPDATE: function handleUserConnectionUpdate({ platformType, id, revoked, accessToken }) {
const r11 = c3000_6.find((item) => item.id === id && item.type === platformType);
if (r11 == null) {
return false;
}
if (revoked != null) {
r11.revoked = revoked;
}
if (accessToken != null) {
r11.accessToken = accessToken;
}
},
USER_CONNECTIONS_INTEGRATION_JOINING_ERROR: function handleJoiningError(a0) {
c3000_11[a0.integrationId] = a0.error !== void 0 ? a0.error : "";
},
USER_CONNECTIONS_CALLBACK: function handleUserConnectionsCallback(a0) {
ConnectedAccountsActionCreators.callback(a0.provider, {
code: a0.code,
state: a0.state,
openid_params: a0.openid_params
});
}
});
export default connectedAccountsStore;