Skip to content
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

feat(friends): Allow quick add friend from link #906

Open
wants to merge 25 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a4c0a9c
allow quick add friend from link
Flemmli97 Dec 3, 2024
7cbb8b0
Merge branch 'dev' into add_friend_link
luisecm Dec 3, 2024
730d098
Merge branch 'dev' into add_friend_link
luisecm Dec 3, 2024
cfb2061
add url copy on did button
Flemmli97 Dec 4, 2024
01e74ad
make param optional. solving prerender problem
Flemmli97 Dec 4, 2024
d8a06d5
Merge branch 'dev' into add_friend_link
Flemmli97 Dec 4, 2024
e0ca90b
fix blocked tab
Flemmli97 Dec 4, 2024
04d49b2
Merge branch 'dev' into add_friend_link
Flemmli97 Dec 5, 2024
24e64d4
Merge branch 'dev' into add_friend_link
stavares843 Dec 5, 2024
2f4d66f
Merge branch 'dev' into add_friend_link
phillsatellite Dec 5, 2024
a69c026
Merge branch 'dev' into add_friend_link
stavares843 Dec 5, 2024
c107e74
Merge branch 'dev' into add_friend_link
phillsatellite Dec 6, 2024
c51178b
Merge branch 'dev' into add_friend_link
Flemmli97 Dec 6, 2024
280c04d
Merge branch 'dev' into add_friend_link
Flemmli97 Dec 9, 2024
192afdc
Merge branch 'dev' into add_friend_link
phillsatellite Dec 9, 2024
4eb5fc9
Merge branch 'dev' into add_friend_link
luisecm Dec 12, 2024
f95a5f7
Merge branch 'dev' into add_friend_link
Flemmli97 Dec 13, 2024
2f4200b
Merge branch 'dev' into add_friend_link
luisecm Dec 13, 2024
b73cce7
Merge branch 'dev' into add_friend_link
tooshel Dec 15, 2024
8de0f32
Merge branch 'dev' into add_friend_link
stavares843 Dec 17, 2024
eec8117
Merge branch 'dev' into add_friend_link
luisecm Dec 18, 2024
6727c9d
Merge branch 'dev' into add_friend_link
Flemmli97 Dec 20, 2024
82f45b3
Merge branch 'dev' into add_friend_link
luisecm Dec 30, 2024
a4bb549
Merge branch 'dev' into add_friend_link
stavares843 Dec 31, 2024
d74441d
Merge branch 'dev' into add_friend_link
stavares843 Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add url copy on did button
Flemmli97 committed Dec 4, 2024
commit cfb2061e1e760fb62b6143ae3d5bb1de6fc8869f
1 change: 1 addition & 0 deletions src/lib/lang/en.json
Original file line number Diff line number Diff line change
@@ -348,6 +348,7 @@
"update": "Profile Updated!",
"copy_id": "Copy ID",
"copy_did": "Copy DID",
"copy_did_link": "URL",
"integration": {
"title": "Accounts",
"description": "Share more ways for others to connect and contribute to you. Link your accounts below and they will display on your profile card.",
40 changes: 31 additions & 9 deletions src/routes/friends/+page.svelte
Original file line number Diff line number Diff line change
@@ -22,6 +22,12 @@
import CreateGroup from "$lib/components/group/CreateGroup.svelte"
import AddFriendPopup from "$lib/components/friends/AddFriendPopup.svelte"

enum DIDCopy {
DEFAULT,
SHORT,
LINK,
}

let loading: boolean = false
$: sidebarOpen = UIStore.state.sidebarOpen
$: friends = Store.getUsers(Store.state.friends)
@@ -140,13 +146,22 @@
let activeChat: Chat = get(Store.state.activeChat)
Store.state.activeChat.subscribe(c => (activeChat = c))

async function copy_did(short: boolean) {
async function copy_did(conf: DIDCopy) {
let user = get(Store.state.user)
if (short) {
await navigator.clipboard.writeText(`${user.name}#${user.id.short}`)
} else {
const updatedKey = user.key.replace("did:key:", "")
await navigator.clipboard.writeText(updatedKey)
switch (conf) {
case DIDCopy.DEFAULT: {
const updatedKey = user.key.replace("did:key:", "")
await navigator.clipboard.writeText(updatedKey)
break
}
case DIDCopy.SHORT: {
await navigator.clipboard.writeText(`${user.name}#${user.id.short}`)
break
}
case DIDCopy.LINK: {
const updatedKey = user.key.replace("did:key:", "")
await navigator.clipboard.writeText(`${window.location.origin}/friends/add/${updatedKey}`)
}
}
}

@@ -268,17 +283,24 @@
icon: Shape.Users,
text: $_("settings.profile.copy_id"),
appearance: Appearance.Default,
onClick: async () => await copy_did(true),
onClick: async () => await copy_did(DIDCopy.SHORT),
},
{
id: "copy-did",
icon: Shape.Clipboard,
text: $_("settings.profile.copy_did"),
appearance: Appearance.Default,
onClick: async () => await copy_did(false),
onClick: async () => await copy_did(DIDCopy.DEFAULT),
},
{
id: "copy-link",
icon: Shape.Clipboard,
text: $_("settings.profile.copy_did_link"),
appearance: Appearance.Default,
onClick: async () => await copy_did(DIDCopy.LINK),
},
]}>
<Button hook="button-copy-id" slot="content" appearance={Appearance.Alt} icon tooltip={$_("friends.copy_did")} let:open on:contextmenu={open} on:click={async _ => await copy_did(false)}>
<Button hook="button-copy-id" slot="content" appearance={Appearance.Alt} icon tooltip={$_("friends.copy_did")} let:open on:contextmenu={open} on:click={async _ => await copy_did(DIDCopy.DEFAULT)}>
<Icon icon={Shape.Clipboard} />
</Button>
</ContextMenu>
41 changes: 32 additions & 9 deletions src/routes/settings/profile/+page.svelte
Original file line number Diff line number Diff line change
@@ -30,6 +30,12 @@
Missing,
}

