Add media server selection to Nostr settings
Also, hide the fallback option when there's no server to fall back to
This commit is contained in:
@@ -24,14 +24,15 @@ export default class BlossomService extends Service {
|
||||
@service settings;
|
||||
|
||||
get servers() {
|
||||
const servers = this.nostrData.blossomServers;
|
||||
const allServers = servers.length ? servers : [DEFAULT_BLOSSOM_SERVER];
|
||||
const discovered = this.nostrData.blossomServers;
|
||||
const mainServer = this.settings.nostrMediaServer || DEFAULT_BLOSSOM_SERVER;
|
||||
const fallbacks = discovered.filter((server) => server !== mainServer);
|
||||
|
||||
if (!this.settings.nostrPhotoFallbackUploads) {
|
||||
return [allServers[0]];
|
||||
return [mainServer];
|
||||
}
|
||||
|
||||
return allServers;
|
||||
return [mainServer, ...fallbacks];
|
||||
}
|
||||
|
||||
async _getAuthHeader(action, hash, serverUrl) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
uniqNormalizedRelays,
|
||||
} from '../utils/nostr';
|
||||
import { getGeohashPrefixesInBbox } from '../utils/geohash-coverage';
|
||||
import { DEFAULT_BLOSSOM_SERVER } from './blossom';
|
||||
|
||||
const DIRECTORY_RELAYS = [
|
||||
'wss://relay.primal.net',
|
||||
@@ -437,6 +438,16 @@ export default class NostrDataService extends Service {
|
||||
} else {
|
||||
this.blossomServers = [];
|
||||
}
|
||||
|
||||
if (this.blossomServers.length > 0) {
|
||||
const current = this.settings.nostrMediaServer;
|
||||
if (
|
||||
current === DEFAULT_BLOSSOM_SERVER ||
|
||||
!this.blossomServers.includes(current)
|
||||
) {
|
||||
this.settings.update('nostrMediaServer', this.blossomServers[0]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 1. Await cache initialization and populate the EventStore with local data
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import Service from '@ember/service';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
|
||||
import { DEFAULT_BLOSSOM_SERVER } from './blossom';
|
||||
|
||||
const DEFAULT_SETTINGS = {
|
||||
overpassApi: 'https://overpass-api.de/api/interpreter',
|
||||
mapKinetic: true,
|
||||
photonApi: 'https://photon.komoot.io/api/',
|
||||
showQuickSearchButtons: true,
|
||||
nostrPhotoFallbackUploads: false,
|
||||
nostrMediaServer: DEFAULT_BLOSSOM_SERVER,
|
||||
nostrReadRelays: null,
|
||||
nostrWriteRelays: null,
|
||||
nostrReadRelayExclusions: null,
|
||||
@@ -21,6 +24,7 @@ export default class SettingsService extends Service {
|
||||
@tracked showQuickSearchButtons = DEFAULT_SETTINGS.showQuickSearchButtons;
|
||||
@tracked nostrPhotoFallbackUploads =
|
||||
DEFAULT_SETTINGS.nostrPhotoFallbackUploads;
|
||||
@tracked nostrMediaServer = DEFAULT_SETTINGS.nostrMediaServer;
|
||||
@tracked nostrReadRelays = DEFAULT_SETTINGS.nostrReadRelays;
|
||||
@tracked nostrWriteRelays = DEFAULT_SETTINGS.nostrWriteRelays;
|
||||
@tracked nostrReadRelayExclusions = DEFAULT_SETTINGS.nostrReadRelayExclusions;
|
||||
@@ -114,6 +118,7 @@ export default class SettingsService extends Service {
|
||||
this.photonApi = finalSettings.photonApi;
|
||||
this.showQuickSearchButtons = finalSettings.showQuickSearchButtons;
|
||||
this.nostrPhotoFallbackUploads = finalSettings.nostrPhotoFallbackUploads;
|
||||
this.nostrMediaServer = finalSettings.nostrMediaServer;
|
||||
this.nostrReadRelays = finalSettings.nostrReadRelays;
|
||||
this.nostrWriteRelays = finalSettings.nostrWriteRelays;
|
||||
this.nostrReadRelayExclusions = finalSettings.nostrReadRelayExclusions;
|
||||
@@ -132,6 +137,7 @@ export default class SettingsService extends Service {
|
||||
photonApi: this.photonApi,
|
||||
showQuickSearchButtons: this.showQuickSearchButtons,
|
||||
nostrPhotoFallbackUploads: this.nostrPhotoFallbackUploads,
|
||||
nostrMediaServer: this.nostrMediaServer,
|
||||
nostrReadRelays: this.nostrReadRelays,
|
||||
nostrWriteRelays: this.nostrWriteRelays,
|
||||
nostrReadRelayExclusions: this.nostrReadRelayExclusions,
|
||||
|
||||
Reference in New Issue
Block a user