Skip to content

Commit

Permalink
round robin paginate
Browse files Browse the repository at this point in the history
  • Loading branch information
progapandist committed Jun 11, 2024
1 parent a472124 commit 885741a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def index
# We always pick one work
@pagy, works = pagy(Work.all, items: 1)
@work = works.sole
@max_page = @pagy.pages
end

def show
Expand Down
1 change: 0 additions & 1 deletion app/javascript/controllers/hints_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default class extends Controller {

addHintMessage() {
const isMobile = /Mobi|Android/i.test(navigator.userAgent);
console.log(isMobile);

this.hint = document.createElement("div");

Expand Down
7 changes: 3 additions & 4 deletions app/javascript/controllers/random_image_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import { Controller } from "@hotwired/stimulus";
import { Turbo } from "@hotwired/turbo-rails";

let FORMAT = "avif";
let RESIZE = "rs:fit:4000:3000/gravity:sm";
export default class extends Controller {
static targets = ["imageDisplay"];

Expand All @@ -12,6 +10,7 @@ export default class extends Controller {
prevSlug: String,
appEnv: String,
imgproxyUrl: String,
maxPage: Number,
};

static outlets = ["sessions"];
Expand Down Expand Up @@ -62,8 +61,8 @@ export default class extends Controller {
const page = url.searchParams.get("page");
this.pageValue = parseInt(page);

if (!this.pageValue) {
this.pageValue = 1;
if (!this.pageValue || this.pageValue === this.maxPageValue) {
this.pageValue = 0;
}

let newPage = this.pageValue + 1;
Expand Down
1 change: 1 addition & 0 deletions app/views/works/_image.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
data-random-image-imgproxy-url-value="<%= @work.imgproxy_url %>"
data-random-image-prev-slug-value="<%= params[:prev_slug] %>"
data-random-image-target="imageDisplay"
data-random-image-max-page-value="<%= @max_page %>"
data-random-image-app-env-value="<%= Rails.env %>"
data-random-image-sessions-outlet=".session-hex"
data-resize-random-image-outlet=".image-display"
Expand Down

0 comments on commit 885741a

Please sign in to comment.