From 6c68fb3aa2729e8ee575beeb1cc431e308bc6a22 Mon Sep 17 00:00:00 2001 From: ari melody Date: Fri, 21 Jun 2024 07:19:31 +0100 Subject: [PATCH] data version tracking, video support, a11y tweaks --- package.json | 2 +- src/client/api.js | 1 + src/client/client.js | 7 +++++++ src/post/Body.svelte | 34 ++++++++++++++++++++++++---------- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 18c0ab0..28b14be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spacesocial-client", - "version": "0.1.0", + "version": "0.1.1", "description": "social media for the galaxy-wide-web! 🌌", "type": "module", "scripts": { diff --git a/src/client/api.js b/src/client/api.js index 9dc440c..6528fd9 100644 --- a/src/client/api.js +++ b/src/client/api.js @@ -148,6 +148,7 @@ export async function parsePost(data, num_replies) { post.boost_count = data.reblogs_count; post.reply_count = data.replies_count; post.mentions = data.mentions; + if (data.media_attachments.length > 0) console.log(data.media_attachments); post.files = data.media_attachments; post.url = data.url; post.visibility = data.visibility; diff --git a/src/client/client.js b/src/client/client.js index 7480cb9..5a4988f 100644 --- a/src/client/client.js +++ b/src/client/client.js @@ -1,3 +1,4 @@ +import { version as APP_VERSION } from '../../package.json'; import { Instance, server_types } from './instance.js'; import * as api from './api.js'; @@ -118,6 +119,7 @@ export class Client { save() { localStorage.setItem(save_name, JSON.stringify({ + version: APP_VERSION, instance: { host: this.instance.host, version: this.instance.version, @@ -130,6 +132,11 @@ export class Client { let json = localStorage.getItem(save_name); if (!json) return false; let saved = JSON.parse(json); + if (!saved.version || saved.version !== APP_VERSION) { + localStorage.setItem(save_name + '-backup', json); + localStorage.removeItem(save_name); + return false; + } this.instance = new Instance(saved.instance.host, saved.instance.version); this.app = saved.app; return true; diff --git a/src/post/Body.svelte b/src/post/Body.svelte index cd726b7..14b9ddc 100644 --- a/src/post/Body.svelte +++ b/src/post/Body.svelte @@ -8,7 +8,7 @@
{#if post.warning} -

{ open_warned = !open_warned }}> + {/if} {#if !post.warning || open_warned} {#if post.text} @@ -27,10 +27,18 @@ {/if}

{#each post.files as file} -
- - {file.alt} - +
+ {#if file.type === "image"} + + {file.description} + + {:else if file.type === "video"} + + {/if}
{/each}
@@ -47,10 +55,15 @@ } .post-warning { - margin-bottom: 6px; + width: 100%; + margin-bottom: 10px; padding: 4px 8px; --warn-bg: rgba(255,220,30,.1); - background-image: repeating-linear-gradient(-45deg, transparent, transparent 10px, var(--warn-bg) 10px, var(--warn-bg) 20px); + background: repeating-linear-gradient(-45deg, transparent, transparent 10px, var(--warn-bg) 10px, var(--warn-bg) 20px); + font-size: inherit; + color: inherit; + text-align: left; + border: none; border-radius: 8px; cursor: pointer; outline-color: var(--warn-bg); @@ -139,7 +152,7 @@ .post-media-container { max-height: 540px; - margin-top: 8px; + margin: 16px 0 4px 0; display: grid; grid-gap: 8px; } @@ -176,7 +189,8 @@ cursor: zoom-in; } - .post-media a img { + .post-media img, + .post-media video { width: 100%; height: 100%; display: block;