Skip to content

Commit

Permalink
Merge pull request #6 from destyk/master
Browse files Browse the repository at this point in the history
Hide pagination buttons & fixes
  • Loading branch information
mcpeblocker authored Sep 17, 2022
2 parents eac108a + 8afd5b2 commit a18be32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Pagination {
}

let currentItem = items[i];
let textButton = (typeof currentItem[titleKey] !== 'undefined')
let textButton = (typeof currentItem[titleKey] !== 'undefined' && currentItem[titleKey] != '')
? currentItem[titleKey]
: `Element #${i + 1}`;

Expand All @@ -154,12 +154,14 @@ class Pagination {
row = [];

// Pagination Controls
row.push(getButton(this.messages.prev, `${this._callbackStr}-prev`));
if (this.isEnabledDeleteButton) {
row.push(getButton(this.messages.delete, `${this._callbackStr}-delete`));
if (this.totalPages > 1) {
row.push(getButton(this.messages.prev, `${this._callbackStr}-prev`));
if (this.isEnabledDeleteButton) {
row.push(getButton(this.messages.delete, `${this._callbackStr}-delete`));
}
row.push(getButton(this.messages.next, `${this._callbackStr}-next`));
keyboard.push(row);
}
row.push(getButton(this.messages.next, `${this._callbackStr}-next`));
keyboard.push(row);

// If needed add custom buttons
if (this.inlineCustomButtons && typeof this.inlineCustomButtons === 'object') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telegraf-pagination",
"version": "1.2.1",
"version": "1.2.2",
"description": "A simplified Telegraf plugin to provide users with a great interface.",
"main": "index.js",
"scripts": {},
Expand Down

0 comments on commit a18be32

Please sign in to comment.