Skip to content

Commit

Permalink
feed poc
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Dec 6, 2023
1 parent 6b7f4bd commit d45ea18
Show file tree
Hide file tree
Showing 7 changed files with 3,352 additions and 8 deletions.
29 changes: 29 additions & 0 deletions apps/bos-blocks/widget/Compose.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Create = () => {
return (
<div className="row">
<div className="col-md-3">
<div className="d-flex flex-column gap-4">
<select className="form-select p-2 border rounded">
<option>Type 1</option>
<option>Type 2</option>
<option>Type 3</option>
</select>
<select className="form-select p-2 border rounded">
<option>Adapter A</option>
<option>Adapter B</option>
<option>Adapter C</option>
</select>
<select className="form-select p-2 border rounded">
<option>Template X</option>
<option>Template Y</option>
<option>Template Z</option>
</select>
<button className="btn btn-primary p-2 rounded">Submit</button>
</div>
</div>
<div className="col-md-9 p-4 border"></div>
</div>
);
};

return { Create };
3 changes: 1 addition & 2 deletions apps/bos-blocks/widget/Create.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const Create = ({ toggleShowCreate }) => {
const Create = () => {
return (
<div className="row">
<button onClick={toggleShowCreate}>back</button>
<div className="col-md-3">
<div className="d-flex flex-column gap-4">
<select className="form-select p-2 border rounded">
Expand Down
70 changes: 64 additions & 6 deletions apps/bos-blocks/widget/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
/**
* TODO
*
* - [ ] add compose for feed, it shares the same "item", but uses a different "set" adapter (Social.index vs Social.set)
* - [ ]
*
*/

const { Feed } = VM.require("devs.near/widget/Feed") || (() => {});
const { Create } = VM.require("devs.near/widget/Create") || (() => {});

const accountId = context.accountId;

const myFeeds = JSON.parse(
Social.get(`${context.accountId}/settings/every/feed`, "final") || "null"
);

function getPersonalizedIndex() {
if (myFeeds) {
return myFeeds.map((feed) => {
return {
action: feed.action,
key: feed.key,
options: {
limit: 10,
order: "desc",
accountId: undefined,
},
cacheOptions: {
ignoreCache: true,
},
};
});
} else {
return [];
}
}

const availableFeeds = [
{
name: "main",
description: "Main feed",
type: "social",
postTemplate: "devs.near/widget/Post",
props: {
index: [
{
Expand Down Expand Up @@ -41,6 +75,7 @@ const availableFeeds = [
name: "#dev",
description: "hashtag feed",
type: "social",
postTemplate: "devs.near/widget/Post",
props: {
index: {
action: "hashtag",
Expand All @@ -56,6 +91,32 @@ const availableFeeds = [
},
},
},
{
name: "embeds",
description: "embeds feed",
type: "social",
postTemplate: "embeds.near/widget/Post.Index",
props: {
index: {
action: "post",
key: "main",
options: {
limit: 10,
order: "desc",
accountId: ["efiz.near"],
},
},
},
},
{
name: "personalized",
description: "personalized feed",
type: "social",
postTemplate: "mob.near/widget/N.Post",
props: {
index: getPersonalizedIndex(),
},
},
];

const defaultFeed = availableFeeds[0];
Expand All @@ -67,21 +128,18 @@ const toggleShowCreate = () => {
};

function Content({ data }) {
const { props } = data;
const { props, postTemplate } = data;
return (
<div key={data.name} className="border p-4 rounded">
{showCreate ? (
<div>
<button onClick={toggleShowCreate}>back</button>
<Create />
</div>
<Create />
) : (
<Feed
index={props.index}
Item={({ accountId, path, blockHeight, type }) => {
return (
<Widget
src={"mob.near/widget/N.Post"}
src={postTemplate}
props={{
accountId,
path,
Expand Down
7 changes: 7 additions & 0 deletions apps/bos-blocks/widget/Feed.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* TODO
*
* - [ ] allow a different source, like widget for an ItemFeed
* - [ ]
*
*/
const Feed = ({ index, typeWhitelist, Item, Layout }) => {
Item = Item || ((props) => <div>{JSON.stringify(props)}</div>);
Layout = Layout || (({ children }) => children);
Expand Down
Empty file removed apps/bos-blocks/widget/Form.jsx
Empty file.
Loading

0 comments on commit d45ea18

Please sign in to comment.