Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ make install # installs built binary in $GOPATH/bin
dgraph
```

**Alternative** for step **1)**: find Unigraph's Dgraph binary for your platform on [GitHub Releases](https://github.com/unigraph-dev/dgraph/releases) and rename it to `dgraph`. On Linux or macOS, you'll need to make it executable: `chmod +x ./Downloads/dgraph`. Then, continue to step **2)**.

**2)** In the `unigraph` project root, fetch and build project dependencies:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ const getQuery = (msgid) => `(func: uid(parIds)) @cascade {
}
}`;

const dest = parsed.map((el) => {
const dest = parsed.map((el, index) => {
return {
name: {
type: { 'unigraph.id': '$/schema/note' },
_value: el.subject || '',
},
...(msgs[index].externalUrl
? {
$context: {
_externalUrl: msgs[index].externalUrl,
},
}
: {}),
message_id: el.messageId,
message: {
date_received: el.date?.toISOString?.() || new Date(0).toISOString(),
Expand Down Expand Up @@ -97,28 +104,29 @@ for (let i = 0; i < toAddChunks.length; i += 1) {
}
}

const inboxEntries = await unigraph.getObject('$/entity/inbox').then((x) => x._value.children._value ?? []);
const inboxEntryUids = inboxEntries.map((x) => x._value._value.uid);
// const inboxEntries = await unigraph.getObject('$/entity/inbox').then((x) => x._value.children._value ?? []);
// const inboxEntryUids = inboxEntries.map((x) => x._value._value.uid);

const mirrorEmailInbox = unigraph.getState('settings/email/mirrorEmailInbox').value;
// const mirrorEmailInbox = unigraph.getState('settings/email/mirrorEmailInbox').value;
uids.forEach((el, index) => {
// if (!readMask[index] && el) inboxEls.push(el);
const elShouldBeInbox = (mirrorEmailInbox ? inboxMask[index] : !readMask[index]) && el;
const elInInbox = inboxEntryUids.includes(el);
if (elShouldBeInbox && !elInInbox) inboxEls.push(el);
if (inboxMask[index] && el) inboxEls.push(el);
// const elShouldBeInbox = (mirrorEmailInbox ? inboxMask[index] : !readMask[index]) && el;
// const elInInbox = inboxEntryUids.includes(el);
// if (elShouldBeInbox && !elInInbox) inboxEls.push(el);
});

await unigraph.runExecutable('$/executable/add-item-to-list', {
where: '$/entity/inbox',
item: inboxEls.reverse(),
});
setTimeout(
() =>
unigraph.addNotification({
name: 'Inboxes synced',
from: 'unigraph.email',
content: `Added ${count} emails (${inboxEls.length} unread).`,
actions: [],
}),
1000,
);
if (count > 0)
setTimeout(
() =>
unigraph.addNotification({
name: 'Inboxes synced',
from: 'unigraph.email',
content: `Added ${count} emails (${inboxEls.length} in inbox).`,
actions: [],
}),
1000,
);
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,21 @@ const updateAccountInbox = async (account) => {
messages.map((id) => gmail.users.messages.get({ userId: 'me', id, format: 'raw' })),
);
const inbox = await unigraph.getObject('$/entity/inbox');
const inboxEntries = inbox._value.children['_value['] ?? [];
const inboxEntries = (inbox._value.children['_value['] ?? []).filter(
(x) => x._value._value.type?.['unigraph.id'] === '$/schema/email_message',
);
const inboxEntryUids = inboxEntries.map((x) => x._value._value.uid);
const inboxEntryMsgIds = inboxEntries
.map((x) => [x._value._value?._value?.message_id?.['_value.%'], x._value._value.uid])
.filter(Boolean);
const gmailIdsForCurrentInbox = await Promise.all(
inboxEntryMsgIds.map((el) =>
gmail.users.messages.list({ userId: 'me', q: `rfc822msgid:${el[0]}`, labelIds: ['INBOX'] }),
),
);
const uidsToRemoveInbox = gmailIdsForCurrentInbox
.map((el, idx) => (el.data?.messages?.length > 0 ? undefined : inboxEntryMsgIds[idx][1]))
.filter(Boolean);

const getOldUid = _.curry((condition, el, index) => {
const isCondition = condition(el);
Expand All @@ -111,14 +124,12 @@ const updateAccountInbox = async (account) => {
(el) => el.data.labelIds?.includes('TRASH') || el.data.labelIds?.includes('SPAM'),
);
const isOldAndInOriginInbox = getOldUid((el) => el.data.labelIds?.includes('INBOX'));
const isOldAndNotInOriginInbox = getOldUid((el) => !el.data.labelIds?.includes('INBOX'));

const uidsToDelete = msgResps.map(isOldAndInOriginTrash).filter((el) => el !== undefined);
const uidsToInbox = msgResps
.map(isOldAndInOriginInbox)
.filter((el) => el !== undefined)
.filter((x) => !inboxEntryUids.includes(x));
const uidsToRemoveInbox = msgResps.map(isOldAndNotInOriginInbox).filter((el) => el !== undefined);

// TODO: remove or hide deleted msgs

Expand All @@ -132,6 +143,7 @@ const updateAccountInbox = async (account) => {
dont_check_unique: true,
messages: newMsgResps.map((el) => ({
message: Buffer.from(el.data.raw, 'base64').toString(),
externalUrl: `https://mail.google.com/mail/u/${account._value.username['_value.%']}/#all/${el.data.id}`,
read: !el.data.labelIds?.includes('UNREAD'),
inbox: el.data.labelIds?.includes('INBOX'),
})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ const updateTriplets = [`<${oldNameRef.uid}> <_value.%> "${newName}" .`];
(oldRefName['_value.%'].includes(oldName) || force)
)
updateTriplets.push(
`<${oldRefName.uid}> <_value.%> "${oldRefName['_value.%'].replaceAll(
`[[${oldName}]]`,
`[[${newName}]]`,
)}" .`,
`<${oldRefName.uid}> <_value.%> "${oldRefName['_value.%']
.replaceAll(`[[${oldName}]]`, `[[${newName}]]`)
.replace(/"/g, '\\"')}" .`,
);
});

Expand Down
Binary file modified packages/unigraph-dev-explorer/public/favicon.ico
Binary file not shown.
Binary file modified packages/unigraph-dev-explorer/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/unigraph-dev-explorer/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion packages/unigraph-dev-explorer/src/examples/email/Email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ const EmailMessage: DynamicViewRenderer = ({ data, callbacks }) => {
secondary={[
Sugar.Date.relative(new Date(unpadded?.message?.date_received)),
<div style={{ display: 'flex', alignItems: 'center' }}>
<Link />
<Link
style={{ display: data?._externalUrl ? '' : 'none', marginRight: '4px' }}
onClick={(ev) => {
ev.stopPropagation();
window.open(data._externalUrl, '_blank');
}}
/>
{`${unpadded.content?.abstract}...`}
</div>,
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ export const RedditPost: DynamicViewRenderer = ({ data, callbacks }) => {

return (
<div style={{ display: 'flex' }}>
<div style={{ alignSelf: 'baseline', marginRight: '16px' }}>
<ArrowUpward fontSize="small" />
<p style={{ marginTop: '0px', marginBottom: '2px' }}>Vote</p>
<ArrowDownward fontSize="small" />
</div>
<div
style={{
alignSelf: 'baseline',
Expand Down