Skip to content

Commit

Permalink
chore: Fix syntax errors and add missing semicolons in code files
Browse files Browse the repository at this point in the history
  • Loading branch information
tako0614 committed Jul 11, 2024
1 parent c0e4aae commit 8230a07
Show file tree
Hide file tree
Showing 59 changed files with 966 additions and 894 deletions.
22 changes: 11 additions & 11 deletions components/ChatDate.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const ChatDate = ({ date }: { date: Date }) => {
const currentDate = new Date()
const chatDate = new Date(date)
const currentDate = new Date();
const chatDate = new Date(date);

const isToday = chatDate.getDate() === currentDate.getDate()
const isYesterday = chatDate.getDate() === currentDate.getDate() - 1
const isToday = chatDate.getDate() === currentDate.getDate();
const isYesterday = chatDate.getDate() === currentDate.getDate() - 1;

let formattedDate = ""
let formattedDate = "";
if (isToday) {
formattedDate = "今日"
formattedDate = "今日";
} else if (isYesterday) {
formattedDate = "昨日"
formattedDate = "昨日";
} else {
formattedDate = chatDate.toLocaleDateString()
formattedDate = chatDate.toLocaleDateString();
}

return (
Expand All @@ -20,6 +20,6 @@ const ChatDate = ({ date }: { date: Date }) => {
<p>{formattedDate}</p>
</div>
</li>
)
}
export default ChatDate
);
};
export default ChatDate;
4 changes: 2 additions & 2 deletions components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HeaderButton from "../islands/headerButton.tsx"
import HeaderButton from "../islands/headerButton.tsx";
export default function ChatHeader(props: { state: any }) {
return (
<>
Expand Down Expand Up @@ -112,5 +112,5 @@ export default function ChatHeader(props: { state: any }) {
</ul>
</header>
</>
)
);
}
38 changes: 19 additions & 19 deletions components/OtherMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const ChatOtherMessage = (
{ time, message, sender, senderNickName, isPrimary }: {
time: string
message: string
sender: string
senderNickName: string
isPrimary: boolean
time: string;
message: string;
sender: string;
senderNickName: string;
isPrimary: boolean;
},
) => {
const isPrimaryClass = isPrimary ? "c-talk-chat other primary" : "c-talk-chat other subsequent"
const isPrimaryClass = isPrimary ? "c-talk-chat other primary" : "c-talk-chat other subsequent";

return (
<li class={isPrimaryClass}>
Expand Down Expand Up @@ -40,27 +40,27 @@ const ChatOtherMessage = (
</div>
</div>
</li>
)
}
);
};
//preactで動作する改行を反映させるために、改行コードをbrタグに変換する関数
function convertLineBreak(message: string | null | undefined) {
if (message === null || message === undefined) return
if (message === null || message === undefined) return;
return message.split("\n").map((line, index) => (
<span key={index}>
{line}
<br />
</span>
))
));
}
//Date型のデータを受け取り、午前か午後何時何分かを返す関数
function convertTime(time: string | number | Date) {
const date = new Date(time)
const hours = date.getHours()
const minutes = date.getMinutes()
const ampm = hours >= 12 ? "午後" : "午前"
const hour = hours % 12
const zeroPaddingHour = hour === 0 ? 12 : hour
const zeroPaddingMinutes = String(minutes).padStart(2, "0")
return `${ampm} ${zeroPaddingHour}:${zeroPaddingMinutes}`
const date = new Date(time);
const hours = date.getHours();
const minutes = date.getMinutes();
const ampm = hours >= 12 ? "午後" : "午前";
const hour = hours % 12;
const zeroPaddingHour = hour === 0 ? 12 : hour;
const zeroPaddingMinutes = String(minutes).padStart(2, "0");
return `${ampm} ${zeroPaddingHour}:${zeroPaddingMinutes}`;
}
export default ChatOtherMessage
export default ChatOtherMessage;
38 changes: 19 additions & 19 deletions components/SendMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const ChatSendMessage = ({ isRead, time, message, isPrimary, isSendPrimary }: {
isRead: boolean
time: string
message: string
isPrimary: boolean
isSendPrimary: boolean
isRead: boolean;
time: string;
message: string;
isPrimary: boolean;
isSendPrimary: boolean;
}) => {
const isPrimaryClass = `c-talk-chat self ${isPrimary ? "primary" : "subsequent"}${isSendPrimary ? " mt-2" : ""}`
const isPrimaryClass = `c-talk-chat self ${isPrimary ? "primary" : "subsequent"}${isSendPrimary ? " mt-2" : ""}`;
return (
<li class={isPrimaryClass}>
<div class="c-talk-chat-box">
Expand All @@ -22,26 +22,26 @@ const ChatSendMessage = ({ isRead, time, message, isPrimary, isSendPrimary }: {
</div>
</div>
</li>
)
}
export default ChatSendMessage
);
};
export default ChatSendMessage;
function convertTime(time: string | number | Date) {
const date = new Date(time)
const hours = date.getHours()
const minutes = date.getMinutes()
const ampm = hours >= 12 ? "午後" : "午前"
const hour = hours % 12
const zeroPaddingHour = hour === 0 ? 12 : hour
const zeroPaddingMinutes = String(minutes).padStart(2, "0")
return `${ampm} ${zeroPaddingHour}:${zeroPaddingMinutes}`
const date = new Date(time);
const hours = date.getHours();
const minutes = date.getMinutes();
const ampm = hours >= 12 ? "午後" : "午前";
const hour = hours % 12;
const zeroPaddingHour = hour === 0 ? 12 : hour;
const zeroPaddingMinutes = String(minutes).padStart(2, "0");
return `${ampm} ${zeroPaddingHour}:${zeroPaddingMinutes}`;
}
//preactで動作する改行を反映させるために、改行コードをbrタグに変換する関数
function convertLineBreak(message: string | null | undefined) {
if (message === null || message === undefined) return
if (message === null || message === undefined) return;
return message.split("\n").map((line, index) => (
<span key={index}>
{line}
<br />
</span>
))
));
}
30 changes: 15 additions & 15 deletions components/User.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
export default function User(
{ userName, latestMessage, icon, onClick, userName2, isNewMessage, isSelected }: {
userName: string
latestMessage: string
icon: string
onClick?: () => void
userName2?: string
isNewMessage: boolean
isSelected: boolean
userName: string;
latestMessage: string;
icon: string;
onClick?: () => void;
userName2?: string;
isNewMessage: boolean;
isSelected: boolean;
},
) {
let resultLatestMessage
let resultLatestMessage;
if (latestMessage.length > 17) {
resultLatestMessage = latestMessage.substr(0, 17) + "..."
resultLatestMessage = latestMessage.substr(0, 17) + "...";
} else {
resultLatestMessage = latestMessage
resultLatestMessage = latestMessage;
}

const className = isSelected ? "c-talk-rooms is-active" : "c-talk-rooms"
const className = isSelected ? "c-talk-rooms is-active" : "c-talk-rooms";

return (
<>
Expand Down Expand Up @@ -46,12 +46,12 @@ export default function User(
</a>
</li>
</>
)
);
}