enum DIDCopy {
DEFAULT,
SHORT,
LINK,
}

let loading = true
let isValidUsernameToUpdate = false
let isValidStatusMessageToUpdate = true
@@ -232,12 +238,22 @@
let unsavedChanges: boolean
let profile_update_txt = $_("settings.profile.update")

async function copy_did(short: boolean) {
if (short) {
await navigator.clipboard.writeText(`${userReference.name}#${userReference.id.short}`)
} else {
const updatedKey = userReference.key.replace("did:key:", "")
await navigator.clipboard.writeText(updatedKey)
async function copy_did(conf: DIDCopy) {
let user = get(Store.state.user)
switch (conf) {
case DIDCopy.DEFAULT: {
const updatedKey = userReference.key.replace("did:key:", "")
await navigator.clipboard.writeText(updatedKey)
break
}
case DIDCopy.SHORT: {
await navigator.clipboard.writeText(`${userReference.name}#${userReference.id.short}`)
break
}
case DIDCopy.LINK: {
const updatedKey = user.key.replace("did:key:", "")
await navigator.clipboard.writeText(`${window.location.origin}/friends/add/${updatedKey}`)
}
}
}

@@ -436,17 +452,24 @@
icon: Shape.Users,
text: $_("settings.profile.copy_id"),
appearance: Appearance.Default,
onClick: async () => await copy_did(true),
onClick: async () => await copy_did(DIDCopy.SHORT),
},
{
id: "copy-did",
icon: Shape.Clipboard,
text: $_("settings.profile.copy_did"),
appearance: Appearance.Default,
onClick: async () => await copy_did(false),
onClick: async () => await copy_did(DIDCopy.DEFAULT),
},
{
id: "copy-link",
icon: Shape.Clipboard,
text: $_("settings.profile.copy_did_link"),
appearance: Appearance.Default,
onClick: async () => await copy_did(DIDCopy.LINK),
},
]}>
<div slot="content" class="short-id" role="presentation" let:open on:contextmenu={open} on:click={async _ => await copy_did(false)}>
<div slot="content" class="short-id" role="presentation" let:open on:contextmenu={open} on:click={async _ => await copy_did(DIDCopy.DEFAULT)}>
<Input hook="input-settings-profile-short-id" alt value={$user.id.short} disabled copyOnInteract>
<Icon icon={Shape.Hashtag} alt muted />
</Input>