Skip to content

Commit

Permalink
chore: refactor all != to !==
Browse files Browse the repository at this point in the history
  • Loading branch information
OXeu committed Jul 10, 2024
1 parent b14bc5f commit 155df16
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function App() {
client.user.profile.get({
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
setProfile({
id: data.id,
avatar: data.avatar || '',
Expand All @@ -49,7 +49,7 @@ function App() {
setConfig(configWrapper)
} else {
client.config({ type: "client" }).get().then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
sessionStorage.setItem('config', JSON.stringify(data))
const config = new ConfigWrapper(data, defaultClientConfig)
setConfig(config)
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function SearchButton({ className, onClose }: { className?: string, onClose?: ()
setIsOpened(false)
onClose?.()
}, 100)
if (value.length != 0)
if (value.length !== 0)
setLocation(`/search/${key}`)
}
return (<div className={className + " flex flex-row items-center"}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export function Markdown({ content }: { content: string }) {
},
};
})
.filter((slide) => slide.src != "");
.filter((slide) => slide.src !== "");
slides.current = (slidesLocal);
}
const index = slidesLocal?.findIndex((slide) => slide.src === src) ?? -1;
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useTableOfContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const useTableOfContents = (selector: string) => {
)
intersectingList.length = 0 // reset array
headers.forEach((header, i) => {
if (header.getAttribute('data-id') != null) return
if (header.getAttribute('data-id') !== null) return
header.setAttribute('data-id', i.toString()) // set data-id
intersectingList.push(false) // increase array length
io.current!.observe(header) // register to observe
Expand Down
2 changes: 1 addition & 1 deletion client/src/page/feeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function FeedsPage() {
},
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
setFeeds({
...feeds,
[type]: data
Expand Down
8 changes: 4 additions & 4 deletions client/src/page/friends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ export function FriendsPage() {
<meta property="og:type" content="article" />
<meta property="og:url" content={document.URL} />
</Helmet>
<Waiting for={friendsAvailable.length != 0 || friendsUnavailable.length != 0 || status === "idle"}>
<Waiting for={friendsAvailable.length !== 0 || friendsUnavailable.length !== 0 || status === "idle"}>
<main className="w-full flex flex-col justify-center items-center mb-8 t-primary">
<FriendList title={t('friends.title')} show={friendsAvailable.length > 0} friends={friendsAvailable} />
<FriendList title={t('friends.left')} show={friendsUnavailable.length > 0} friends={friendsUnavailable} />
<FriendList title={t('friends.review.waiting')} show={waitList.length > 0} friends={waitList} />
<FriendList title={t('friends.review.rejected')} show={refusedList.length > 0} friends={refusedList} />
<FriendList title={t('friends.my_apply')} show={profile?.permission != true && apply != undefined} friends={apply ? [apply] : []} />
<FriendList title={t('friends.my_apply')} show={profile?.permission !== true && apply !== undefined} friends={apply ? [apply] : []} />
{profile && (profile.permission || config.get("friend_apply_enable")) &&
<div className="wauto t-primary flex text-start text-2xl font-bold mt-8 ani-show">
<div className="md:basis-1/2 bg-w rounded-xl p-4">
Expand Down Expand Up @@ -210,7 +210,7 @@ function Friend({ friend }: { friend: FriendItem }) {
</div>
<p className="text-base text-center">{friend.name}</p>
{friend.health.length == 0 && <p className="text-sm text-neutral-500 text-center">{friend.desc}</p>}
{friend.accepted != 1 && <p className={`${friend.accepted === 0 ? "t-primary" : "text-theme"}`}>{statusOption[friend.accepted + 1].label}</p>}
{friend.accepted !== 1 && <p className={`${friend.accepted === 0 ? "t-primary" : "text-theme"}`}>{statusOption[friend.accepted + 1].label}</p>}
{friend.health.length > 0 && <p className="text-sm text-gray-500 text-center">{errorHumanize(friend.health)}</p>}
{(profile?.permission || profile?.id === friend.uid) && <>
<button onClick={(e) => { e.preventDefault(); setIsOpen(true) }} className="absolute top-0 right-0 m-2 px-2 py-1 bg-secondary t-primary rounded-full bg-active">
Expand Down Expand Up @@ -262,7 +262,7 @@ function Friend({ friend }: { friend: FriendItem }) {
<Select options={statusOption} required defaultValue={statusOption[friend.accepted + 1]}
onChange={(newValue, _) => {
const value = newValue?.value
if (value != undefined) {
if (value !== undefined) {
setStatus(value)
}
}}
Expand Down
2 changes: 1 addition & 1 deletion client/src/page/hashtag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function HashtagPage({ name }: { name: string }) {
client.tag({ name: nameDecoded }).get({
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
setHashtag(data)
setStatus('idle')
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/page/hashtags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function HashtagsPage() {
useEffect(() => {
if (ref.current) return;
client.tag.index.get().then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
setHashtags(data);
}
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/page/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function SearchPage({ keyword }: { keyword: string }) {
},
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
setFeeds(data)
setStatus('idle')
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/page/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function Settings() {
}).get({
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
sessionStorage.setItem('config', JSON.stringify(data));
const config = new ConfigWrapper(data, defaultClientConfig)
setClientConfig(config)
Expand All @@ -46,7 +46,7 @@ export function Settings() {
}).get({
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
const config = new ConfigWrapper(data, defaultServerConfig)
setServerConfig(config)
}
Expand All @@ -66,7 +66,7 @@ export function Settings() {
}, {
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
setMsg(t('settings.import_success$success$skipped', { success: data.success, skipped: data.skipped }))
setMsgList(data.skippedList)
setIsOpen(true);
Expand Down
2 changes: 1 addition & 1 deletion client/src/page/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function TimelinePage() {
client.feed.timeline.get({
headers: headersWithAuth()
}).then(({ data }) => {
if (data && typeof data != 'string') {
if (data && typeof data !== 'string') {
setLength(data.length)
const groups = Object.groupBy(data, ({ createdAt }) => new Date(createdAt).getFullYear())
setFeeds(groups)
Expand Down
6 changes: 3 additions & 3 deletions client/src/page/writing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function publish({
if (error) {
showAlert(error.value as string);
}
if (data && typeof data != "string") {
if (data && typeof data !== "string") {
showAlert(t("publish.success"));
Cache.with().clear();
window.location.href = "/feed/" + data.insertedId;
Expand Down Expand Up @@ -176,7 +176,7 @@ export function WritingPage({ id }: { id?: number }) {
.split("#")
.filter((tag) => tag !== "")
.map((tag) => tag.trim()) || [];
if (id != undefined) {
if (id !== undefined) {
setPublishing(true)
update({
id,
Expand Down Expand Up @@ -451,7 +451,7 @@ export function WritingPage({ id }: { id?: number }) {
</div>
</div>
<div
className={"px-4 h-[600px] overflow-y-scroll " + (preview != 'edit' ? "" : "hidden")}
className={"px-4 h-[600px] overflow-y-scroll " + (preview !== 'edit' ? "" : "hidden")}
>
<Markdown content={content ? content : "> No content now. Write on the left side."} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/state/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ConfigWrapper {
}
get<T>(key: string) {
const value = this.config[key];
if (value != undefined && value !== "") {
if (value !== undefined && value !== "") {
return value as T;
}
if (this.defaultConfig.has(key)) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function fetchPage(url: string) {
const anchors = Array.from(document.querySelectorAll('a'));
return anchors.map(anchor => anchor.href);
});
for (const link of links.filter(link => (link.startsWith(baseUrl) || (containsKey != '' && link.includes(containsKey))))) {
for (const link of links.filter(link => (link.startsWith(baseUrl) || (containsKey !== '' && link.includes(containsKey))))) {
const linkWithoutHash = link.split('#')[0];
if (fetchedLinks.has(linkWithoutHash)) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export function FeedService() {
const feedItems: FeedItem[] = items?.map((item: any) => {
const createdAt = new Date(item?.['wp:post_date']);
const updatedAt = new Date(item?.['wp:post_modified']);
const draft = item?.['wp:status'] != 'publish';
const draft = item?.['wp:status'] !== 'publish';
const contentHtml = item?.['content:encoded'];
const content = html2md(contentHtml);
const summary = content.length > 100 ? content.slice(0, 100) : content;
Expand Down

0 comments on commit 155df16

Please sign in to comment.