forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Glitch] Converted app/javascript/flavours/glitch/utils/ folder to Ty…
…peScript Port 1142f4c to glitch-soc Signed-off-by: Claire <[email protected]>
- Loading branch information
1 parent
f7bafe8
commit 16014d4
Showing
10 changed files
with
77 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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,13 @@ | ||
import ready from '../ready'; | ||
|
||
export let assetHost = ''; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
ready(() => { | ||
const cdnHost = document.querySelector<HTMLMetaElement>( | ||
'meta[name=cdn-host]', | ||
); | ||
if (cdnHost) { | ||
assetHost = cdnHost.content || ''; | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains 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,9 @@ | ||
// NB: This function can still return unsafe HTML | ||
export const unescapeHTML = (html: string) => { | ||
const wrapper = document.createElement('div'); | ||
wrapper.innerHTML = html | ||
.replace(/<br\s*\/?>/g, '\n') | ||
.replace(/<\/p><p>/g, '\n\n') | ||
.replace(/<[^>]*>/g, ''); | ||
return wrapper.textContent; | ||
}; |
14 changes: 12 additions & 2 deletions
14
...avascript/flavours/glitch/utils/icons.jsx → ...avascript/flavours/glitch/utils/icons.tsx
This file contains 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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
// Copied from emoji-mart for consistency with emoji picker and since | ||
// they don't export the icons in the package | ||
export const loupeIcon = ( | ||
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' width='13' height='13'> | ||
<svg | ||
xmlns='http://www.w3.org/2000/svg' | ||
viewBox='0 0 20 20' | ||
width='13' | ||
height='13' | ||
> | ||
<path d='M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z' /> | ||
</svg> | ||
); | ||
|
||
export const deleteIcon = ( | ||
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' width='13' height='13'> | ||
<svg | ||
xmlns='http://www.w3.org/2000/svg' | ||
viewBox='0 0 20 20' | ||
width='13' | ||
height='13' | ||
> | ||
<path d='M10 8.586L2.929 1.515 1.515 2.929 8.586 10l-7.071 7.071 1.414 1.414L10 11.414l7.071 7.071 1.414-1.414L11.414 10l7.071-7.071-1.414-1.414L10 8.586z' /> | ||
</svg> | ||
); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains 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,13 @@ | ||
/** | ||
* Tries Notification.requestPermission, console warning instead of rejecting on error. | ||
* @param callback Runs with the permission result on completion. | ||
*/ | ||
export const requestNotificationPermission = async ( | ||
callback: NotificationPermissionCallback, | ||
) => { | ||
try { | ||
callback(await Notification.requestPermission()); | ||
} catch (error) { | ||
console.warn(error); | ||
} | ||
}; |
This file contains 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 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