const isOnClickUndefind = (fn: (() => void) | null | undefined) => {
if (fn === undefined || fn === null) {
return () => {}
return () => {};
}
return fn
}
return fn;
};
54 changes: 29 additions & 25 deletions components/chat.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import Header from "../components/header.tsx"
import TalkListHeader from "../islands/talkListHeader.tsx"
import TalkListContent from "../islands/TalkListContent.tsx"
import SetDefaultState from "../islands/setDefaultState.tsx"
import { signal, effect } from "@preact/signals"
import { createContext } from "preact"
import { AppStateType } from "../util/types.ts"
import Main from "./chatmain.tsx"
import Header from "../components/header.tsx";
import TalkListHeader from "../islands/talkListHeader.tsx";
import TalkListContent from "../islands/TalkListContent.tsx";
import SetDefaultState from "../islands/setDefaultState.tsx";
import { effect, signal } from "@preact/signals";
import { createContext } from "preact";
import { AppStateType } from "../util/types.ts";
import Main from "./chatmain.tsx";
function createAppState(obj: {
isChoiceUser: boolean
roomid: string
userName: string
page: number
isChoiceUser: boolean;
roomid: string;
userName: string;
page: number;
}): AppStateType {
const isChoiceUser = signal(obj.isChoiceUser)
const ws = signal(null)
const talkData = signal([])
const roomid = signal(obj.roomid)
const sessionid = signal("")
const friendList = signal([])
const roomName = signal("")
const page = signal(obj.page)
const isChoiceUser = signal(obj.isChoiceUser);
const ws = signal(null);
const talkData = signal([]);
const roomid = signal(obj.roomid);
const sessionid = signal("");
const friendList = signal([]);
const roomName = signal("");
const page = signal(obj.page);
const inputMessage = signal("");
const setIsValidInput = signal(false);
return {
isChoiceUser: isChoiceUser,
ws: ws,
Expand All @@ -30,15 +32,17 @@ function createAppState(obj: {
friendList: friendList,
roomName: roomName,
page: page,
}
inputMessage: inputMessage,
isValidInput: setIsValidInput,
};
}
function chat(props: { page: any; userName: string }) {
const AppState = createAppState({
isChoiceUser: false,
roomid: "",
userName: props.userName,
page: props.page,
})
});
return (
<>
<head>
Expand All @@ -51,7 +55,7 @@ function chat(props: { page: any; userName: string }) {
</head>
<App state={AppState} />
</>
)
);
}
function App({ state }: { state: AppStateType }) {
return (
Expand Down Expand Up @@ -80,6 +84,6 @@ function App({ state }: { state: AppStateType }) {
</main>
</div>
</>
)
);
}
export default chat
export default chat;
16 changes: 8 additions & 8 deletions components/chatmain.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ChatTalkTitle from "../islands/ChatTalkTitle.tsx"
import ChatTalkContent from "../islands/ChatTalkContent.tsx"
import ChatSend from "../islands/ChatSend.tsx"
import ChatTalkTitleContent from "../islands/ChatTalkTitleContent.tsx"
import { AppStateType } from "../util/types.ts"
import ChatTalkTitle from "../islands/ChatTalkTitle.tsx";
import ChatTalkContent from "../islands/ChatTalkContent.tsx";
import ChatSend from "../islands/ChatSend.tsx";
import ChatTalkTitleContent from "../islands/ChatTalkTitleContent.tsx";
import { AppStateType } from "../util/types.ts";
function chatmain({ state }: { state: AppStateType }) {
return (
<>
Expand All @@ -15,9 +15,9 @@ function chatmain({ state }: { state: AppStateType }) {
</div>
<ChatTalkContent state={state} />
</div>
<ChatSend />
<ChatSend state={state} />
</>
)
);
}

