From 6d2b49fcbb1d0073eea74be11f42b6b12bf55020 Mon Sep 17 00:00:00 2001 From: Yizhe Shen Date: Fri, 25 Jul 2014 22:07:15 -0400 Subject: [PATCH] Fixed handling of 'page' parameter for 'list' commands. - The 'page' parameter will default to the total number of pages, if it's greater than the total --- plugin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index 121e174..29675be 100644 --- a/plugin.py +++ b/plugin.py @@ -655,8 +655,9 @@ class TriviaTime(callbacks.Plugin): pages = int(count / 3) if count % 3 > 0: pages += 1 - if page is None or page < 1: + if page is None: page = 1 + page = max(1, min(page, pages)) if self.registryValue('general.globalstats'): deletes = threadStorage.getDeleteTop3(page) else: @@ -700,8 +701,9 @@ class TriviaTime(callbacks.Plugin): pages = int(count / 3) if count % 3 > 0: pages += 1 - if page is None or page < 1: + if page is None: page = 1 + page = max(1, min(page, pages)) if self.registryValue('general.globalstats'): edits = threadStorage.getEditTop3(page) else: @@ -735,8 +737,9 @@ class TriviaTime(callbacks.Plugin): pages = int(count / 3) if count % 3 > 0: pages += 1 - if page is None or page < 1: + if page is None: page = 1 + page = max(1, min(page, pages)) if self.registryValue('general.globalstats'): reports = threadStorage.getReportTop3(page) else: @@ -775,8 +778,9 @@ class TriviaTime(callbacks.Plugin): pages = int(count / 3) if count % 3 > 0: pages += 1 - if page is None or page < 1: + if page is None: page = 1 + page = max(1, min(page, pages)) if self.registryValue('general.globalstats'): q = threadStorage.getTemporaryQuestionTop3(page) else: