From e6c5bcf3c306e548d05e3bc8bec698f2650dc99b Mon Sep 17 00:00:00 2001 From: ari melody Date: Sat, 22 Jun 2024 16:35:41 +0100 Subject: [PATCH] warn user instead of disallowing unsupported servers --- package-lock.json | 4 ++-- src/client/api.js | 19 ------------------- src/client/client.js | 17 ++++++++++------- src/client/instance.js | 6 +++--- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 53c9631..e6ad192 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "spacesocial-client", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "spacesocial-client", - "version": "0.1.0", + "version": "0.1.1", "license": "ISC", "devDependencies": { "@sveltejs/vite-plugin-svelte": "^3.1.1", diff --git a/src/client/api.js b/src/client/api.js index fe9b860..61cc5a3 100644 --- a/src/client/api.js +++ b/src/client/api.js @@ -93,25 +93,6 @@ export async function getTimeline(last_post_id) { }).then(res => res.json()); return data; - - let posts = []; - for (let i in data) { - const post_data = data[i]; - const post = await parsePost(post_data, 1); - if (!post) { - if (post === null || post === undefined) { - if (post_data.id) { - console.warn("Failed to parse post #" + post_data.id); - } else { - console.warn("Failed to parse post:"); - console.warn(post_data); - } - } - continue; - } - posts.push(post); - } - return posts; } export async function getPost(post_id, num_replies) { diff --git a/src/client/client.js b/src/client/client.js index 5a4988f..2101b0f 100644 --- a/src/client/client.js +++ b/src/client/client.js @@ -39,13 +39,16 @@ export class Client { } this.instance = new Instance(host, data.version); - if (this.instance.type == server_types.INCOMPATIBLE) { - console.error(`Server ${host} is not supported - ${data.version}`); - alert(`Sorry, this app is not compatible with ${host}!`); - return false; - } - - console.log(`Server is "${this.instance.type}" (or compatible) with capabilities: [${this.instance.capabilities}].`); + if (this.instance.type == server_types.UNSUPPORTED) { + console.warn(`Server ${host} is unsupported - ${data.version}`); + if (!confirm( + `This app does not officially support ${host}. ` + + `Things may break, or otherwise not work as epxected! ` + + `Are you sure you wish to continue?` + )) return false; + } else { + console.log(`Server is "${this.instance.type}" (or compatible) with capabilities: [${this.instance.capabilities}].`); + } this.app = await api.createApp(host); diff --git a/src/client/instance.js b/src/client/instance.js index e15d99f..92003e8 100644 --- a/src/client/instance.js +++ b/src/client/instance.js @@ -27,16 +27,16 @@ export class Instance { } #setType(version) { + this.type = server_types.UNSUPPORTED; if (version.constructor !== String) return; let version_lower = version.toLowerCase(); for (let i = 1; i < Object.keys(server_types).length; i++) { const check_type = Object.values(server_types)[i]; if (version_lower.includes(check_type)) { this.type = check_type; - break; + return; } } - if (this.type === server_types.UNSUPPORTED) return; } #getCapabilities(type) { @@ -56,7 +56,7 @@ export class Instance { case server_types.ICESHRIMP: // more trouble than it's worth atm // the server already hands this to us ;p - // c.push(capabilities.MARKDOWN_CONTENT); + //c.push(capabilities.MARKDOWN_CONTENT); c.push(capabilities.REACTIONS); break; case server_types.SHARKEY: