mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 05:18:58 +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()) {
|
try (var connection = dataSource.getConnection()) {
|
||||||
|
|
||||||
return domainIdCache.get(domain, () -> {
|
return domainIdCache.get(domain, () -> {
|
||||||
@ -42,6 +42,9 @@ public class DbDomainQueries {
|
|||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
catch (UncheckedExecutionException ex) {
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
}
|
||||||
catch (ExecutionException ex) {
|
catch (ExecutionException ex) {
|
||||||
throw new RuntimeException(ex.getCause());
|
throw new RuntimeException(ex.getCause());
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import java.nio.IntBuffer;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class SearchSiteSubscriptionService {
|
public class SearchSiteSubscriptionService {
|
||||||
@ -65,10 +66,15 @@ public class SearchSiteSubscriptionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubscribed(Context context, EdgeDomain domain) {
|
public boolean isSubscribed(Context context, EdgeDomain domain) {
|
||||||
|
try {
|
||||||
int domainId = dbDomainQueries.getDomainId(domain);
|
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) {
|
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>
|
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>
|
</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="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>
|
<div class="bg-margeblue text-white p-2 text-sm">Recently Discovered Domains</div>
|
||||||
|
|
||||||
@ -73,6 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user