Skip to content

Commit e95d37d

Browse files
committed
feat: better premium indicator
1 parent 323857e commit e95d37d

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

lua/leetcode-ui/group/similar-questions.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ function SimilarQuestions:init(questions)
3636
button:append(fid .. " ", "leetcode_normal")
3737
button:append(utils.translate(p.title, p.title_cn))
3838

39-
if not config.auth.is_premium and q.paid_only then
40-
button:append((" %s "):format(config.icons.lock) .. t("Premium"), "leetcode_medium")
39+
if q.paid_only then
40+
local txt
41+
42+
if config.auth.is_premium then
43+
txt = " " .. config.icons.unlock
44+
else
45+
txt = (" %s "):format(config.icons.lock) .. t("Premium")
46+
end
47+
48+
button:append(txt, "leetcode_medium")
4149
end
4250

4351
self:insert(button)

lua/leetcode-ui/lines/footer.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Footer:contents()
1515
self:endgrp()
1616

1717
self:append(t("Signed in as") .. ": ", "leetcode_alt")
18+
if config.auth.is_premium then self:append(config.icons.star .. " ", "leetcode_medium") end
1819
self:append(config.auth.name):endl()
1920
end
2021

lua/leetcode-ui/split/description.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function Description:populate()
119119

120120
header:append(q.frontend_id .. ". ", "leetcode_normal")
121121
header:append(utils.translate(q.title, q.translated_title))
122+
if q.is_paid_only then header:append(" " .. t("Premium"), "leetcode_medium") end
122123
header:endgrp()
123124

124125
local show_stats = self.show_stats

lua/leetcode/config/icons.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ local icons = {
33
circle = "",
44
square = "󱓻",
55
lock = "",
6+
unlock = "",
7+
star = "",
68
status = {
79
ac = "",
810
notac = "󱎖",
@@ -17,6 +19,7 @@ icons.hl = {
1719
todo = { icons.status.todo, "leetcode_alt" },
1820
},
1921
lock = { icons.lock, "leetcode_medium" },
22+
unlock = { icons.unlock, "leetcode_medium" },
2023
}
2124

2225
icons.indent = ("\t%s "):format(icons.bar)

lua/leetcode/pickers/question.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ end
3434

3535
---@param question lc.cache.Question
3636
local function display_user_status(question)
37-
if question.paid_only and not config.auth.is_premium then return config.icons.hl.lock end
37+
if question.paid_only then
38+
return config.auth.is_premium and config.icons.hl.unlock or config.icons.hl.lock
39+
end
3840

3941
if question.status == vim.NIL then return { "" } end
4042
return config.icons.hl.status[question.status] or { "" }

0 commit comments

Comments
 (0)