diff --git a/README.md b/README.md index 5c91169..bc710c8 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,19 @@ -# create-svelte - -Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). - -## Creating a project - -If you're seeing this, you've probably already done this step. Congrats! +1. Please clone and build + https://git.batsense.net/realaravinth/forgejo-notifications-core in the + parent directory and install it on this project. +2. Please deploy a local instance of https://github.com/Bassetts/warp-cors with: ```bash -# create a new project in the current directory -npm create svelte@latest - -# create a new project in my-app -npm create svelte@latest my-app +docker run -dp 3030:3030 bassetts/warp-cors ``` -## Developing +The URL is hardcoded, so it won't work if warp-cors isn't running on +`localhost:3030` -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +3. I Haven't figured out how to build and deploy this project. I'm not + even sure if it is possible (I'm new to svelte). But I know the + development server works ;) : -```bash -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open -``` - -## Building - -To create a production version of your app: - -```bash -npm run build -``` - -You can preview the production build with `npm run preview`. - -> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. + ```bash + pnpm run dev + ```` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 432626d..587fb8e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1120,7 +1120,7 @@ packages: dev: true file:../forgejo-notifications-core/forgejo-notifications-core-0.1.0-alpha-1.tgz: - resolution: {integrity: sha512-Xz61PNEyFfQw+StI78kqMEp0QnI4TDU69JK3V1Ty1w5FWpF9Nv+3s6vZbXdv9GfEk630VTY3ELedbVB+nu9FBA==, tarball: file:../forgejo-notifications-core/forgejo-notifications-core-0.1.0-alpha-1.tgz} + resolution: {integrity: sha512-zXpAZjwjN1kPW/JBpziAG/YNvoXfco0ocWYHPut3NCsFUMqaWs0PfQ+vPRo8IaCeVP+sBgB6xTvMasclXmkP9g==, tarball: file:../forgejo-notifications-core/forgejo-notifications-core-0.1.0-alpha-1.tgz} name: forgejo-notifications-core version: 0.1.0-alpha-1 dev: false diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d44315f..0c50efe 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -15,12 +15,11 @@
- - {#if user_value} +

Hello {user_value.username}

+ + {:else} + {/if} - - -
diff --git a/src/routes/IssueAttrGrp.svelte b/src/routes/IssueAttrGrp.svelte index 6e21275..fe10c0c 100644 --- a/src/routes/IssueAttrGrp.svelte +++ b/src/routes/IssueAttrGrp.svelte @@ -19,7 +19,7 @@ {#if assignments > 0} {#if user_val} - + {/if} {/if} diff --git a/src/routes/Login.svelte b/src/routes/Login.svelte index 70ee46c..642e295 100644 --- a/src/routes/Login.svelte +++ b/src/routes/Login.svelte @@ -11,6 +11,11 @@ user_val = value; }); + let api_val; + api.subscribe((value) => { + api_val = value; + }); + let notification_val; notification.subscribe((value) => { notification_val = value; @@ -125,11 +130,23 @@ }); }; - const login = async (e) => { - e.preventDefault(); - let api_val = new Forgejo(instanceUrl); - await api_val.setTokenAuth(accessToken); - let tmpUser = await api_val.getUser(); + const isIssueAssigned = (i) => { + let local_assigned = false; + if (i.assignee) { + if (i.assignee.username == user_val.username) { + local_assigned = true; + } + } + if (i.assignees) { + i.assignees.forEach((a) => { + if (a.username == user_val.username) { + local_assigned = true; + } + }); + } + }; + + const hydrate = async () => { let local_notifications = await api_val.getNotifications(); local_notifications.forEach(async (n) => { if (n.subject.type == "Issue") { @@ -142,33 +159,29 @@ indexNotification(n, i); - let local_assigned = false; - if (i.assignee) { - if (i.assignee.username == user_val.username) { - local_assigned = true; - } - } - if (i.assignees) { - i.assignees.forEach((a) => { - if (a.username == user_val.username) { - local_assigned = true; - } - }); - } n.subject["local_issue"] = i; + n.subject["local_assigned"] = isIssueAssigned(i); n.subject["local_mention"] = await api_val.findMentionsInIssue(i); } organisations.update(() => updateOrg(n, organisations_val)); }); - user.update(() => tmpUser); - api.update(() => api_val); - notification.update(() => { return local_notifications; }); }; + + const login = async (e) => { + e.preventDefault(); + api_val = new Forgejo(instanceUrl); + api_val.setCors(); + await api_val.setTokenAuth(accessToken); + user_val = await api_val.getUser(); + user.update(() => user_val); + api.update(() => api_val); + await hydrate(); + };
diff --git a/src/routes/Notifications b/src/routes/Notifications deleted file mode 100644 index 81e3504..0000000 --- a/src/routes/Notifications +++ /dev/null @@ -1,42 +0,0 @@ - - -
-

Repositories

-
    - {#each organisations_val as org} -

    - {org.name} - -

    -
      - {#each org.repo as repo} -
    1. - {repo.name} - -
    2. - {/each} -
    - {/each} -
-
diff --git a/src/routes/Notifications.svelte b/src/routes/Notifications.svelte index 6b38234..8aba7bf 100644 --- a/src/routes/Notifications.svelte +++ b/src/routes/Notifications.svelte @@ -8,6 +8,9 @@ notification.subscribe((value) => { notification_val = value; }); + + let mentions_icon = "/at-sign.svg"; + let issues_icon = "/bell.svg";
@@ -34,8 +37,14 @@ {/if} {/if} {n.subject.title} + {#if n.subject.html_url.local_assignments} + {#if user_val} + + {/if} + {/if} + {#if n.subject.html_url.local_mention} - + {/if} diff --git a/src/routes/Repository.svelte b/src/routes/Repository.svelte index 81e3504..94682f5 100644 --- a/src/routes/Repository.svelte +++ b/src/routes/Repository.svelte @@ -13,12 +13,16 @@ }); -
+
+ diff --git a/src/routes/Search.svelte b/src/routes/Search.svelte index 2ccc470..558a17b 100644 --- a/src/routes/Search.svelte +++ b/src/routes/Search.svelte @@ -1,74 +1,70 @@ -{#if enableClearResults} - +{#if results.length > 0} + {/if}
    -

    Search Results

    - {#each results as r} - -
  1. -

    {r.content}

    - {r.id} -
    - {#each r.itemType as i} - {i} - {/each} -
    -
  2. - {/each} + {#if results.length > 0} +

    Search Results

    + {/if} + {#each results as r} + +
  3. +

    {r.content}

    + {r.id} +
    + {#each r.itemType as i} + {i} + {/each} +
    +
  4. + {/each}
diff --git a/src/routes/notifications/+page.svelte b/src/routes/notifications/+page.svelte deleted file mode 100644 index d44315f..0000000 --- a/src/routes/notifications/+page.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - -
- - - {#if user_value} -

Hello {user_value.username}

- {/if} - - - -
diff --git a/src/routes/notifications/IssueAttr.svelte b/src/routes/notifications/IssueAttr.svelte deleted file mode 100644 index bae66ef..0000000 --- a/src/routes/notifications/IssueAttr.svelte +++ /dev/null @@ -1,8 +0,0 @@ - - -{#if count > 0 && img} - {count} -{/if} diff --git a/src/routes/notifications/IssueAttrGrp.svelte b/src/routes/notifications/IssueAttrGrp.svelte deleted file mode 100644 index 6e21275..0000000 --- a/src/routes/notifications/IssueAttrGrp.svelte +++ /dev/null @@ -1,33 +0,0 @@ - - - - {#if assignments > 0} - {#if user_val} - - {/if} - {/if} - - {#if mentions > 0} - - {/if} - - {#if issues > 0} - - {/if} -