mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
Simplify Avatar component and get rid of extra requests
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import type { Author } from "@app/lib/cobs";
|
||||
|
||||
import Avatar from "@app/components/Comment/Avatar.svelte";
|
||||
import Avatar from "@app/components/Avatar.svelte";
|
||||
import { formatNodeId, formatTimestamp } from "@app/lib/utils";
|
||||
|
||||
export let author: Author;
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<span class="authorship txt-tiny" title={relativeTimestamp(timestamp)}>
|
||||
{#if !noAvatar}
|
||||
<Avatar inline source={author.id} title={author.id} />
|
||||
<Avatar inline nodeId={author.id} />
|
||||
{/if}
|
||||
<span class:highlight class="id highlight layout-desktop">
|
||||
{formatNodeId(author.id)}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { createIcon } from "@app/lib/blockies";
|
||||
import { isNodeId } from "@app/lib/utils";
|
||||
|
||||
export let title: string;
|
||||
export let source: string;
|
||||
export let nodeId: string;
|
||||
export let inline = false;
|
||||
|
||||
function handleMissingFile() {
|
||||
console.warn("Not able to locate", source);
|
||||
source = createContainer(title);
|
||||
}
|
||||
|
||||
function createContainer(source: string) {
|
||||
source = source.replace("did:key:", "");
|
||||
const seed = source.toLowerCase();
|
||||
@@ -21,10 +14,6 @@
|
||||
});
|
||||
return avatar.toDataURL();
|
||||
}
|
||||
|
||||
if (isNodeId(source)) {
|
||||
source = createContainer(source);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -48,9 +37,8 @@
|
||||
</style>
|
||||
|
||||
<img
|
||||
{title}
|
||||
src={source}
|
||||
title={nodeId}
|
||||
src={createContainer(nodeId)}
|
||||
class="avatar"
|
||||
alt="avatar"
|
||||
on:error={handleMissingFile}
|
||||
class:inline />
|
||||
Reference in New Issue
Block a user