Skip to content

Commit

Permalink
Add topic activity page
Browse files Browse the repository at this point in the history
  • Loading branch information
stnguyen90 committed Dec 19, 2023
1 parent 49d532f commit 81cbe71
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script lang="ts">
import type { PageData } from './$types';
import { Activity } from '$lib/layout';
export let data: PageData;
</script>

<Activity {...data} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Query, type Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';

export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);

const payload = {
queries: [Query.limit(limit), Query.offset(offset)]
};

// TODO: remove when the API is ready with data
// This allows us to mock w/ data and when search returns 0 results
const logs: Models.LogList = await sdk.forProject.client.call(
'GET',
new URL(`${sdk.forProject.client.config.endpoint}/messaging/topics/${params.topic}/logs`),
{
'X-Appwrite-Project': sdk.forProject.client.config.project,
'content-type': 'application/json',
'X-Appwrite-Mode': 'admin'
},
payload
);

return {
offset,
limit,
logs
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@
href: `${path}/subscribers`,
title: 'Subscribers',
event: 'subscribers'
},
{
href: `${path}/activity`,
title: 'Activity',
event: 'activity'
}
// {
// href: `${path}/sessions`,
// title: 'Sessions',
// event: 'sessions'
// },
// {
// href: `${path}/activity`,
// title: 'Activity',
// event: 'activity',
// hasChildren: true
// }
];
</script>

Expand Down

0 comments on commit 81cbe71

Please sign in to comment.