Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Fix spurious requests
Sebastian Martinez committed 3 years ago
commit 0c2fbe0e487f313f34377cc7f9cbc61a55536147
parent 7ae5317b5465445eed689b69f4452ac2413e8157
3 files changed +31 -25
modified cypress/fixtures/projectInfo.json
@@ -12,5 +12,7 @@
      ]
    }
  ],
-
  "head": "56e4e029c294b08546386e1fb706b772c7433c49"
+
  "head": "56e4e029c294b08546386e1fb706b772c7433c49",
+
  "patches": 2,
+
  "issues": 3
}
modified src/base/projects/Header.svelte
@@ -8,8 +8,6 @@
  import PeerSelector from "@app/base/projects/PeerSelector.svelte";
  import type { Tree } from "@app/project";
  import Input from "@app/Input.svelte";
-
  import { groupIssues, Issue } from "@app/issue";
-
  import { groupPatches, Patch } from "@app/patch";

  export let project: Project;
  export let tree: Tree;
@@ -210,30 +208,30 @@
    on:click={() => toggleContent(ProjectContent.History, true)}>
    <strong>{tree.stats.commits}</strong> commit(s)
  </div>
-
  {#await Issue.getIssues(project.urn, seed.api) then issues}
+
  {#if project.issues > 0}
    <div
      class="stat issue-count clickable widget"
      class:active={content == ProjectContent.Issues}
      on:click={() => toggleContent(ProjectContent.Issues, false)}>
-
      <strong>{groupIssues(issues).open.length}</strong> issue(s)
+
      <strong>{project.issues}</strong> issue(s)
    </div>
-
  {:catch}
+
  {:else}
    <div class="stat issue-count not-allowed widget" title="Not supported">
      0 issue(s)
    </div>
-
  {/await}
-
  {#await Patch.getPatches(project.urn, seed.api) then patches}
+
  {/if}
+
  {#if project.patches > 0}
    <div
      class="stat patch-count clickable widget"
      class:active={content == ProjectContent.Patches}
      on:click={() => toggleContent(ProjectContent.Patches, false)}>
-
      <strong>{groupPatches(patches).proposed.length}</strong> patch(es)
+
      <strong>{project.patches}</strong> patch(es)
    </div>
-
  {:catch}
+
  {:else}
    <div class="stat patch-count not-allowed widget" title="Not supported">
      0 patch(es)
    </div>
-
  {/await}
+
  {/if}
  <div class="stat contributor-count widget">
    <strong>{tree.stats.contributors}</strong> contributor(s)
  </div>
modified src/project.ts
@@ -6,12 +6,20 @@ import { isOid, isRadicleId } from '@app/utils';
import { Profile, ProfileType } from '@app/profile';
import { Seed } from '@app/base/seeds/Seed';
import type { Config } from '@app/config';
-
import type { Issue } from '@app/issue';

export type Urn = string;
export type PeerId = string;
export type Branches = { [key: string]: string };

+
export type Delegate = {
+
  type: "indirect";
+
  urn: Urn;
+
  ids: PeerId[];
+
} | {
+
  type: "direct";
+
  id: PeerId;
+
};
+

export interface Anchor {
  confirmed: true;
  id: string;
@@ -47,8 +55,10 @@ export interface ProjectInfo {
  name: string;
  description: string;
  defaultBranch: string;
-
  maintainers: Urn[];
-
  delegates: PeerId[];
+
  delegates: Delegate[];
+
  remotes: PeerId[];
+
  patches: number;
+
  issues: number;
}

export interface Tree {
@@ -247,13 +257,15 @@ export class Project implements ProjectInfo {
  name: string;
  description: string;
  defaultBranch: string;
-
  maintainers: Urn[];
-
  delegates: PeerId[];
+
  delegates: Delegate[];
+
  remotes: PeerId[];
  seed: Seed;
  peers: Peer[];
  branches: Branches;
  profile: Profile | null;
  anchors: string[];
+
  patches: number;
+
  issues: number;

  constructor(urn: string, info: ProjectInfo, seed: Seed, peers: Peer[], branches: Branches, profile: Profile | null, anchors: string[]) {
    this.urn = urn;
@@ -261,11 +273,13 @@ export class Project implements ProjectInfo {
    this.name = info.name;
    this.description = info.description;
    this.defaultBranch = info.defaultBranch;
-
    this.maintainers = info.maintainers;
    this.delegates = info.delegates;
+
    this.remotes = info.remotes;
    this.seed = seed;
    this.peers = peers;
    this.branches = branches;
+
    this.patches = info.patches;
+
    this.issues = info.issues;
    this.profile = profile;
    this.anchors = anchors;
  }
@@ -336,14 +350,6 @@ export class Project implements ProjectInfo {
    return new Request(`projects/${this.urn}/commits/${commit}`, this.seed.api).get();
  }

-
  static async getIssues(urn: string, host: Host): Promise<Issue[]> {
-
    return new Request(`projects/${urn}/issues`, host).get();
-
  }
-

-
  async getIssue(issue: string): Promise<Issue> {
-
    return new Request(`projects/${this.urn}/issues/${issue}`, this.seed.api).get();
-
  }
-

  async getTree(
    commit: string,
    path: string,