-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/personalization #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c04805f
メッセージにホバーしたときに色が変わるようにし、右クリックでドロップダウンメニューを出せるようにした
Kanata844 9bf5f78
キャメルケースに修正、snippetを使用した実装に変更
Kanata844 851e623
個人用設定の画面に飛べるようにした(中身はまだ)
Kanata844 9154ed6
アイコン変更ができそうな画面になったけどまだできない
Kanata844 d12a285
アイコンの写真と名前を変えられるようにした
Kanata844 98f08a2
怪しい改行を直した
Kanata844 b0bd850
型を修正
Kanata844 17f81c6
コメント削除
Kanata844 9c3c967
マージできないかためす
Kanata844 fba6133
とりあえずコンフリクトを直して自分が作った機能が使えるようにした
Kanata844 297614c
組織ごとに名前とアイコンを設定できるようにした(つもりだが、組織の追加の仕方が分からないため試せなかった。もしかしたら何か破壊しちゃってい…
Kanata844 afe590a
add市忘れてたみたい?
Kanata844 a9538be
コンフリクト解消できてるといいなー
Kanata844 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,27 +2,32 @@ | |
| import { type Id } from "@packages/convex"; | ||
| import Channel from "./Channel.svelte"; | ||
| import ChannelList from "./ChannelList.svelte"; | ||
| import Personalization from "./Personalization.svelte"; | ||
| let selectedChannelId = $state<Id<"channels"> | undefined>(undefined); | ||
| let screenMode = $state("chat"); | ||
|
||
| </script> | ||
|
|
||
| <div class="bg-base-100 flex h-screen"> | ||
| <ChannelList bind:selectedChannelId /> | ||
|
|
||
| <ChannelList bind:selectedChannelId bind:screenMode /> | ||
| <div class="flex flex-1 flex-col"> | ||
| {#if selectedChannelId} | ||
| <Channel {selectedChannelId} /> | ||
| {:else} | ||
| <div class="bg-base-200 flex flex-1 items-center justify-center"> | ||
| <div class="text-center"> | ||
| <h2 class="text-base-content/60 mb-2 text-2xl font-semibold"> | ||
| チャットアプリへようこそ | ||
| </h2> | ||
| <p class="text-base-content/50"> | ||
| 左からチャンネルを選択して会話を始めましょう | ||
| </p> | ||
| {#if screenMode == "chat"} | ||
| {#if selectedChannelId} | ||
| <Channel {selectedChannelId} /> | ||
| {:else} | ||
| <div class="bg-base-200 flex flex-1 items-center justify-center"> | ||
| <div class="text-center"> | ||
| <h2 class="text-base-content/60 mb-2 text-2xl font-semibold"> | ||
| チャットアプリへようこそ | ||
| </h2> | ||
| <p class="text-base-content/50"> | ||
| 左からチャンネルを選択して会話を始めましょう | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {/if} | ||
| {:else if screenMode == "personalization"} | ||
| <Personalization /> | ||
| {/if} | ||
| </div> | ||
| </div> | ||
16 changes: 16 additions & 0 deletions
16
packages/client/src/components/chat/MessageDropdown.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <script lang="ts"> | ||
| import type { Snippet } from "svelte"; | ||
|
|
||
| const { | ||
| children, | ||
| x, | ||
| y, | ||
| visible, | ||
| }: { children: Snippet; x: number; y: number; visible: boolean } = $props(); | ||
| </script> | ||
|
|
||
| {#if visible} | ||
| <div style={`top: ${y}px; left: ${x}px;}`} class="absolute z-10"> | ||
| {@render children()} | ||
| </div> | ||
| {/if} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
packages/client/src/components/chat/Personalization.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| <script lang="ts"> | ||
| import { api, type Id } from "@packages/convex"; | ||
| import { useConvexClient, useQuery } from "convex-svelte"; | ||
|
|
||
| const convex = useConvexClient(); | ||
|
|
||
| const identity = useQuery(api.users.me, {}); | ||
| const personalization = useQuery(api.personalization.getPersonalization, {}); | ||
| let iconURL = $state<string | null>(""); | ||
| let imageURL = $derived(iconURL || identity.data?.image); | ||
| let userName = $derived( | ||
| personalization.data?.nickname || identity.data?.name, | ||
| ); | ||
| let changedImage = $state<string>(""); | ||
| let changedImageFile = $state<File | undefined>(); | ||
| let changedUserName = $state<string>(""); | ||
|
|
||
| $effect(() => { | ||
| if (userName) { | ||
| changedUserName = userName; | ||
| } | ||
| if (personalization.data) { | ||
| new Promise((resolve) => { | ||
| resolve(personalization.data?.icon); | ||
| }) | ||
| .then((value) => { | ||
| return new Promise((resolve, reject) => { | ||
| const storageId = value as Id<"_storage">; | ||
| if (storageId) { | ||
| resolve( | ||
| convex.mutation(api.personalization.getImageUrl, { | ||
| storageId: storageId, | ||
| }), | ||
| ); | ||
| } else { | ||
| reject(); | ||
| } | ||
| }); | ||
| }) | ||
| .then((value) => { | ||
| const url = value as string; | ||
| iconURL = url; | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| async function save() { | ||
| const image = changedImageFile; | ||
| changedImage = ""; | ||
| changedImageFile = undefined; | ||
| if (changedUserName?.trim() && !(userName === changedUserName)) { | ||
| await convex.mutation(api.personalization.save, { | ||
| name: changedUserName, | ||
| }); | ||
| } | ||
| if (image) { | ||
| const postUrl = await convex.mutation( | ||
| api.personalization.generateUploadUrl, | ||
| {}, | ||
| ); | ||
| const result = await fetch(postUrl, { | ||
| method: "POST", | ||
| headers: { "Content-Type": image.type }, | ||
| body: image, | ||
| }); | ||
|
|
||
| const { storageId } = await result.json(); | ||
|
|
||
| await convex.mutation(api.personalization.saveImage, { | ||
| icon: storageId, | ||
| }); | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <h2 class="py-2 text-center text-lg font-semibold">アイコンの変更</h2> | ||
| <div class="flex justify-around"> | ||
| <div class="w-32 flex-col"> | ||
| <p class="mb-2 text-center">変更前</p> | ||
| <img src={imageURL} alt="googleアイコン" class="w-32" /> | ||
| </div> | ||
| {#if changedImage} | ||
| <div class="w-32 flex-col"> | ||
| <p class="mb-2 text-center">変更後</p> | ||
| <img src={changedImage} alt="変更後" class="w-32" /> | ||
| </div> | ||
| {/if} | ||
| </div> | ||
| <input | ||
| type="file" | ||
| class="file:bg-primary file:text-primary-content | ||
| text-sm | ||
| text-gray-500 file:mr-4 file:ml-2 | ||
| file:rounded file:border-0 | ||
| file:px-4 | ||
| file:py-2 file:font-semibold" | ||
| accept=".jpg, .png" | ||
| onchange={(event) => { | ||
| const input = event.target as HTMLInputElement; | ||
| const file = input.files?.[0]; | ||
| if (file) { | ||
| changedImage = URL.createObjectURL(file); | ||
| changedImageFile = file; | ||
| } | ||
| }} | ||
| /> | ||
| <h2 class="py-2 text-center text-lg font-semibold">名前の変更</h2> | ||
| <div class="flex justify-around"> | ||
| <div> | ||
| <h3 class="text-center text-base">変更前</h3> | ||
| <h4 class="text-lg">{userName}</h4> | ||
| </div> | ||
| <div> | ||
| <h3 class="text-center text-base">変更後</h3> | ||
| <input | ||
| type="text" | ||
| placeholder="ユーザー名" | ||
| class="input input-primary w-full" | ||
| bind:value={changedUserName} | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <button class="btn btn-primary mt-auto mr-2 mb-2 ml-auto w-16" onclick={save}>保存</button> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedChannelId と screenMode は
screenMode = "channel" -> selectedChannelId は必須
screenMode = "personalization" -> selectedChannelId は不要
という関係にあるので、その関連性を反映した型にするといいね