Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"liveServer.settings.root": "front-end/",
"python.defaultInterpreterPath": "backend/.venv/bin/python"
"python.defaultInterpreterPath": "backend/.venv/bin/python",
"python-envs.defaultEnvManager": "ms-python.python:system"
}
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/.env
/.venv/
/venv/
*.pyc
4 changes: 2 additions & 2 deletions backend/data/blooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Bloom:
def add_bloom(*, sender: User, content: str) -> Bloom:
hashtags = [word[1:] for word in content.split(" ") if word.startswith("#")]

now = datetime.datetime.now(tz=datetime.UTC)
now = datetime.datetime.now(tz=datetime.timezone.utc)
bloom_id = int(now.timestamp() * 1000000)
with db_cursor() as cur:
cur.execute(
Expand All @@ -27,7 +27,7 @@ def add_bloom(*, sender: User, content: str) -> Bloom:
bloom_id=bloom_id,
sender_id=sender.id,
content=content,
timestamp=datetime.datetime.now(datetime.UTC),
timestamp=datetime.datetime.now(datetime.timezone.utc),
),
)
for hashtag in hashtags:
Expand Down
2 changes: 2 additions & 0 deletions front-end/components/login.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ async function handleLogin(event) {
const password = formData.get("password");

await apiService.login(username, password);
//the browser refreshes on that exact same URL
window.location.reload();
} catch (error) {
throw error;
} finally {
Expand Down
1 change: 1 addition & 0 deletions front-end/components/logout.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function createLogout(template, isLoggedIn) {
async function handleLogout(event) {
try {
apiService.logout();
window.location.href = "/";
} catch (error) {
throw error;
}
Expand Down
7 changes: 5 additions & 2 deletions front-end/views/hashtag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ import {createHeading} from "../components/heading.mjs";

// Hashtag view: show all tweets containing this tag

function hashtagView(hashtag) {
async function hashtagView(hashtag) {
destroy();

apiService.getBloomsByHashtag(hashtag);
const normalizedHashtag = hashtag.startsWith("#") ? hashtag : `#${hashtag}`;
if (state.currentHashtag !== normalizedHashtag) {
await apiService.getBloomsByHashtag(hashtag);
}

renderOne(
state.isLoggedIn,
Expand Down