Skip to content

Commit

Permalink
Merge pull request #90 from sheodox/0.19.0-support
Browse files Browse the repository at this point in the history
Support 0.19 auth changes, nsfw edit fix
  • Loading branch information
sheodox authored Dec 17, 2023
2 parents fe82a4b + aae40be commit 2987fd8
Show file tree
Hide file tree
Showing 54 changed files with 405 additions and 435 deletions.
529 changes: 268 additions & 261 deletions package-lock.json

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "Alexandrite",
"version": "0.8.11",
"version": "0.8.12",
"private": true,
"scripts": {
"dev": "vite dev",
"dev": "vite dev --host 0.0.0.0",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
Expand All @@ -17,32 +17,32 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.22.3",
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-container": "^2.0.6",
"@types/markdown-it-footnote": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte": "^2.32.4",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.0",
"sass": "^1.64.1",
"@sveltejs/kit": "^1.27.1",
"@types/markdown-it": "^13.0.5",
"@types/markdown-it-container": "^2.0.8",
"@types/markdown-it-footnote": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.34.0",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"sass": "^1.69.4",
"sheodox-ui": "^0.20.3",
"svelte": "^4.1.1",
"svelte-check": "^3.4.6",
"tslib": "^2.6.1",
"typescript": "^5.1.6",
"vite": "^4.4.7",
"vitest": "^0.33.0"
"svelte": "^4.2.2",
"svelte-check": "^3.5.2",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vitest": "^0.34.6"
},
"type": "module",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.4.0",
"@fortawesome/fontawesome-free": "^6.4.2",
"date-fns": "^2.30.0",
"lemmy-js-client": "^0.18.3-rc.3",
"markdown-it": "^13.0.1",
"lemmy-js-client": "^0.19.0-rc.19",
"markdown-it": "^13.0.2",
"markdown-it-container": "^3.0.0",
"markdown-it-footnote": "^3.0.3",
"markdown-it-ruby": "^0.1.1",
Expand Down
1 change: 0 additions & 1 deletion src/lib/CommunityJoin.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
}
const res = await client.followCommunity({
auth: jwt,
follow: communityView.subscribed === 'NotSubscribed',
community_id: communityView.community.id
});
Expand Down
3 changes: 0 additions & 3 deletions src/lib/CommunitySelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
const { siteMeta } = getAppContext();
$: client = $profile.client;
$: jwt = $profile.jwt;
let searchText = '';
Expand Down Expand Up @@ -90,7 +89,6 @@
}
const res = await client.getCommunity({
auth: jwt,
name: communityName
});
Expand All @@ -102,7 +100,6 @@
}
} else {
const comms = await client.search({
auth: jwt,
type_: 'Communities',
q: searchText,
limit: 50
Expand Down
3 changes: 0 additions & 3 deletions src/lib/InboxReadButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,19 @@
if (content.type === 'reply') {
const res = await client.markCommentReplyAsRead({
auth: jwt,
comment_reply_id: id,
read
});
cvStore.updateView(replyViewToContentView(res.comment_reply_view));
} else if (content.type === 'mention') {
const res = await client.markPersonMentionAsRead({
auth: jwt,
person_mention_id: id,
read
});
cvStore.updateView(mentionViewToContentView(res.person_mention_view));
} else if (content.type === 'message') {
const res = await client.markPrivateMessageAsRead({
auth: jwt,
private_message_id: id,
read
});
Expand Down
1 change: 0 additions & 1 deletion src/lib/MarkdownEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
// busy = true;
// const { selectionStart } = textarea,
// res = await client.uploadImage({
// auth: jwt,
// image: file
// });
// console.log(res);
Expand Down
5 changes: 1 addition & 4 deletions src/lib/PostPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@
}
const res = await client.createComment({
content: body.content as string,
auth: jwt,
post_id: postView.post.id,
language_id: body.languageId ? Number(body.languageId) : undefined
});
Expand Down Expand Up @@ -514,7 +513,6 @@
const { comments, busy, error } = await loadComments(async () => {
const { comments } = await client.getComments({
auth: jwt,
post_id: postView.post.id,
limit: 100,
page: commentsPageNum++,
Expand All @@ -541,7 +539,6 @@
commentExpandLoadingIds = commentExpandLoadingIds;
await loadComments(async () => {
const { comments } = await client.getComments({
auth: jwt,
post_id: postView.post.id,
limit: 100,
parent_id: e.detail,
Expand Down Expand Up @@ -570,7 +567,7 @@
onMount(async () => {
if (jwt) {
// getting the post has a side effect of marking it and its comments as read
const res = await client.getPost({ id: postView.post.id, auth: jwt }).then((res) => {
const res = await client.getPost({ id: postView.post.id }).then((res) => {
res.post_view.read = true;
res.post_view.unread_comments = 0;
return res;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/PrivateMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
return;
}
await client.createPrivateMessageReport({
auth: jwt,
reason: e.detail,
private_message_id: privateMessageView.private_message.id
});
Expand Down Expand Up @@ -154,7 +153,6 @@
}
if (confirm('Are you sure you want to delete this message?')) {
await client.deletePrivateMessage({
auth: jwt,
deleted: true,
private_message_id: privateMessageView.private_message.id
});
Expand Down
2 changes: 0 additions & 2 deletions src/lib/PrivateMessageCompose.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
// if they're editing a message, save the changes, don't send a new one
if (privateMessageView) {
res = await client.editPrivateMessage({
auth: jwt,
content: body.content as string,
private_message_id: privateMessageView.private_message.id
});
Expand All @@ -70,7 +69,6 @@
} else {
//else just create a new message
res = await client.createPrivateMessage({
auth: jwt,
content: body.content as string,
recipient_id: to.id
});
Expand Down
6 changes: 1 addition & 5 deletions src/lib/UserCounts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,24 @@
<Stack dir="r" gap={2} align="center">
<strong>{count.count.toLocaleString()}</strong>
<span class="muted">{count.label}</span>
<strong>{count.score.toLocaleString()}</strong>
<Icon icon="trophy" />
</Stack>
{/each}
</Stack>

<script lang="ts">
import { Stack, Icon } from 'sheodox-ui';
import { Stack } from 'sheodox-ui';
import type { PersonView } from 'lemmy-js-client';
export let personView: PersonView;
$: counts = [
{
label: personView.counts.post_count === 1 ? 'Post' : 'Posts',
score: personView.counts.post_score,
count: personView.counts.post_count,
icon: 'file-lines'
},
{
label: personView.counts.comment_count === 1 ? 'Comment' : 'Comments',
score: personView.counts.comment_score,
count: personView.counts.comment_count,
icon: 'comments'
}
Expand Down
12 changes: 3 additions & 9 deletions src/lib/comments/Comment.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@
let showReportModal = false;
let replyForm: HTMLFormElement;
let editForm: HTMLFormElement;
$: isAdmin = $siteMeta.admins.some(
(admin) => admin.person.actor_id === $siteMeta.my_user?.local_user_view.person.actor_id
);
$: replyState = createStatefulForm(replyForm, replySubmit);
$: editState = createStatefulForm(editForm, editSubmit);
$: voteState = createStatefulAction<number>(async (score) => {
Expand All @@ -318,7 +321,6 @@
}
const res = await client.likeComment({
auth: jwt,
comment_id: comment.id,
score
});
Expand Down Expand Up @@ -378,7 +380,6 @@
const res = await client.createComment({
content: body.content as string,
auth: jwt,
post_id: contentView.view.post.id,
parent_id,
language_id: body.languageId ? Number(body.languageId) : undefined
Expand All @@ -400,7 +401,6 @@
const res = await client.editComment({
content: body.content as string,
auth: jwt,
comment_id: Number(body.commentId),
language_id: body.languageId ? Number(body.languageId) : undefined
});
Expand All @@ -415,7 +415,6 @@
}
const res = await client.deleteComment({
auth: jwt,
comment_id: comment.id,
deleted
});
Expand All @@ -429,7 +428,6 @@
return;
}
const res = await client.saveComment({
auth: jwt,
comment_id: contentView.view.comment.id,
save: !contentView.view.saved
});
Expand All @@ -441,7 +439,6 @@
return;
}
await client.createCommentReport({
auth: jwt,
reason: e.detail,
comment_id: contentView.view.comment.id
});
Expand All @@ -458,7 +455,6 @@
return;
}
await client.blockPerson({
auth: jwt,
person_id: contentView.view.creator.id,
block
});
Expand Down Expand Up @@ -597,8 +593,6 @@
});
}
const isAdmin = $siteMeta.my_user?.local_user_view.person.admin ?? false;
if (isCommunityModerator || isAdmin) {
const warn = isCommunityModerator ? $showModlogWarningModerated : $showModlogWarning,
modlogBase = `/${$profile.instance}/modlog${warn ? '' : '/view'}`;
Expand Down
3 changes: 1 addition & 2 deletions src/lib/community-context/community-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ export const createCommunityContext = () => {

async function loadCommunity(name: string) {
loading.add(name);
const { client, jwt } = get(profile);
const { client } = get(profile);

const res = await client.getCommunity({
auth: jwt,
name
});

Expand Down
5 changes: 1 addition & 4 deletions src/lib/feed-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface FeedDataQuery {
}

export const loadFeedData = async (filters: FeedDataQuery): Promise<ApiFeedLoad> => {
const { client, jwt, settings } = get(profile),
const { client, settings } = get(profile),
page = Number(filters.page ?? '1'),
selectedType = filters.type ?? (filters.username ? 'Overview' : 'Posts'),
selectedListing = filters.listing,
Expand All @@ -55,7 +55,6 @@ export const loadFeedData = async (filters: FeedDataQuery): Promise<ApiFeedLoad>
if (filters.username) {
const userDetails = await client.getPersonDetails({
sort: postQuery.sort,
auth: jwt,
username: filters.username,
limit: 50,
page,
Expand All @@ -72,7 +71,6 @@ export const loadFeedData = async (filters: FeedDataQuery): Promise<ApiFeedLoad>
if (typePosts || typeSaved) {
const postViews = await client
.getPosts({
auth: jwt,
limit: 50,
page,
community_name: filters.communityName ?? undefined,
Expand All @@ -98,7 +96,6 @@ export const loadFeedData = async (filters: FeedDataQuery): Promise<ApiFeedLoad>
query,
commentViews: await client
.getComments({
auth: jwt,
page,
sort: query.sort,
type_: query.listing,
Expand Down
1 change: 0 additions & 1 deletion src/lib/feeds/posts/CommunityHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
return;
}
const res = await client.blockCommunity({
auth: jwt,
community_id: community.id,
block
});
Expand Down
Loading

0 comments on commit 2987fd8

Please sign in to comment.