mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(search) Fix site info view for completely unknown domains
Also correct the DbDomainQueries.getDomainId so that it throws NoSuchElementException when domain id is missing, and not UncheckedExecutionException via Cache.
This commit is contained in:
parent
0c839453c5
commit
ab5c30ad51
@ -28,7 +28,7 @@ public class DbDomainQueries {
|
||||
}
|
||||
|
||||
|
||||
public Integer getDomainId(EdgeDomain domain) {
|
||||
public Integer getDomainId(EdgeDomain domain) throws NoSuchElementException {
|
||||
try (var connection = dataSource.getConnection()) {
|
||||
|
||||
return domainIdCache.get(domain, () -> {
|
||||
@ -42,6 +42,9 @@ public class DbDomainQueries {
|
||||
throw new NoSuchElementException();
|
||||
});
|
||||
}
|
||||
catch (UncheckedExecutionException ex) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
catch (ExecutionException ex) {
|
||||
throw new RuntimeException(ex.getCause());
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import java.nio.IntBuffer;
|
||||
import java.time.Duration;
|
||||
import java.util.Base64;
|
||||
import java.util.HashSet;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
public class SearchSiteSubscriptionService {
|
||||
@ -65,9 +66,14 @@ public class SearchSiteSubscriptionService {
|
||||
}
|
||||
|
||||
public boolean isSubscribed(Context context, EdgeDomain domain) {
|
||||
int domainId = dbDomainQueries.getDomainId(domain);
|
||||
try {
|
||||
int domainId = dbDomainQueries.getDomainId(domain);
|
||||
|
||||
return getSubscriptions(context).contains(domainId);
|
||||
return getSubscriptions(context).contains(domainId);
|
||||
}
|
||||
catch (NoSuchElementException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleSubscription(Context context, EdgeDomain domain) {
|
||||
|
@ -44,6 +44,7 @@
|
||||
marginalia search resources, instead reach out with an email, and we'll work out some way of exporting the data or creating a dedicated API instead.</p>
|
||||
</div>
|
||||
|
||||
@if (!model.domains().isEmpty())
|
||||
<div class="border dark:border-gray-600 rounded md:my-4 overflow-hidden w-full md:w-auto">
|
||||
<div class="bg-margeblue text-white p-2 text-sm">Recently Discovered Domains</div>
|
||||
|
||||
@ -73,6 +74,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user