Compare commits
2 Commits
kiok-updat
...
use-flatma
| Author | SHA1 | Date | |
|---|---|---|---|
|
941414b3ee
|
|||
|
e9bc6186b9
|
@@ -510,7 +510,7 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
|||||||
const templates = await this.engine.listImportedTemplates();
|
const templates = await this.engine.listImportedTemplates();
|
||||||
|
|
||||||
// For each template, we need to create a 2d array of all the outputs
|
// For each template, we need to create a 2d array of all the outputs
|
||||||
const outputs = templates.map(template => {
|
const outputs = templates.flatMap(template => {
|
||||||
return Object.keys(template.outputs).map(output => {
|
return Object.keys(template.outputs).map(output => {
|
||||||
const templateIdentifier = generateTemplateIdentifier(template);
|
const templateIdentifier = generateTemplateIdentifier(template);
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// then, for each output, we need to get the spendable resources
|
// then, for each output, we need to get the spendable resources
|
||||||
const spendableResources = await Promise.all(outputs.flat().map(output => {
|
const spendableResources = await Promise.all(outputs.map(output => {
|
||||||
return this.engine.getSpendableResources(this.data, {
|
return this.engine.getSpendableResources(this.data, {
|
||||||
templateIdentifier: output.templateIdentifier,
|
templateIdentifier: output.templateIdentifier,
|
||||||
outputIdentifier: output.outputIdentifier,
|
outputIdentifier: output.outputIdentifier,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Invitation } from "../services/invitation.js";
|
import type { Invitation } from "../services/invitation.js";
|
||||||
import type { XOTemplate } from "@xo-cash/types";
|
import type { XOInvitationCommit, XOTemplate } from "@xo-cash/types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color names for invitation states.
|
* Color names for invitation states.
|
||||||
@@ -249,9 +249,9 @@ export function formatInvitationId(id: string, maxLength: number = 16): string {
|
|||||||
* @param invitation - The invitation to check
|
* @param invitation - The invitation to check
|
||||||
* @returns Array of unique entity identifiers
|
* @returns Array of unique entity identifiers
|
||||||
*/
|
*/
|
||||||
export function getInvitationParticipants(invitation: Invitation): string[] {
|
export function getInvitationParticipants(commits: Array<XOInvitationCommit>): string[] {
|
||||||
const participants = new Set<string>();
|
const participants = new Set<string>();
|
||||||
for (const commit of invitation.data.commits || []) {
|
for (const commit of commits) {
|
||||||
if (commit.entityIdentifier) {
|
if (commit.entityIdentifier) {
|
||||||
participants.add(commit.entityIdentifier);
|
participants.add(commit.entityIdentifier);
|
||||||
}
|
}
|
||||||
@@ -267,9 +267,14 @@ export function getInvitationParticipants(invitation: Invitation): string[] {
|
|||||||
* @returns True if the user has made at least one commit
|
* @returns True if the user has made at least one commit
|
||||||
*/
|
*/
|
||||||
export function isUserParticipant(
|
export function isUserParticipant(
|
||||||
invitation: Invitation,
|
invitation: Invitation | Array<XOInvitationCommit>,
|
||||||
userEntityId: string | null,
|
userEntityId: string | null,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (!userEntityId) return false;
|
if (!userEntityId) return false;
|
||||||
return getInvitationParticipants(invitation).includes(userEntityId);
|
|
||||||
|
if (Array.isArray(invitation)) {
|
||||||
|
return invitation.some(commit => commit.entityIdentifier === userEntityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getInvitationParticipants(invitation.data.commits).includes(userEntityId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user