Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Fixed mocks and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Oct 22, 2024
1 parent 11f1ad3 commit 294a646
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 1,153 deletions.
40 changes: 9 additions & 31 deletions docs/elements/my-notifications-icon-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ import { mdiBell } from '@mdi/js';
import { decode } from '@msgpack/msgpack';
import { decodeHashFromBase64 } from '@holochain/client';
import { render, html } from "lit";
import { Signal } from '@holochain-open-dev/signals';
import { Signal, toPromise } from '@holochain-open-dev/signals';

import { NotificationsZomeMock, sampleNotification } from "../../ui/src/mocks.ts";
import { NotificationsZomeMock } from "../../ui/src/mocks.ts";
import { NotificationsStore } from "../../ui/src/notifications-store.ts";
import { NotificationsClient } from "../../ui/src/notifications-client.ts";

Expand All @@ -82,38 +82,16 @@ onMounted(async () => {
);
const profilesStore = new ProfilesStore(new ProfilesClient(profilesMock, "notifications_test"));

const myProfile = await toPromise(profilesStore.myProfile);

const mock = new NotificationsZomeMock();
const client = new NotificationsClient(mock, "notifications_test");

const notification = await sampleNotification(client);

const record = await mock.create_notification(notification);

const store = new NotificationsStore(client, {
types: {
type1: {
name: 'Hello!',
description: 'something',
title(group) {
return new Signal.State({
status: 'completed',
value: group,
});
},
onClick: group => alert(`clicked notification of group: ${group}`),
contents: n => {
const i = decode(n.entry.content);
return new Signal.State({
status: 'completed',
value: {
iconSrc: wrapPathInSvg(mdiBell),
body: i.body,
},
});
},
},
},
});
const record = await client.sendNotification(myProfile.profileHash, 'example', 'type1', 'group1', {
Hello: 'world!'
});

const store = new NotificationsStore(client);

render(html`
<profiles-context .store=${profilesStore}>
Expand Down
40 changes: 9 additions & 31 deletions docs/elements/my-notifications-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ import { render, html } from "lit";
import { wrapPathInSvg } from '@holochain-open-dev/elements/dist/icon.js'
import { mdiBell } from '@mdi/js';
import { decode } from '@msgpack/msgpack';
import { Signal } from '@holochain-open-dev/signals';
import { Signal, toPromise } from '@holochain-open-dev/signals';

import { NotificationsZomeMock, sampleNotification } from "../../ui/src/mocks.ts";
import { NotificationsZomeMock } from "../../ui/src/mocks.ts";
import { NotificationsStore } from "../../ui/src/notifications-store.ts";
import { NotificationsClient } from "../../ui/src/notifications-client.ts";

Expand All @@ -82,38 +82,16 @@ onMounted(async () => {
);
const profilesStore = new ProfilesStore(new ProfilesClient(profilesMock, "notifications_test"));

const myProfile = await toPromise(profilesStore.myProfile);

const mock = new NotificationsZomeMock();
const client = new NotificationsClient(mock, "notifications_test");

const notification = await sampleNotification(client);

const record = await mock.create_notification(notification);

const store = new NotificationsStore(client, {
types: {
type1: {
name: 'Hello!',
description: 'something',
title(group) {
return new Signal.State({
status: 'completed',
value: group,
});
},
onClick: group => alert(`clicked notification of group: ${group}`),
contents: n => {
const i = decode(n.entry.content);
return new Signal.State({
status: 'completed',
value: {
iconSrc: wrapPathInSvg(mdiBell),
body: i.body,
},
});
},
},
},
});
const record = await client.sendNotification(myProfile.profileHash, 'example', 'type1', 'group1', {
Hello: 'world!'
});

const store = new NotificationsStore(client);

render(html`
<profiles-context .store=${profilesStore}>
Expand Down
Loading

0 comments on commit 294a646

Please sign in to comment.