export default chatmain
export default chatmain;
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react-dom": "preact/compat"
},
"fmt": {
"semiColons": false,
"semiColons": true,
"exclude": ["fresh.gen.ts", "node_moduls/"],
"indentWidth": 2,
"lineWidth": 200
Expand Down
22 changes: 11 additions & 11 deletions dev.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/

import dev from "$fresh/dev.ts"
import config from "./fresh.config.ts"
import dev from "$fresh/dev.ts";
import config from "./fresh.config.ts";

import "$std/dotenv/load.ts"
import "$std/dotenv/load.ts";
/**connect mongoDB */
import mongoose from "mongoose"
import { load } from "$std/dotenv/mod.ts"
import mongoose from "mongoose";
import { load } from "$std/dotenv/mod.ts";
/**connect mongoDB */
const env = await load()
const url = env["MONGO_URL"]
const env = await load();
const url = env["MONGO_URL"];
await mongoose.connect(url).then(() => {
console.log("mongo DB 接続")
console.log("mongo DB 接続");
}).catch((err) => {
console.log(err)
})
console.log(err);
});

await dev(import.meta.url, "./main.ts", config)
await dev(import.meta.url, "./main.ts", config);
6 changes: 3 additions & 3 deletions fresh.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "$fresh/server.ts"
import { defineConfig } from "$fresh/server.ts";
//import twindPlugin from "$fresh/plugins/twind.ts"
//import twindConfig from "./twind.config.ts";
import tailwind from "$fresh/plugins/tailwind.ts"
import tailwind from "$fresh/plugins/tailwind.ts";
export default defineConfig({
plugins: [tailwind()],
})
});
Loading

0 comments on commit 8230a07

Please sign in to comment.