fix(web): fix behavior on getting no quotes

This commit is contained in:
Masahiko AMANO 2025-01-07 03:23:48 +03:00
parent 838f089c69
commit b3090f5dc0
2 changed files with 9 additions and 0 deletions

View File

@ -121,6 +121,7 @@ func QuotesGet(ctx context.Context, user_id string, filter string, sort string,
err = fmt.Errorf("error while getting quotes: %w", err)
return
}
quotes = []models.Quote{}
for rows.Next() {
var quote models.Quote
err = rows.Scan(&quote.ID, &quote.Text, &quote.Author, &quote.Datetime, &quote.Creator.ID, &quote.Creator.Name, &quote.Creator.Login, &quote.Creator.Role, &quote.Creator.TelegramID)

View File

@ -95,6 +95,10 @@ function load() {
type: "GET",
dataType: "json",
success: function (resp) {
if (resp.length == 0) {
container.html("<p style='text-align: center;'><i>Чёт нету ничего...</i></p>");
return;
}
resp.forEach((quote) => {
container.append(renderBlockQuote(quote));
});
@ -130,6 +134,10 @@ $(window).on("load", function (e) {
$(document).on("click", "#btn-refresh", function (e) {
search = $("#input-search").val();
if (search != "") {
currPage = 1;
sessionStorage.setItem("search", currPage);
}
sorting = $("#input-sorting option:selected").val();
reload();
sessionStorage.setItem("search", search);