diff --git a/materialious/src/lib/Api/index.ts b/materialious/src/lib/Api/index.ts index a09792ce..b25e0326 100644 --- a/materialious/src/lib/Api/index.ts +++ b/materialious/src/lib/Api/index.ts @@ -57,3 +57,10 @@ export async function getSearch(search: string, options: { const resp = await fetch(path); return await resp.json(); } + +export async function getFeed(maxResults: number, page: number) { + const path = new URL(buildPath("auth/feed")); + path.search = new URLSearchParams({ max_results: maxResults.toString(), page: page.toString() }).toString(); + const resp = await fetch(path, buildAuthHeaders()); + return await resp.json(); +} \ No newline at end of file diff --git a/materialious/src/lib/Api/model.ts b/materialious/src/lib/Api/model.ts index 4a1f1287..c52052ff 100644 --- a/materialious/src/lib/Api/model.ts +++ b/materialious/src/lib/Api/model.ts @@ -155,3 +155,12 @@ export interface SearchSuggestion { query: string; suggestions: string[]; } + +export interface Notification extends VideoBase { + type: "video" | "shortVideo" | "stream"; +} + +export interface Feed { + notifications: Notification[]; + videos: Video[]; +} \ No newline at end of file diff --git a/materialious/src/lib/Thumbnail.svelte b/materialious/src/lib/Thumbnail.svelte index 4eb45e52..f75a6afc 100644 --- a/materialious/src/lib/Thumbnail.svelte +++ b/materialious/src/lib/Thumbnail.svelte @@ -3,7 +3,7 @@ import type { Video, VideoBase } from './Api/model'; import { cleanNumber, truncate } from './misc'; - export let video: VideoBase | Video; + export let video: VideoBase | Video | Notification; function videoLength(lengthSeconds: number): string { const hours = Math.floor(lengthSeconds / 3600); diff --git a/materialious/src/routes/+layout.svelte b/materialious/src/routes/+layout.svelte index 2c076d4b..e1e99784 100644 --- a/materialious/src/routes/+layout.svelte +++ b/materialious/src/routes/+layout.svelte @@ -1,7 +1,8 @@ @@ -423,7 +436,13 @@
No new notifications here
+ {#if notifications.length === 0} +No new notifications here
+ {:else} + {#each notifications as notification} +