Skip to content

Commit

Permalink
Merge branch 'dev' into import/export_account
Browse files Browse the repository at this point in the history
  • Loading branch information
stavares843 authored Dec 18, 2024
2 parents d142bb7 + 4347185 commit 4820fe2
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UISupportsDocumentBrowser</key>
<true/>
<key>NSMicrophoneUsageDescription</key>
Expand Down
18 changes: 18 additions & 0 deletions ios/App/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<!-- Add this dict entry to the array if the PrivacyInfo file already exists -->
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
</array>
</dict>
</plist>
5 changes: 4 additions & 1 deletion src/lib/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"request_sent": "You sent a request for {amount}"
},
"friends": {
"copy": "Copy",
"copy_did": "Copy ID",
"block": "Block",
"blocked": "Blocked",
Expand All @@ -170,9 +171,10 @@
"all": "All",
"active": "Active",
"add": "Add",
"add_friend": "Add Friend",
"add_someone": "Add Someone",
"search_friends_placeholder": "Search friends",
"find_placeholder": "Enter Friend ID",
"find_placeholder": "Enter Friend DID",
"incoming_requests": "Incoming Requests",
"outgoing_requests": "Outgoing Requests",
"noOutgoing": "No outbound requests.",
Expand All @@ -189,6 +191,7 @@
"dragging_files": "Dragging {count} files for upload",
"unknown": "UNKNOWN",
"download": "Download",
"shareFileCanceled": "File sharing canceled",
"rename": "Rename",
"share": "Share",
"share.selectChats": "Select Chats",
Expand Down
5 changes: 2 additions & 3 deletions src/lib/wasm/ConstellationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class ConstellationStore {
return regex.test(path)
}

async downloadFile(fileName: string): Promise<Result<WarpError, Blob>> {
async downloadFile(fileName: string): Promise<Result<WarpError, Buffer>> {
const constellation = get(this.constellationWritable)
if (constellation) {
try {
Expand All @@ -308,8 +308,7 @@ class ConstellationStore {
}
} finally {
const combinedArray = Buffer.concat(chunks)
const blob = new Blob([new Uint8Array(combinedArray)], { type: "application/octet-stream" })
return success(blob)
return success(combinedArray)
}
} catch (error) {
return failure(handleErrors(error))
Expand Down
37 changes: 36 additions & 1 deletion src/routes/files/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
import { Store } from "$lib/state/Store"
import path from "path"
import { MultipassStoreInstance } from "$lib/wasm/MultipassStore"
import { Share } from "@capacitor/share"
import { isAndroidOriOS } from "$lib/utils/Mobile"
import { Filesystem, Directory, Encoding } from "@capacitor/filesystem"
import { log } from "$lib/utils/Logger"
export let browseFilesForChatMode: boolean = false
Expand Down Expand Up @@ -456,7 +460,12 @@
err => {
Store.addToastNotification(new ToastMessage("", err, 2))
},
blob => {
async combinedArray => {
if (isAndroidOriOS()) {
await shareFile(fileName, combinedArray)
return
}
const blob = new Blob([new Uint8Array(combinedArray)], { type: "application/octet-stream" })
const url = URL.createObjectURL(blob)
const a = document.createElement("a")
a.href = url
Expand All @@ -469,6 +478,32 @@
)
}
async function shareFile(fileName: string, combinedArray: Buffer) {
try {
const base64Data = combinedArray.toString("base64")
const filePath = await Filesystem.writeFile({
path: fileName,
data: base64Data!,
directory: Directory.Cache,
})
await Share.share({
text: fileName,
url: filePath.uri,
})
log.info(`File shared: ${fileName} successfully`)
} catch (error) {
let errorMessage = `${error}`
log.error("Error when to share file:", fileName, "Error:", errorMessage)
if (errorMessage.includes("Share canceled")) {
Store.addToastNotification(new ToastMessage("", $_("files.shareFileCanceled"), 2))
return
}
}
}
$: chats = UIStore.state.chats
$: activeChat = Store.state.activeChat
Expand Down
6 changes: 4 additions & 2 deletions src/routes/friends/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@
bind:value={requestString}>
<Icon icon={Shape.Search} />
</Input>
<Button hook="button-add-friend" disabled={!isValidFriendDid} appearance={Appearance.Alt} text={$_("friends.add")} on:click={submitRequest}>
</div>
<div class="section" data-cy="friends-section-all-buttons">
<Button hook="button-add-friend" disabled={!isValidFriendDid} appearance={Appearance.Alt} text={$_("friends.add")} tooltip={$_("friends.add_friend")} on:click={submitRequest}>
<Icon icon={Shape.Plus} />
</Button>
<ContextMenu
Expand All @@ -281,7 +283,7 @@
onClick: 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(false)}>
<Button hook="button-copy-id" slot="content" appearance={Appearance.Alt} text={$_("friends.copy")} tooltip={$_("friends.copy_did")} let:open on:contextmenu={open} on:click={async _ => await copy_did(false)}>
<Icon icon={Shape.Clipboard} />
</Button>
</ContextMenu>
Expand Down

0 comments on commit 4820fe2

Please sign in to comment.