Compare commits

...

2 Commits

Author SHA1 Message Date
480c97fb9d 1.18.4
All checks were successful
CI / Lint (push) Successful in 29s
CI / Test (push) Successful in 45s
2026-04-02 14:41:19 +04:00
179cf49370 Fix OSM auth not being loaded correctly on launch 2026-04-02 14:40:20 +04:00
6 changed files with 21 additions and 6 deletions

View File

@@ -7,7 +7,15 @@ class MarcoOsmAuthStorage {
localStorage.setItem('marco:osm_auth_state', serializedState); localStorage.setItem('marco:osm_auth_state', serializedState);
} }
loadState() { loadState() {
return localStorage.getItem('marco:osm_auth_state'); const state = localStorage.getItem('marco:osm_auth_state');
if (!state) return false;
try {
JSON.parse(state);
return state;
} catch (e) {
console.warn('Failed to parse OSM auth state', e);
return false;
}
} }
} }
@@ -45,6 +53,11 @@ export default class OsmAuthService extends Service {
} }
async restoreSession() { async restoreSession() {
try {
await this.oauthClient.ready;
} catch (e) {
console.warn('oauthClient.ready failed', e);
}
const isAuthorized = await this.oauthClient.isAuthorized(); const isAuthorized = await this.oauthClient.isAuthorized();
if (isAuthorized) { if (isAuthorized) {
this.isConnected = true; this.isConnected = true;

View File

@@ -1,6 +1,6 @@
{ {
"name": "marco", "name": "marco",
"version": "1.18.3", "version": "1.18.4",
"private": true, "private": true,
"description": "Unhosted maps app", "description": "Unhosted maps app",
"repository": { "repository": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -39,7 +39,7 @@
<meta name="msapplication-TileColor" content="#F6E9A6"> <meta name="msapplication-TileColor" content="#F6E9A6">
<meta name="msapplication-TileImage" content="/icons/icon-144.png"> <meta name="msapplication-TileImage" content="/icons/icon-144.png">
<script type="module" crossorigin src="/assets/main-BPMVqwjL.js"></script> <script type="module" crossorigin src="/assets/main-0ky279gM.js"></script>
<link rel="stylesheet" crossorigin href="/assets/main-BF2Ls-fG.css"> <link rel="stylesheet" crossorigin href="/assets/main-BF2Ls-fG.css">
</head> </head>
<body> <body>

View File

@@ -52,6 +52,7 @@ module('Unit | Service | osm-auth', function (hooks) {
// Because restoreSession runs in the constructor, we might need to overwrite it after, but it's async. // Because restoreSession runs in the constructor, we might need to overwrite it after, but it's async.
// Let's just create it, let the original restoreSession fail or do nothing, and then we stub and re-call it. // Let's just create it, let the original restoreSession fail or do nothing, and then we stub and re-call it.
service.oauthClient.ready = Promise.resolve();
service.oauthClient.isAuthorized = async () => true; service.oauthClient.isAuthorized = async () => true;
window.localStorage.setItem('marco:osm_user_display_name', 'CachedName'); window.localStorage.setItem('marco:osm_user_display_name', 'CachedName');
@@ -68,6 +69,7 @@ module('Unit | Service | osm-auth', function (hooks) {
test('it fetches user info when logged in but no cached name', async function (assert) { test('it fetches user info when logged in but no cached name', async function (assert) {
let service = this.owner.factoryFor('service:osm-auth').create(); let service = this.owner.factoryFor('service:osm-auth').create();
service.oauthClient.ready = Promise.resolve();
service.oauthClient.isAuthorized = async () => true; service.oauthClient.isAuthorized = async () => true;
service.oauthClient.getTokens = async () => ({ accessToken: 'fake-token' }); service.oauthClient.getTokens = async () => ({ accessToken: 'fake-token' });
// Ensure localStorage is empty for this key // Ensure localStorage is empty for this key