Skip to content

Commit a090758

Browse files
committed
fix minor bugs
1 parent d3c6f8f commit a090758

File tree

8 files changed

+17
-13
lines changed

8 files changed

+17
-13
lines changed

jupyterlab_leetcode/handlers/cookie_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ def get(self):
1717
cookie = get_leetcode_cookie(
1818
browser, self.settings, self.request.headers.get("User-Agent", "")
1919
)
20-
self.set_cookie("leetcode_browser", browser, expires=cookie["expires"])
20+
if not cookie["expired"] and cookie["expires"]:
21+
self.set_cookie("leetcode_browser", browser, expires=cookie["expires"])
2122
self.finish(json.dumps(cookie))
2223
except Exception as e:
2324
self.set_status(400)
24-
self.finish(json.dumps({"message": str(e.args)}))
25+
self.finish(json.dumps({"message": str(e)}))

jupyterlab_leetcode/utils/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ def get_leetcode_cookie(browser: str, settings: dict[str, Any], ua: str):
5555
try:
5656
cj = BROWSER_COOKIE_METHOD_MAP[browser](domain_name="leetcode.com")
5757
except browser_cookie3.BrowserCookieError as e:
58-
raise Exception(
59-
"Failed to retrieve cookies. Maybe not installed the browser?"
60-
) from e
58+
raise Exception("Failed to retrieve cookies. Maybe not installed the browser?")
6159
except Exception as e:
62-
raise Exception(f"An error occurred: {str(e)}") from e
60+
raise Exception(f"An error occurred: {str(e)}")
6361

6462
cookie_session = first(cj, lambda c: c.name == "LEETCODE_SESSION")
6563
cookie_csrf = first(cj, lambda c: c.name == "csrftoken")
@@ -70,7 +68,9 @@ def get_leetcode_cookie(browser: str, settings: dict[str, Any], ua: str):
7068
)
7169
checked = exist and not expired
7270

73-
expires = cast(Cookie, cookie_session).expires
71+
expires = None
72+
if checked:
73+
expires = cast(Cookie, cookie_session).expires
7474

7575
settings.update(
7676
leetcode_headers=HTTPHeaders(

src/components/Actions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const Actions: React.FC<{
5050
{Data.map(item => (
5151
<Tooltip label={item.label} key={item.label}>
5252
<Anchor
53-
size="xs"
53+
size="sm"
5454
target="_blank"
5555
underline="never"
5656
href={item.href}

src/components/BrowserMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ const BrowserMenu: React.FC<{
104104
.then(resp => {
105105
if (!resp['checked']) {
106106
Notification.error(
107-
`Failed to check cookie for ${browser}. Please ensure you are logged in to LeetCode in ${browser}.`,
108-
{ autoClose: 3000 }
107+
`Failed to check cookie for ${browser}. Have you logged in LeetCode in ${browser}?`,
108+
{ autoClose: 5000 }
109109
);
110110
return;
111111
}
@@ -134,7 +134,7 @@ const BrowserMenu: React.FC<{
134134
</Button>
135135
</Menu.Target>
136136
<Menu.Dropdown>
137-
<Menu.Label>With LeetCode logged in</Menu.Label>
137+
<Menu.Label>Where LeetCode logged in:</Menu.Label>
138138
{Browsers.map(({ name, icon }) => (
139139
<Menu.Item
140140
key={name}

src/components/QuestionCompanyFilter.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import classes from '../styles/Filter.module.css';
55

66
const CheckedIcon = <IconCheck size={12} stroke={1.5} />;
77

8+
// TODO: fill data
89
const Data = ['facebook', 'google'];
910

11+
// TODO: show 'wont work if not premium'
1012
const renderMultiSelectOption: MultiSelectProps['renderOption'] = ({
1113
option,
1214
checked

src/components/QuestionTopicFilter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import classes from '../styles/Filter.module.css';
55

66
const CheckedIcon = <IconCheck size={12} stroke={1.5} />;
77

8+
// TODO: fill data
89
const Data = ['array', 'hash-table'];
910

1011
const renderMultiSelectOption: MultiSelectProps['renderOption'] = ({

src/components/SubmissionCalendar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const dates = Array(ShowWeeks * 7 + today.getUTCDay() + 1) // ensure table colum
1313
.map((_, i) => new Date(today.getTime() - i * ADay));
1414
const months = Array.from(
1515
new Map(
16-
dates.map(d => [d.getUTCFullYear() * 100 + d.getMonth(), d])
16+
dates.map(d => [d.getUTCFullYear() * 100 + d.getUTCMonth(), d])
1717
).entries()
1818
).sort(([a], [b]) => a - b);
1919
const monthHead = (

src/widget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class JupyterMainWidget extends ReactWidget {
1919
this.id = 'JupyterlabLeetcodeWidget';
2020
this.addClass('jupyterlab-leetcode-widget');
2121
this.docManager = docManager;
22-
// TODO: fix mantine override body line-height
22+
// FIXME: fix mantine override body line-height
2323
this.theme = createTheme({});
2424
}
2525

0 commit comments

Comments
 (0)