Skip to content

Commit

Permalink
Merge pull request #33 from DSC-best/footer-and-fixes
Browse files Browse the repository at this point in the history
Show error when not logged in instead of showing "login required"
  • Loading branch information
mikaib authored Dec 6, 2023
2 parents 0184377 + 4471e36 commit 77236c4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/lib/components/cards/botCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
padding-bottom: 5px;
}
.bot-info-item:not(:last-child) {
/* .bot-info-item:not(:last-child) {
overflow: hidden;
text-overflow: ellipsis;
padding-bottom: 5px;
}
} */
.bot-tagline {
/* auto line break */
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/footer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Footer at bottom -->
<div class="app-footer-margin"></div>
<footer class="app-footer">
<div class="app-footer-margin"></div>
<div class="footer-content">
<div class="footer-section about">
<p class="copyright-text">
Expand All @@ -23,7 +23,7 @@
margin-top: auto;
}
footer .app-footer-margin {
height: 50px;
.app-footer-margin {
height: 25px;
}
</style>
23 changes: 11 additions & 12 deletions src/routes/bots/[bot_id]/vote/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requireActor from '$lib/server/middleware/requireActor.js';
import prisma from '$lib/server/prisma';
import SafeBot from '$lib/structures/bot';
import { BotApprovalStatus } from '@prisma/client';
Expand All @@ -7,8 +6,6 @@ import { error } from '@sveltejs/kit';
export const _voteTimeout = 1000 * 60 * 60 * 12; // 12 hours

export async function load({ locals, params }) {
await requireActor(locals);

const bot = await prisma.bot.findUnique({
where: {
id: params.bot_id
Expand All @@ -25,15 +22,17 @@ export async function load({ locals, params }) {

if (bot?.approval_status !== BotApprovalStatus.APPROVED) votingDisabled = true;

const latestVote = await prisma.botVote.findFirst({
where: {
bot_id: bot.id,
voter_id: locals.actor!.id
},
orderBy: {
created_time: 'desc'
}
});
let latestVote = locals.actor
? await prisma.botVote.findFirst({
where: {
bot_id: bot.id,
voter_id: locals.actor!.id
},
orderBy: {
created_time: 'desc'
}
})
: null;

if (latestVote) {
if (Date.now() - latestVote.created_time.getTime() < _voteTimeout) {
Expand Down
6 changes: 5 additions & 1 deletion src/routes/bots/[bot_id]/vote/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
errorMessage = 'Voting is currently disabled for this bot.';
}
if(!data?.actor){
errorMessage = 'You must be logged in to vote for a bot.';
}
function onVote() {
loading = true;
Expand Down Expand Up @@ -78,7 +82,7 @@
<!-- Actions -->
<div>
<Button
disabled={!data?.canVote || data?.votingDisabled || loading}
disabled={!data?.canVote || data?.votingDisabled || loading || !data?.actor}
variant="outlined"
color="primary"
on:click={onVote}
Expand Down

0 comments on commit 77236c4

Please sign in to comment.