diff --git a/web/db/db.go b/web/db/db.go index ded731e..fb45cf2 100644 --- a/web/db/db.go +++ b/web/db/db.go @@ -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("e.ID, "e.Text, "e.Author, "e.Datetime, "e.Creator.ID, "e.Creator.Name, "e.Creator.Login, "e.Creator.Role, "e.Creator.TelegramID) diff --git a/web/static/js/quotes.js b/web/static/js/quotes.js index d0b677f..57b3fae 100644 --- a/web/static/js/quotes.js +++ b/web/static/js/quotes.js @@ -95,6 +95,10 @@ function load() { type: "GET", dataType: "json", success: function (resp) { + if (resp.length == 0) { + container.html("

Чёт нету ничего...

"); + 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);