Skip to content

Commit

Permalink
feat: made js side overview-comnpatible
Browse files Browse the repository at this point in the history
fixes 42
  • Loading branch information
phu54321 committed Mar 18, 2021
1 parent 849154c commit 342be91
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 0 additions & 2 deletions jssrc/barRender/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ async function updateDOM (svgHtml: string, progressBarMessage: string) {
export async function renderProgressBar () {
const currentRemainingReviews = await getRemainingReviews()
const remainingLoad = reviewLoad(currentRemainingReviews)
if (remainingLoad === 0) return

const estimator = await Estimator.instance()
const renderOptions = {
fixedWidth: !!(await getAddonConfig('fixedSegmentWidth'))
Expand Down
8 changes: 7 additions & 1 deletion jssrc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ async function isQuestionSide (): Promise<boolean> {
}
}

async function isOverview (): Promise<boolean> {
// AnkiDroid
if (isMobile()) return false
else return callPyFunc('isOverview')
}

// eslint-disable-next-line no-inner-declarations
async function main () {
if (await isQuestionSide()) {
if (await isQuestionSide() || await isOverview()) {
await updateEstimator()
}
await renderProgressBar()
Expand Down
8 changes: 6 additions & 2 deletions src/jsapi/isQuestionSide.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@

@JSCallable
def isQuestionSide():
reviewer = mw.reviewer
return reviewer.state == "question"
return mw.state == "review" and mw.reviewer.state == "question"


@JSCallable
def isOverview():
return mw.state == "overview"

0 comments on commit 342be91

Please sign in to comment.