wip(webui): partially fix "HAS" -> "OF" switch

feat/type-attributes
Tomáš Mládek 2023-06-15 10:35:10 +02:00
parent 8bf75a7c9e
commit 0177fe007d
6 changed files with 18 additions and 37 deletions

View File

@ -1,5 +0,0 @@
export const BLOB_TYPE_ADDR =
"zQmWvjFhyhxpCxZy89VzyEe1mXqk8cX9X5b3xewbM3bf7CB";
export const GROUP_TYPE_ADDR =
"zQmZ523exNAbYdsMsoxfNcwTjxkUWqCX6GZjVqJgCoG54Wv";

View File

@ -14,7 +14,6 @@
import IconButton from "./utils/IconButton.svelte";
import type { BrowseContext } from "../util/browse";
import { Link, useParams } from "svelte-navigator";
import { GROUP_TYPE_ADDR } from "upend/constants";
import Icon from "./utils/Icon.svelte";
import BlobViewer from "./display/BlobViewer.svelte";
import { i18n } from "../i18n";
@ -109,6 +108,7 @@
![
"IS",
"LBL",
"OF",
"NOTE",
"LAST_VISITED",
"NUM_VISITED",
@ -120,17 +120,9 @@
? untypedAttributes
: filteredUntypedAttributes;
$: currentBacklinks =
(editable
? $entity?.backlinks
: $entity?.backlinks.filter(
(entry) => !["HAS"].includes(entry.attribute)
)) || [];
$: currentBacklinks = $entity?.backlinks || [];
$: groups = ($entity?.backlinks || [])
.filter((e) => e.attribute === "HAS")
.map((e) => [e.address, e.entity])
.sort(); // TODO
$: groups = [];
let attributesUsed: UpEntry[] = [];
$: {
@ -177,19 +169,11 @@
}
await api.putEntry([
{
entity: String(groupToAdd.c),
attribute: "HAS",
entity: address,
attribute: "OF",
value: {
t: "Address",
c: address,
},
},
{
entity: String(groupToAdd.c),
attribute: "IS",
value: {
t: "Address",
c: GROUP_TYPE_ADDR,
c: String(groupToAdd.c),
},
},
]);

View File

@ -37,12 +37,16 @@
let failedChildren: string[] = [];
let loadedChildren: string[] = [];
$: groupChildren = ($entity?.attr["HAS"] || [])
.map((e) => String(e.value.c))
$: groupChildren = $entity?.backlinks
.filter((e) => e.attribute === "OF")
.map((e) => String(e.entity))
.filter(
(addr) =>
!failedChildren
.slice(0, ($entity?.attr["HAS"] || []).length - 4)
.slice(
0,
$entity?.backlinks.filter((e) => e.attribute === "OF").length - 4
)
.includes(addr)
)
.slice(0, 4);

View File

@ -1,6 +1,6 @@
<script lang="ts">
import { createEventDispatcher, getContext } from "svelte";
import { BLOB_TYPE_ADDR } from "upend/constants";
import HashBadge from "./HashBadge.svelte";
import Ellipsis from "../utils/Ellipsis.svelte";
import UpLink from "./UpLink.svelte";
@ -10,7 +10,6 @@
import { vaultInfo } from "../../util/info";
import type { BrowseContext } from "../../util/browse";
import type { UpObject } from "upend";
import { i18n } from "../../i18n";
import type { EntityInfo } from "upend/types";
import { useEntity } from "../../lib/entity";
import api from "../../lib/api";
@ -27,7 +26,7 @@
({ entity, entityInfo } = useEntity(address));
// isFile
$: isFile = $entity?.get("IS") === BLOB_TYPE_ADDR;
$: isFile = $entityInfo?.t == "Hash";
// Identification
let inferredIds: string[] = [];

View File

@ -1,6 +1,5 @@
import type { EntityInfo } from "upend/types";
import type { UpObject } from "upend";
import { GROUP_TYPE_ADDR } from "upend/constants";
export function getTypes(entity: UpObject, entityInfo: EntityInfo) {
const mimeType = String(entity?.get("FILE_MIME"));
@ -23,7 +22,7 @@ export function getTypes(entity: UpObject, entityInfo: EntityInfo) {
const web = entityInfo?.t == "Url";
const fragment = Boolean(entity?.get("ANNOTATES"));
const group = entity?.get("IS") == GROUP_TYPE_ADDR;
const group = entity?.backlinks.some((e) => e.attribute == "OF");
return {
mimeType,

View File

@ -12585,11 +12585,11 @@ __metadata:
"upend@file:../tools/upend_js::locator=upend-kestrel%40workspace%3A.":
version: 0.0.1
resolution: "upend@file:../tools/upend_js#../tools/upend_js::hash=67912a&locator=upend-kestrel%40workspace%3A."
resolution: "upend@file:../tools/upend_js#../tools/upend_js::hash=f2ceee&locator=upend-kestrel%40workspace%3A."
dependencies:
debug: ^4.3.4
lru-cache: ^7.0.0
checksum: e89edf5fc49b52de1f6bcc8574c5a5c9d6decfb0150f03355d54d2fa8f507962c0a5eaf71c49a23c60a3e088c218f39eb83d5a7ec06c891117cbc1dcdb1445b6
checksum: aaeb2d9605684b048f9b0da394c60108ca655bedcb633aa752d6163094123435b2b4b5408244890822fc1444af5ffb9b0372a69c0a4f04e3b080ced6b77146b7
languageName: node
linkType: hard