warn user instead of disallowing unsupported servers
This commit is contained in:
		
							parent
							
								
									1da2789684
								
							
						
					
					
						commit
						e6c5bcf3c3
					
				
					 4 changed files with 15 additions and 31 deletions
				
			
		
							
								
								
									
										4
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -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", | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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; | ||||
|         } | ||||
| 
 | ||||
|         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); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue