Refactor settings menu, add Nostr settings

Adds a setting to control if photos should be uploaded only to the
main/default server, or all known servers of a user.

Only upload to the main server by default, to speed up adding photos.
This commit is contained in:
2026-04-21 14:39:24 +04:00
parent 54ba99673f
commit 5bd4dba907
6 changed files with 241 additions and 160 deletions

View File

@@ -21,10 +21,17 @@ function getBlossomUrl(serverUrl, path) {
export default class BlossomService extends Service {
@service nostrAuth;
@service nostrData;
@service settings;
get servers() {
const servers = this.nostrData.blossomServers;
return servers.length ? servers : [DEFAULT_BLOSSOM_SERVER];
const allServers = servers.length ? servers : [DEFAULT_BLOSSOM_SERVER];
if (!this.settings.nostrPhotoFallbackUploads) {
return [allServers[0]];
}
return allServers;
}
async _getAuthHeader(action, hash, serverUrl) {

View File

@@ -6,6 +6,7 @@ export default class SettingsService extends Service {
@tracked mapKinetic = true;
@tracked photonApi = 'https://photon.komoot.io/api/';
@tracked showQuickSearchButtons = true;
@tracked nostrPhotoFallbackUploads = false;
overpassApis = [
{
@@ -64,6 +65,14 @@ export default class SettingsService extends Service {
if (savedShowQuickSearch !== null) {
this.showQuickSearchButtons = savedShowQuickSearch === 'true';
}
const savedNostrPhotoFallbackUploads = localStorage.getItem(
'marco:nostr-photo-fallback-uploads'
);
if (savedNostrPhotoFallbackUploads !== null) {
this.nostrPhotoFallbackUploads =
savedNostrPhotoFallbackUploads === 'true';
}
}
updateOverpassApi(url) {
@@ -84,4 +93,9 @@ export default class SettingsService extends Service {
updatePhotonApi(url) {
this.photonApi = url;
}
updateNostrPhotoFallbackUploads(enabled) {
this.nostrPhotoFallbackUploads = enabled;
localStorage.setItem('marco:nostr-photo-fallback-uploads', String(enabled));
}
}