feat: solve conflicts

This commit is contained in:
Fernando Porazzi 2023-09-29 17:15:27 +02:00
commit a0824646eb
No known key found for this signature in database
GPG Key ID: 76A29568782EB818
418 changed files with 19637 additions and 9054 deletions

View File

@ -58,7 +58,7 @@ steps:
- yarn build - yarn build
- yarn test - yarn test
- yarn workspace @snort/app eslint - yarn workspace @snort/app eslint
- yarn workspace @snort/app prettier --check . - yarn prettier --check .
volumes: volumes:
- name: cache - name: cache
claim: claim:
@ -93,7 +93,7 @@ steps:
- yarn install - yarn install
- npx @crowdin/cli upload sources -b main -T $CTOKEN - npx @crowdin/cli upload sources -b main -T $CTOKEN
- npx @crowdin/cli pull -b main -T $CTOKEN - npx @crowdin/cli pull -b main -T $CTOKEN
- yarn workspace @snort/app format - yarn prettier --write .
- git add . - git add .
- 'git commit -a -m "chore: Update translations"' - 'git commit -a -m "chore: Update translations"'
- git push -u origin main - git push -u origin main

View File

@ -44,7 +44,77 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tagName: ${{ github.ref_name }} tagName: ${{ github.ref_name }}
releaseName: "Snort v__VERSION__" app:
releaseBody: "See the assets to download and install this version." runs-on: ubuntu-latest
releaseDraft: true permissions:
prerelease: false contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache gradle
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Install frontend dependencies
run: yarn install
- name: Build Site
run: yarn build
- name: Copy files
run: |-
git clone https://git.v0l.io/Kieran/snort_android.git
mkdir -p snort_android/app/src/main/assets/
cp packages/app/build/* snort_android/app/src/main/assets/
- name: Build AAB
working-directory: snort_android
run: ./gradlew clean bundleRelease --stacktrace
- name: Build APK
working-directory: snort_android
run: ./gradlew assembleRelease --stacktrace
- name: Sign AAB
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: snort_android/app/build/outputs/bundle/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Sign APK
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: snort_android/app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Rename files
run: |-
mkdir -p snort_android/app/release
mv snort_android/app/build/outputs/bundle/release/app-release.aab snort_android/app/release/snort-${{ github.ref_name }}.aab
mv snort_android/app/build/outputs/apk/release/app-universal-release-unsigned-signed.apk snort_android/app/release/snort-universal-${{ github.ref_name }}.apk
mv snort_android/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned-signed.apk snort_android/app/release/snort-arm64-v8a-${{ github.ref_name }}.apk
mv snort_android/app/build/outputs/apk/release/app-x86_64-release-unsigned-signed.apk snort_android/app/release/snort-x86_64-${{ github.ref_name }}.apk
mv snort_android/app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned-signed.apk snort_android/app/release/snort-armeabi-v7a-${{ github.ref_name }}.apk
- name: Upload assets
uses: softprops/action-gh-release@v1
with:
files: |
snort_android/app/release/snort-${{ github.ref_name }}.aab
snort_android/app/release/snort-universal-${{ github.ref_name }}.apk
snort_android/app/release/snort-arm64-v8a-${{ github.ref_name }}.apk
snort_android/app/release/snort-x86_64-${{ github.ref_name }}.apk
snort_android/app/release/snort-armeabi-v7a-${{ github.ref_name }}.apk

View File

@ -3,4 +3,5 @@ build/
.vscode/ .vscode/
.github/ .github/
transifex.yml transifex.yml
dist/ dist/
src-tauri/

View File

@ -1,6 +1,7 @@
{ {
"recommendations": [ "recommendations": [
"arcanis.vscode-zipfs", "arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint" "dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
] ]
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "eslint", "name": "eslint",
"version": "8.44.0-sdk", "version": "8.48.0-sdk",
"main": "./lib/api.js", "main": "./lib/api.js",
"type": "commonjs" "type": "commonjs"
} }

20
.yarn/sdks/prettier/index.js vendored Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier
require(absPnpApiPath).setup();
}
}
// Defer to the real prettier your application uses
module.exports = absRequire(`prettier`);

6
.yarn/sdks/prettier/package.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"name": "prettier",
"version": "3.0.3-sdk",
"main": "./index.js",
"type": "commonjs"
}

View File

@ -1,6 +1,6 @@
{ {
"name": "typescript", "name": "typescript",
"version": "5.1.6-sdk", "version": "5.2.2-sdk",
"main": "./lib/typescript.js", "main": "./lib/typescript.js",
"type": "commonjs" "type": "commonjs"
} }

695
LICENSE
View File

@ -1,674 +1,21 @@
GNU GENERAL PUBLIC LICENSE MIT License
Version 3, 29 June 2007
Copyright (c) 2023 Kieran (v0l)
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Permission is hereby granted, free of charge, to any person obtaining a copy
of this license document, but changing it is not allowed. of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Preamble to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
The GNU General Public License is a free, copyleft license for furnished to do so, subject to the following conditions:
software and other kinds of works.
The above copyright notice and this permission notice shall be included in all
The licenses for most software and other practical works are designed copies or substantial portions of the Software.
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
share and change all versions of a program--to make sure it remains free IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
software for all its users. We, the Free Software Foundation, use the FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
GNU General Public License for most of our software; it applies also to AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
any other work released this way by its authors. You can apply it to LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
your programs, too. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -15,14 +15,12 @@ Snort supports the following NIP's:
- [x] NIP-09: Event Deletion - [x] NIP-09: Event Deletion
- [x] NIP-10: Conventions for clients' use of `e` and `p` tags in text events - [x] NIP-10: Conventions for clients' use of `e` and `p` tags in text events
- [x] NIP-11: Relay Information Document - [x] NIP-11: Relay Information Document
- [x] NIP-12: Generic Tag Queries
- [x] NIP-13: Proof of Work - [x] NIP-13: Proof of Work
- [ ] NIP-14: Subject tag in text events - [ ] NIP-14: Subject tag in text events
- [x] NIP-15: End of Stored Events Notice
- [x] NIP-18: Reposts - [x] NIP-18: Reposts
- [x] NIP-19: bech32-encoded entities - [x] NIP-19: bech32-encoded entities
- [x] NIP-20: Command Results
- [x] NIP-21: `nostr:` Protocol handler (`web+nostr`) - [x] NIP-21: `nostr:` Protocol handler (`web+nostr`)
- [x] NIP-23: Long form content
- [x] NIP-25: Reactions - [x] NIP-25: Reactions
- [x] NIP-26: Delegated Event Signing (Display delegated signings only) - [x] NIP-26: Delegated Event Signing (Display delegated signings only)
- [x] NIP-27: Text note references - [x] NIP-27: Text note references
@ -30,6 +28,8 @@ Snort supports the following NIP's:
- [x] NIP-30: Custom Emoji - [x] NIP-30: Custom Emoji
- [x] NIP-31: Alt tag for unknown events - [x] NIP-31: Alt tag for unknown events
- [x] NIP-36: Sensitive Content - [x] NIP-36: Sensitive Content
- [x] NIP-38: User Statuses
- [ ] NIP-39: External Identities
- [ ] NIP-40: Expiration Timestamp - [ ] NIP-40: Expiration Timestamp
- [x] NIP-42: Authentication of clients to relays - [x] NIP-42: Authentication of clients to relays
- [x] NIP-44: Versioned encryption - [x] NIP-44: Versioned encryption
@ -38,11 +38,14 @@ Snort supports the following NIP's:
- [x] NIP-50: Search - [x] NIP-50: Search
- [x] NIP-51: Lists - [x] NIP-51: Lists
- [x] NIP-53: Live Events - [x] NIP-53: Live Events
- [x] NIP-57: Zaps
- [x] NIP-58: Badges - [x] NIP-58: Badges
- [x] NIP-59: Gift Wrap - [x] NIP-59: Gift Wrap
- [x] NIP-65: Relay List Metadata - [x] NIP-65: Relay List Metadata
- [x] NIP-75: Zap Goals
- [ ] NIP-78: App specific data - [ ] NIP-78: App specific data
- [x] NIP-94: File header - [ ] NIP-89: App handlers
- [x] NIP-94: File Metadata
- [x] NIP-98: HTTP Auth - [x] NIP-98: HTTP Auth
### Running ### Running

View File

@ -6,12 +6,8 @@
"scripts": { "scripts": {
"build": "yarn workspace @snort/shared build && yarn workspace @snort/system build && yarn workspace @snort/system-react build && yarn workspace @snort/app build", "build": "yarn workspace @snort/shared build && yarn workspace @snort/system build && yarn workspace @snort/system-react build && yarn workspace @snort/app build",
"start": "yarn workspace @snort/shared build && yarn workspace @snort/system build && yarn workspace @snort/system-react build && yarn workspace @snort/app start", "start": "yarn workspace @snort/shared build && yarn workspace @snort/system build && yarn workspace @snort/system-react build && yarn workspace @snort/app start",
"test": "yarn workspace @snort/shared build && yarn workspace @snort/system build && yarn workspace @snort/app test && yarn workspace @snort/system test" "test": "yarn workspace @snort/shared build && yarn workspace @snort/system build && yarn workspace @snort/app test && yarn workspace @snort/system test",
}, "pre:commit": "yarn workspace @snort/app intl-extract && yarn workspace @snort/app intl-compile && yarn prettier --write ."
"devDependencies": {
"@cloudflare/workers-types": "^4.20230307.0",
"@tauri-apps/cli": "^1.2.3",
"prettier": "^3.0.0"
}, },
"prettier": { "prettier": {
"printWidth": 120, "printWidth": 120,
@ -20,7 +16,10 @@
}, },
"packageManager": "yarn@3.6.3", "packageManager": "yarn@3.6.3",
"dependencies": { "dependencies": {
"@cloudflare/workers-types": "^4.20230307.0",
"@tauri-apps/cli": "^1.2.3",
"eslint": "^8.48.0", "eslint": "^8.48.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2" "typescript": "^5.2.2"
} }
} }

View File

@ -1,2 +1,2 @@
/* /*
Content-Security-Policy: default-src 'self'; manifest-src *; child-src 'none'; worker-src 'self'; frame-src youtube.com www.youtube.com https://platform.twitter.com https://embed.tidal.com https://w.soundcloud.com https://www.mixcloud.com https://open.spotify.com https://player.twitch.tv https://embed.music.apple.com https://nostrnests.com https://embed.wavlake.com; style-src 'self' 'unsafe-inline'; connect-src *; img-src * data: blob:; font-src 'self'; media-src * blob:; script-src 'self' 'wasm-unsafe-eval' https://static.cloudflareinsights.com https://platform.twitter.com https://embed.tidal.com; Content-Security-Policy: default-src 'self'; manifest-src *; child-src 'none'; worker-src 'self'; frame-src youtube.com www.youtube.com https://platform.twitter.com https://embed.tidal.com https://w.soundcloud.com https://www.mixcloud.com https://open.spotify.com https://player.twitch.tv https://embed.music.apple.com https://nostrnests.com https://embed.wavlake.com; style-src 'self' 'unsafe-inline'; connect-src *; img-src * data: blob:; font-src 'self'; media-src * blob:; script-src 'self' 'wasm-unsafe-eval' https://analytics.v0l.io https://platform.twitter.com https://embed.tidal.com;

View File

@ -0,0 +1 @@
Choose config with NODE_CONFIG_ENV: `NODE_CONFIG_ENV=iris yarn start`

View File

@ -0,0 +1,7 @@
{
"appName": "Snort",
"appNameCapitalized": "Snort",
"appTitle": "Snort - Nostr",
"nip05Domain": "snort.social",
"favicon": "public/favicon.ico"
}

View File

@ -0,0 +1,7 @@
{
"appName": "iris",
"appNameCapitalized": "Iris",
"appTitle": "iris",
"nip05Domain": "iris.to",
"favicon": "public/iris.ico"
}

View File

@ -6,14 +6,15 @@
"@lightninglabs/lnc-web": "^0.2.3-alpha", "@lightninglabs/lnc-web": "^0.2.3-alpha",
"@noble/curves": "^1.0.0", "@noble/curves": "^1.0.0",
"@noble/hashes": "^1.2.0", "@noble/hashes": "^1.2.0",
"@reduxjs/toolkit": "^1.9.1",
"@scure/base": "^1.1.1", "@scure/base": "^1.1.1",
"@scure/bip32": "^1.3.0", "@scure/bip32": "^1.3.0",
"@scure/bip39": "^1.1.1", "@scure/bip39": "^1.1.1",
"@snort/shared": "workspace:*", "@snort/shared": "workspace:*",
"@snort/system": "workspace:*", "@snort/system": "workspace:*",
"@snort/system-react": "workspace:*", "@snort/system-react": "workspace:*",
"@snort/system-wasm": "workspace:*",
"@szhsin/react-menu": "^3.3.1", "@szhsin/react-menu": "^3.3.1",
"@types/use-sync-external-store": "^0.0.4",
"@void-cat/api": "^1.0.4", "@void-cat/api": "^1.0.4",
"debug": "^4.3.4", "debug": "^4.3.4",
"dexie": "^3.2.4", "dexie": "^3.2.4",
@ -26,11 +27,11 @@
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-intersection-observer": "^9.4.1", "react-intersection-observer": "^9.4.1",
"react-intl": "^6.4.4", "react-intl": "^6.4.4",
"react-redux": "^8.0.5",
"react-router-dom": "^6.5.0", "react-router-dom": "^6.5.0",
"react-textarea-autosize": "^8.4.0", "react-textarea-autosize": "^8.4.0",
"react-twitter-embed": "^4.0.4", "react-twitter-embed": "^4.0.4",
"use-long-press": "^2.0.3", "use-long-press": "^2.0.3",
"use-sync-external-store": "^1.2.0",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"workbox-core": "^6.4.2", "workbox-core": "^6.4.2",
"workbox-precaching": "^7.0.0", "workbox-precaching": "^7.0.0",
@ -43,9 +44,7 @@
"test": "jest --runInBand", "test": "jest --runInBand",
"intl-extract": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --out-file src/lang.json --flatten true", "intl-extract": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --out-file src/lang.json --flatten true",
"intl-compile": "formatjs compile src/lang.json --out-file src/translations/en.json", "intl-compile": "formatjs compile src/lang.json --out-file src/translations/en.json",
"format": "prettier --write .", "eslint": "eslint ."
"eslint": "eslint .",
"prepare": "cd ../.. && husky install"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
@ -89,6 +88,7 @@
"@webpack-cli/generators": "^3.0.4", "@webpack-cli/generators": "^3.0.4",
"@webscopeio/react-textarea-autocomplete": "^4.9.2", "@webscopeio/react-textarea-autocomplete": "^4.9.2",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"config": "^3.3.9",
"copy-webpack-plugin": "^11.0.0", "copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3", "css-loader": "^6.7.3",
"css-minimizer-webpack-plugin": "^5.0.0", "css-minimizer-webpack-plugin": "^5.0.0",
@ -102,6 +102,7 @@
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"source-map-loader": "^4.0.1", "source-map-loader": "^4.0.1",
"terser-webpack-plugin": "^5.3.9", "terser-webpack-plugin": "^5.3.9",
"tinybench": "^2.5.0",
"ts-jest": "^29.1.0", "ts-jest": "^29.1.0",
"ts-loader": "^9.4.4", "ts-loader": "^9.4.4",
"typescript": "^5.2.2", "typescript": "^5.2.2",
@ -110,8 +111,5 @@
"webpack-cli": "^5.1.4", "webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1", "webpack-dev-server": "^4.15.1",
"workbox-webpack-plugin": "^6.5.4" "workbox-webpack-plugin": "^6.5.4"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,css,md}": "prettier --write"
} }
} }

View File

@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Snort Benchmarks</title>
</head>
<body>
Check console
</body>
</html>

View File

@ -176,7 +176,7 @@
<path d="M22.1328 5.76872C22.3174 5.64092 22.4097 5.57702 22.4664 5.47424C22.5104 5.39443 22.5356 5.26804 22.5255 5.17745C22.5125 5.06079 22.463 4.98377 22.3638 4.82973C21.9839 4.23964 21.4373 3.75256 20.816 3.43598C20.3306 3.18868 19.8139 3.09012 19.2518 3.04419C18.7106 2.99998 18.0463 2.99999 17.2413 3H6.7587C5.95374 2.99999 5.28937 2.99998 4.74818 3.04419C4.18608 3.09012 3.66937 3.18868 3.18404 3.43598C2.62501 3.72082 2.1418 4.1326 1.77436 4.63335C1.65877 4.79089 1.60097 4.86966 1.58192 4.98921C1.56703 5.08269 1.58783 5.21257 1.63116 5.29674C1.68657 5.40436 1.78269 5.47302 1.97493 5.61033L10.75 11.8783C11.4773 12.3977 11.6316 12.4881 11.7681 12.5233C11.9272 12.5644 12.0939 12.5656 12.2535 12.5269C12.3906 12.4937 12.5463 12.4056 13.281 11.8969L22.1328 5.76872Z" fill="currentColor"/> <path d="M22.1328 5.76872C22.3174 5.64092 22.4097 5.57702 22.4664 5.47424C22.5104 5.39443 22.5356 5.26804 22.5255 5.17745C22.5125 5.06079 22.463 4.98377 22.3638 4.82973C21.9839 4.23964 21.4373 3.75256 20.816 3.43598C20.3306 3.18868 19.8139 3.09012 19.2518 3.04419C18.7106 2.99998 18.0463 2.99999 17.2413 3H6.7587C5.95374 2.99999 5.28937 2.99998 4.74818 3.04419C4.18608 3.09012 3.66937 3.18868 3.18404 3.43598C2.62501 3.72082 2.1418 4.1326 1.77436 4.63335C1.65877 4.79089 1.60097 4.86966 1.58192 4.98921C1.56703 5.08269 1.58783 5.21257 1.63116 5.29674C1.68657 5.40436 1.78269 5.47302 1.97493 5.61033L10.75 11.8783C11.4773 12.3977 11.6316 12.4881 11.7681 12.5233C11.9272 12.5644 12.0939 12.5656 12.2535 12.5269C12.3906 12.4937 12.5463 12.4056 13.281 11.8969L22.1328 5.76872Z" fill="currentColor"/>
</g> </g>
</symbol> </symbol>
<symbol id="bell-v2" viewBox="0 0 24 24" fill="none"> <symbol id="bell-02" viewBox="0 0 24 24" fill="none">
<g> <g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.99974 21C8.99974 20.4477 9.44745 20 9.99974 20H13.9997C14.552 20 14.9997 20.4477 14.9997 21C14.9997 21.5523 14.552 22 13.9997 22H9.99974C9.44745 22 8.99974 21.5523 8.99974 21Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.99974 21C8.99974 20.4477 9.44745 20 9.99974 20H13.9997C14.552 20 14.9997 20.4477 14.9997 21C14.9997 21.5523 14.552 22 13.9997 22H9.99974C9.44745 22 8.99974 21.5523 8.99974 21Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.04999 3.05025C8.36275 1.7375 10.1432 1 11.9997 1C13.8563 1 15.6367 1.7375 16.9495 3.05025C18.2622 4.36301 18.9997 6.14349 18.9997 8C18.9997 10.9127 19.7317 12.8439 20.4991 14.0771L20.511 14.0962C20.8683 14.6704 21.1507 15.1243 21.3411 15.4547C21.4366 15.6202 21.5235 15.7797 21.5879 15.9215C21.62 15.9922 21.6559 16.079 21.684 16.1733C21.7073 16.2515 21.7517 16.4187 21.7351 16.6223C21.7239 16.7591 21.696 16.9928 21.5618 17.2343C21.4277 17.4758 21.244 17.623 21.1337 17.7047C20.8834 17.8904 20.596 17.9329 20.5001 17.947L20.4957 17.9477C20.3482 17.9695 20.181 17.9804 20.0122 17.9869C19.677 18 19.2128 18 18.6356 18H5.36388C4.78666 18 4.32252 18 3.98726 17.9869C3.81851 17.9804 3.65123 17.9695 3.50382 17.9477L3.49939 17.947C3.40347 17.9329 3.11604 17.8904 2.86574 17.7047C2.7555 17.623 2.57178 17.4758 2.43762 17.2343C2.30347 16.9928 2.27558 16.7591 2.26439 16.6223C2.24774 16.4187 2.29214 16.2515 2.31545 16.1733C2.34354 16.079 2.37948 15.9922 2.41161 15.9215C2.47598 15.7797 2.56291 15.6202 2.65833 15.4547C2.84876 15.1243 3.13124 14.6703 3.48856 14.0961L3.50035 14.0771C4.26773 12.8439 4.99974 10.9127 4.99974 8C4.99974 6.14348 5.73724 4.36301 7.04999 3.05025Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.04999 3.05025C8.36275 1.7375 10.1432 1 11.9997 1C13.8563 1 15.6367 1.7375 16.9495 3.05025C18.2622 4.36301 18.9997 6.14349 18.9997 8C18.9997 10.9127 19.7317 12.8439 20.4991 14.0771L20.511 14.0962C20.8683 14.6704 21.1507 15.1243 21.3411 15.4547C21.4366 15.6202 21.5235 15.7797 21.5879 15.9215C21.62 15.9922 21.6559 16.079 21.684 16.1733C21.7073 16.2515 21.7517 16.4187 21.7351 16.6223C21.7239 16.7591 21.696 16.9928 21.5618 17.2343C21.4277 17.4758 21.244 17.623 21.1337 17.7047C20.8834 17.8904 20.596 17.9329 20.5001 17.947L20.4957 17.9477C20.3482 17.9695 20.181 17.9804 20.0122 17.9869C19.677 18 19.2128 18 18.6356 18H5.36388C4.78666 18 4.32252 18 3.98726 17.9869C3.81851 17.9804 3.65123 17.9695 3.50382 17.9477L3.49939 17.947C3.40347 17.9329 3.11604 17.8904 2.86574 17.7047C2.7555 17.623 2.57178 17.4758 2.43762 17.2343C2.30347 16.9928 2.27558 16.7591 2.26439 16.6223C2.24774 16.4187 2.29214 16.2515 2.31545 16.1733C2.34354 16.079 2.37948 15.9922 2.41161 15.9215C2.47598 15.7797 2.56291 15.6202 2.65833 15.4547C2.84876 15.1243 3.13124 14.6703 3.48856 14.0961L3.50035 14.0771C4.26773 12.8439 4.99974 10.9127 4.99974 8C4.99974 6.14348 5.73724 4.36301 7.04999 3.05025Z" fill="currentColor"/>
@ -296,6 +296,52 @@
<path d="M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2Z" fill="currentColor"/> <path d="M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2Z" fill="currentColor"/>
</g> </g>
</symbol> </symbol>
<symbol id="grid-01" viewBox="0 0 24 24" fill="none">
<g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.56811 2C5.85605 2.00016 7.1465 2.00016 8.4319 2C8.68429 1.99997 8.93008 1.99994 9.13824 2.01695C9.36683 2.03563 9.63656 2.07969 9.90799 2.21799C10.2843 2.40974 10.5903 2.7157 10.782 3.09202C10.9203 3.36345 10.9644 3.63318 10.9831 3.86178C11.0001 4.06994 11 4.31574 11 4.56813V8.43189C11 8.68427 11.0001 8.93007 10.9831 9.13824C10.9644 9.36683 10.9203 9.63656 10.782 9.90799C10.5903 10.2843 10.2843 10.5903 9.90799 10.782C9.63656 10.9203 9.36683 10.9644 9.13824 10.9831C8.93007 11.0001 8.68427 11 8.43189 11H4.56812C4.31574 11 4.06994 11.0001 3.86178 10.9831C3.63318 10.9644 3.36345 10.9203 3.09202 10.782C2.7157 10.5903 2.40974 10.2843 2.21799 9.90799C2.07969 9.63656 2.03563 9.36683 2.01695 9.13824C1.99994 8.93008 1.99997 8.68429 2 8.4319C2 8.42128 2.00001 8.41065 2.00001 8.40001V4.60001C2.00001 4.58936 2 4.57873 2 4.56811C1.99997 4.31572 1.99994 4.06993 2.01695 3.86178C2.03563 3.63318 2.07969 3.36345 2.21799 3.09202C2.40974 2.7157 2.7157 2.40974 3.09202 2.21799C3.36345 2.07969 3.63318 2.03563 3.86178 2.01695C4.06993 1.99994 4.31572 1.99997 4.56811 2Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.56811 13C5.85605 13.0002 7.1465 13.0002 8.4319 13C8.68429 13 8.93008 12.9999 9.13824 13.017C9.36683 13.0356 9.63656 13.0797 9.90799 13.218C10.2843 13.4097 10.5903 13.7157 10.782 14.092C10.9203 14.3634 10.9644 14.6332 10.9831 14.8618C11.0001 15.0699 11 15.3157 11 15.5681V19.4319C11 19.6843 11.0001 19.9301 10.9831 20.1382C10.9644 20.3668 10.9203 20.6366 10.782 20.908C10.5903 21.2843 10.2843 21.5903 9.90799 21.782C9.63656 21.9203 9.36683 21.9644 9.13824 21.9831C8.93007 22.0001 8.68427 22 8.43189 22H4.56812C4.31574 22 4.06994 22.0001 3.86178 21.9831C3.63318 21.9644 3.36345 21.9203 3.09202 21.782C2.7157 21.5903 2.40974 21.2843 2.21799 20.908C2.07969 20.6366 2.03563 20.3668 2.01695 20.1382C1.99994 19.9301 1.99997 19.6843 2 19.4319C2 19.4213 2.00001 19.4106 2.00001 19.4V15.6C2.00001 15.5894 2 15.5787 2 15.5681C1.99997 15.3157 1.99994 15.0699 2.01695 14.8618C2.03563 14.6332 2.07969 14.3634 2.21799 14.092C2.40974 13.7157 2.7157 13.4097 3.09202 13.218C3.36345 13.0797 3.63318 13.0356 3.86178 13.017C4.06993 12.9999 4.31572 13 4.56811 13Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.5681 2C16.856 2.00016 18.1465 2.00016 19.4319 2C19.6843 1.99997 19.9301 1.99994 20.1382 2.01695C20.3668 2.03563 20.6366 2.07969 20.908 2.21799C21.2843 2.40974 21.5903 2.7157 21.782 3.09202C21.9203 3.36345 21.9644 3.63318 21.9831 3.86178C22.0001 4.06994 22 4.31574 22 4.56813V8.43189C22 8.68427 22.0001 8.93007 21.9831 9.13824C21.9644 9.36683 21.9203 9.63656 21.782 9.90799C21.5903 10.2843 21.2843 10.5903 20.908 10.782C20.6366 10.9203 20.3668 10.9644 20.1382 10.9831C19.9301 11.0001 19.6843 11 19.4319 11H15.5681C15.3157 11 15.0699 11.0001 14.8618 10.9831C14.6332 10.9644 14.3634 10.9203 14.092 10.782C13.7157 10.5903 13.4097 10.2843 13.218 9.90799C13.0797 9.63656 13.0356 9.36683 13.017 9.13824C12.9999 8.93008 13 8.68429 13 8.4319C13 8.42128 13 8.41065 13 8.40001V4.60001C13 4.58936 13 4.57873 13 4.56811C13 4.31572 12.9999 4.06993 13.017 3.86178C13.0356 3.63318 13.0797 3.36345 13.218 3.09202C13.4097 2.7157 13.7157 2.40974 14.092 2.21799C14.3634 2.07969 14.6332 2.03563 14.8618 2.01695C15.0699 1.99994 15.3157 1.99997 15.5681 2Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.5681 13C16.856 13.0002 18.1465 13.0002 19.4319 13C19.6843 13 19.9301 12.9999 20.1382 13.017C20.3668 13.0356 20.6366 13.0797 20.908 13.218C21.2843 13.4097 21.5903 13.7157 21.782 14.092C21.9203 14.3634 21.9644 14.6332 21.9831 14.8618C22.0001 15.0699 22 15.3157 22 15.5681V19.4319C22 19.6843 22.0001 19.9301 21.9831 20.1382C21.9644 20.3668 21.9203 20.6366 21.782 20.908C21.5903 21.2843 21.2843 21.5903 20.908 21.782C20.6366 21.9203 20.3668 21.9644 20.1382 21.9831C19.9301 22.0001 19.6843 22 19.4319 22H15.5681C15.3157 22 15.0699 22.0001 14.8618 21.9831C14.6332 21.9644 14.3634 21.9203 14.092 21.782C13.7157 21.5903 13.4097 21.2843 13.218 20.908C13.0797 20.6366 13.0356 20.3668 13.017 20.1382C12.9999 19.9301 13 19.6843 13 19.4319C13 19.4213 13 19.4106 13 19.4V15.6C13 15.5894 13 15.5787 13 15.5681C13 15.3157 12.9999 15.0699 13.017 14.8618C13.0356 14.6332 13.0797 14.3634 13.218 14.092C13.4097 13.7157 13.7157 13.4097 14.092 13.218C14.3634 13.0797 14.6332 13.0356 14.8618 13.017C15.0699 12.9999 15.3157 13 15.5681 13Z" fill="currentColor"/>
</g>
</symbol>
<symbol id="settings-02" viewBox="0 0 24 24" fill="none">
<g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.74225 21.5541L9.08973 20.1082C8.85724 19.5922 8.4646 19.1621 7.9683 18.8799C7.47171 18.5977 6.89723 18.4774 6.32708 18.5364L4.73053 18.7039C4.25532 18.7531 3.77581 18.6656 3.35002 18.4519C2.92423 18.2383 2.57041 17.9076 2.33135 17.5C2.09223 17.0924 1.97831 16.6252 2.00341 16.1551C2.02851 15.6849 2.19156 15.2321 2.47277 14.8514L3.41805 13.5718C3.75516 13.115 3.9367 12.5648 3.93659 12C3.9367 11.4352 3.75516 10.885 3.41805 10.4282L2.47277 9.14855C2.19156 8.76793 2.02851 8.31508 2.00341 7.84494C1.97831 7.3748 2.09223 6.90759 2.33135 6.5C2.57017 6.09216 2.92395 5.76134 3.3498 5.54765C3.77565 5.33396 4.25528 5.24658 4.73053 5.29611L6.33205 5.46356C6.90219 5.52255 7.47667 5.40233 7.97326 5.12011C8.46771 4.83708 8.85854 4.40709 9.08973 3.89178L9.74225 2.44589C9.93622 2.01549 10.2528 1.64979 10.6535 1.39314C11.0543 1.13649 11.522 0.999923 12 1C12.478 0.999923 12.9457 1.13649 13.3465 1.39314C13.7472 1.64979 14.0638 2.01549 14.2578 2.44589L14.9152 3.89178C15.1464 4.40709 15.5372 4.83708 16.0317 5.12011C16.5283 5.40233 17.1028 5.52255 17.6729 5.46356L19.2695 5.29611C19.7447 5.24658 20.2243 5.33396 20.6502 5.54765C21.076 5.76134 21.4298 6.09216 21.6686 6.5C21.9078 6.90759 22.0217 7.3748 21.9966 7.84494C21.9715 8.31508 21.8084 8.76793 21.5272 9.14855L20.5819 10.4282C20.2448 10.885 20.0633 11.4352 20.0634 12C20.0605 12.5663 20.2404 13.1188 20.577 13.5779L21.5223 14.8576C21.8035 15.2382 21.9665 15.691 21.9916 16.1612C22.0167 16.6313 21.9028 17.0985 21.6637 17.5061C21.4249 17.914 21.0711 18.2448 20.6452 18.4585C20.2194 18.6722 19.7398 18.7595 19.2645 18.71L17.668 18.5426C17.0978 18.4836 16.5233 18.6038 16.0267 18.886C15.5333 19.1674 15.1425 19.5952 14.9103 20.1082L14.2578 21.5541C14.0638 21.9845 13.7472 22.3502 13.3465 22.6069C12.9457 22.8635 12.478 23.0001 12 23C11.522 23.0001 11.0543 22.8635 10.6535 22.6069C10.2528 22.3502 9.93622 21.9845 9.74225 21.5541ZM15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z" fill="currentColor"/>
</g>
</symbol>
<symbol id="rows-01" viewBox="0 0 24 24" fill="none">
<g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22 17.1615V17.8385C22 18.3657 22 18.8205 21.9694 19.195C21.9371 19.5904 21.8658 19.9836 21.673 20.362C21.3854 20.9265 20.9265 21.3854 20.362 21.673C19.9836 21.8658 19.5904 21.9371 19.195 21.9694C18.8205 22 18.3657 22 17.8385 22H6.16148C5.63432 22 5.17955 22 4.80497 21.9694C4.40963 21.9371 4.01641 21.8658 3.63803 21.673C3.07354 21.3854 2.6146 20.9265 2.32698 20.362C2.13419 19.9836 2.06287 19.5904 2.03057 19.195C1.99997 18.8205 1.99998 18.3657 2 17.8386L2 17.1614C1.99998 16.6343 1.99997 16.1795 2.03057 15.805C2.06287 15.4096 2.13419 15.0164 2.32698 14.638C2.6146 14.0735 3.07354 13.6146 3.63803 13.327C4.01641 13.1342 4.40963 13.0629 4.80497 13.0306C5.17955 13 5.63431 13 6.16146 13L17.8385 13C18.3657 13 18.8205 13 19.195 13.0306C19.5904 13.0629 19.9836 13.1342 20.362 13.327C20.9265 13.6146 21.3854 14.0735 21.673 14.638C21.8658 15.0164 21.9371 15.4096 21.9694 15.805C22 16.1795 22 16.6343 22 17.1615Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22 6.16146V6.83855C22 7.36569 22 7.82046 21.9694 8.19503C21.9371 8.59038 21.8658 8.98359 21.673 9.36197C21.3854 9.92646 20.9265 10.3854 20.362 10.673C19.9836 10.8658 19.5904 10.9371 19.195 10.9694C18.8205 11 18.3657 11 17.8385 11L6.16148 11C5.63432 11 5.17955 11 4.80497 10.9694C4.40963 10.9371 4.01641 10.8658 3.63803 10.673C3.07354 10.3854 2.6146 9.92646 2.32698 9.36197C2.13419 8.98359 2.06287 8.59037 2.03057 8.19503C1.99997 7.82046 1.99998 7.36571 2 6.83857L2 6.16144C1.99998 5.6343 1.99997 5.17954 2.03057 4.80497C2.06287 4.40963 2.13419 4.01641 2.32698 3.63803C2.6146 3.07354 3.07354 2.6146 3.63803 2.32698C4.01641 2.13419 4.40963 2.06287 4.80497 2.03057C5.17955 1.99997 5.63431 1.99998 6.16146 2L17.8385 2C18.3657 1.99998 18.8205 1.99997 19.195 2.03057C19.5904 2.06287 19.9836 2.13419 20.362 2.32698C20.9265 2.6146 21.3854 3.07354 21.673 3.63803C21.8658 4.01641 21.9371 4.40963 21.9694 4.80497C22 5.17955 22 5.63431 22 6.16146Z" fill="currentColor"/>
</g>
</symbol>
<symbol id="camera-lens" viewBox="0 0 24 24" fill="none">
<g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.7782 4.22183C24.0739 8.5176 24.0739 15.4824 19.7782 19.7782C15.4824 24.0739 8.51757 24.0739 4.22183 19.7782C-0.073941 15.4824 -0.0739439 8.51757 4.22183 4.22183C8.5176 -0.0739412 15.4824 -0.0739441 19.7782 4.22183ZM18.3639 5.63604C16.9457 4.21783 15.172 3.37188 13.3296 3.09818C15.1903 4.84851 16.3469 7.26042 16.5131 9.84459C16.7413 10.3224 16.8892 10.8289 16.957 11.344C18.1231 9.82019 18.7436 7.89858 18.6289 5.91225C18.5429 5.81878 18.4546 5.72668 18.3639 5.63604ZM13.9108 7.37813C13.1743 5.60658 11.8204 4.10837 10.0429 3.21421C8.42788 3.57237 6.89244 4.37965 5.63604 5.63604C5.39169 5.88039 5.16433 6.13529 4.95396 6.39928C7.40123 5.66183 10.0699 5.86592 12.3924 7.01533C12.9104 7.05586 13.4233 7.17679 13.9108 7.37813ZM8.95317 8.03485C7.04977 7.78701 5.07457 8.21117 3.4111 9.30482C2.79889 11.2616 2.87046 13.3861 3.62582 15.3036C4.21048 12.8157 5.72136 10.6067 7.87702 9.16982C8.04787 8.92153 8.24369 8.68524 8.46446 8.46446C8.62007 8.30886 8.78338 8.16566 8.95317 8.03485ZM7.04296 12.656C5.87684 14.1797 5.25622 16.1012 5.37085 18.0874C5.4569 18.181 5.5453 18.2732 5.63604 18.3639C7.05418 19.7821 8.82785 20.628 10.6701 20.9018C8.80942 19.1513 7.65282 16.7393 7.48676 14.1551C7.25866 13.6774 7.11073 13.1709 7.04296 12.656ZM10.089 16.6218C10.8255 18.3934 12.1794 19.8916 13.9569 20.7858C15.572 20.4277 17.1075 19.6204 18.3639 18.3639C18.6084 18.1195 18.8358 17.8646 19.0462 17.6005C16.599 18.338 13.9303 18.134 11.6079 16.9847C11.0897 16.9442 10.5766 16.8232 10.089 16.6218ZM15.047 15.965C15.2167 15.8343 15.38 15.6911 15.5355 15.5355C15.7563 15.3148 15.952 15.0786 16.1228 14.8304C18.2786 13.3934 19.7895 11.1842 20.3741 8.69606C21.1295 10.6136 21.2011 12.7381 20.589 14.6949C18.9255 15.7886 16.9504 16.2128 15.047 15.965Z" fill="currentColor"/>
</g>
</symbol>
<symbol id="file-06" viewBox="0 0 24 24" fill="none">
<g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 2.01558C13 1.98928 13 1.97612 12.9989 1.95227C12.9753 1.4585 12.541 1.02448 12.0473 1.00112C12.0234 0.999992 12.0156 0.999995 12 1H12H8.75866H8.75862C7.95369 0.99999 7.28935 0.999981 6.74818 1.0442C6.18608 1.09012 5.66938 1.18869 5.18404 1.43598C4.43139 1.81947 3.81947 2.43139 3.43598 3.18404C3.18869 3.66938 3.09012 4.18608 3.0442 4.74818C2.99998 5.28936 2.99999 5.95372 3 6.75867V6.75869V17.2413V17.2413C2.99999 18.0463 2.99998 18.7106 3.0442 19.2518C3.09012 19.8139 3.18869 20.3306 3.43598 20.816C3.81947 21.5686 4.43139 22.1805 5.18404 22.564C5.66938 22.8113 6.18608 22.9099 6.74818 22.9558C7.28937 23 7.95372 23 8.75868 23H15.2413C16.0463 23 16.7106 23 17.2518 22.9558C17.8139 22.9099 18.3306 22.8113 18.816 22.564C19.5686 22.1805 20.1805 21.5686 20.564 20.816C20.8113 20.3306 20.9099 19.8139 20.9558 19.2518C21 18.7106 21 18.0463 21 17.2413V9.99994C21 9.98441 21 9.97664 20.9989 9.95282C20.9756 9.45899 20.5415 9.02471 20.0477 9.00115C20.0238 9.00001 20.0107 9.00001 19.9845 9.00001L15.5681 9.00001C15.3157 9.00004 15.0699 9.00007 14.8618 8.98307C14.6332 8.96439 14.3634 8.92032 14.092 8.78202C13.7157 8.59028 13.4097 8.28432 13.218 7.90799C13.0797 7.63657 13.0356 7.36683 13.017 7.13824C12.9999 6.93008 13 6.68429 13 6.43191L13 2.01558ZM18.908 6.99999C19.2016 7 19.3484 7 19.4686 6.92627C19.6385 6.82215 19.74 6.57684 19.6935 6.38313C19.6605 6.24598 19.5648 6.15033 19.3733 5.95904L16.041 2.62672C15.8497 2.43523 15.754 2.33949 15.6169 2.30652C15.4232 2.25996 15.1779 2.3615 15.0737 2.53134C15 2.65161 15 2.79842 15 3.09204L15 6.19996C15 6.47998 15 6.61999 15.0545 6.72694C15.1024 6.82102 15.1789 6.89751 15.273 6.94545C15.38 6.99995 15.52 6.99995 15.8 6.99995L18.908 6.99999ZM8 9C7.44772 9 7 9.44772 7 10C7 10.5523 7.44772 11 8 11H10C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9H8ZM7 14C7 13.4477 7.44772 13 8 13H16C16.5523 13 17 13.4477 17 14C17 14.5523 16.5523 15 16 15H8C7.44772 15 7 14.5523 7 14ZM7 18C7 17.4477 7.44772 17 8 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H8C7.44772 19 7 18.5523 7 18Z" fill="currentColor"/>
</g>
</symbol>
<symbol id="alert-circle" viewBox="0 0 18 19" fill="none">
<g>
<path d="M9 6.5V9.5M9 12.5H9.0075M16.5 9.5C16.5 13.6421 13.1421 17 9 17C4.85786 17 1.5 13.6421 1.5 9.5C1.5 5.35786 4.85786 2 9 2C13.1421 2 16.5 5.35786 16.5 9.5Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</g>
</symbol>
<symbol id="signal-01" viewBox="0 0 24 25" fill="none">
<g>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.5355 7.55101C15.9261 7.16048 16.5592 7.16048 16.9497 7.55101C19.6834 10.2847 19.6834 14.7168 16.9497 17.4505C16.5592 17.841 15.9261 17.841 15.5355 17.4505C15.145 17.06 15.145 16.4268 15.5355 16.0363C17.4882 14.0837 17.4882 10.9178 15.5355 8.96522C15.145 8.5747 15.145 7.94153 15.5355 7.55101Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.46447 7.55097C8.85499 7.9415 8.85499 8.57466 8.46447 8.96519C6.51184 10.9178 6.51184 14.0836 8.46447 16.0363C8.85499 16.4268 8.85499 17.0599 8.46447 17.4505C8.07394 17.841 7.44078 17.841 7.05025 17.4505C4.31658 14.7168 4.31658 10.2846 7.05025 7.55097C7.44078 7.16045 8.07394 7.16045 8.46447 7.55097Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.63604 4.72258C6.02656 5.11311 6.02656 5.74627 5.63604 6.13679C2.12132 9.65151 2.12132 15.35 5.63604 18.8647C6.02656 19.2552 6.02656 19.8884 5.63604 20.2789C5.24551 20.6695 4.61235 20.6695 4.22183 20.2789C-0.0739419 15.9832 -0.0739419 9.01835 4.22183 4.72258C4.61235 4.33206 5.24551 4.33206 5.63604 4.72258Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.364 4.72263C18.7545 4.3321 19.3877 4.3321 19.7782 4.72263C24.0739 9.01839 24.0739 15.9832 19.7782 20.279C19.3877 20.6695 18.7545 20.6695 18.364 20.279C17.9734 19.8885 17.9734 19.2553 18.364 18.8648C21.8787 15.35 21.8787 9.65156 18.364 6.13684C17.9734 5.74632 17.9734 5.11315 18.364 4.72263Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 12.5008C9 10.8439 10.3431 9.50076 12 9.50076C13.6569 9.50076 15 10.8439 15 12.5008C15 14.1576 13.6569 15.5008 12 15.5008C10.3431 15.5008 9 14.1576 9 12.5008Z" fill="currentColor"/>
</g>
</symbol>
<symbol id="shield-tick" viewBox="0 0 24 24" fill="none">
<path d="M9 11.5L11 13.5L15.5 8.99999M20 12C20 16.9084 14.646 20.4784 12.698 21.6149C12.4766 21.744 12.3659 21.8086 12.2097 21.8421C12.0884 21.8681 11.9116 21.8681 11.7903 21.8421C11.6341 21.8086 11.5234 21.744 11.302 21.6149C9.35396 20.4784 4 16.9084 4 12V7.21759C4 6.41808 4 6.01833 4.13076 5.6747C4.24627 5.37113 4.43398 5.10027 4.67766 4.88552C4.9535 4.64243 5.3278 4.50207 6.0764 4.22134L11.4382 2.21067C11.6461 2.13271 11.75 2.09373 11.857 2.07827C11.9518 2.06457 12.0482 2.06457 12.143 2.07827C12.25 2.09373 12.3539 2.13271 12.5618 2.21067L17.9236 4.22134C18.6722 4.50207 19.0465 4.64243 19.3223 4.88552C19.566 5.10027 19.7537 5.37113 19.8692 5.6747C20 6.01833 20 6.41808 20 7.21759V12Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</symbol>
</defs> </defs>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
@ -11,7 +11,7 @@
<link rel="preconnect" href="https://imgproxy.snort.social" /> <link rel="preconnect" href="https://imgproxy.snort.social" />
<link rel="apple-touch-icon" href="/nostrich_512.png" /> <link rel="apple-touch-icon" href="/nostrich_512.png" />
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json" />
<title>Snort - Nostr</title> <title><%= htmlWebpackPlugin.options.templateParameters.appTitle %></title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,126 @@
import debug from "debug";
import { EventKind, RequestBuilder, SystemInterface, TaggedNostrEvent } from "@snort/system";
import { unixNow, unixNowMs } from "@snort/shared";
import { db } from "Db";
import { RefreshFeedCache, TWithCreated } from "./RefreshFeedCache";
import { LoginSession } from "Login";
import { Day, Hour } from "Const";
const WindowSize = Hour * 6;
const MaxCacheWindow = Day * 7;
export class FollowsFeedCache extends RefreshFeedCache<TaggedNostrEvent> {
#kinds = [EventKind.TextNote, EventKind.Repost, EventKind.Polls];
#oldest?: number;
constructor() {
super("FollowsFeedCache", db.followsFeed);
}
key(of: TWithCreated<TaggedNostrEvent>): string {
return of.id;
}
takeSnapshot(): TWithCreated<TaggedNostrEvent>[] {
return [...this.cache.values()];
}
buildSub(session: LoginSession, rb: RequestBuilder): void {
const since = this.newest();
rb.withFilter()
.kinds(this.#kinds)
.authors(session.follows.item)
.since(since === 0 ? unixNow() - WindowSize : since);
}
async onEvent(evs: readonly TaggedNostrEvent[]): Promise<void> {
const filtered = evs.filter(a => this.#kinds.includes(a.kind));
if (filtered.length > 0) {
await this.bulkSet(filtered);
this.notifyChange(filtered.map(a => this.key(a)));
}
}
override async preload() {
const start = unixNowMs();
const keys = (await this.table?.toCollection().primaryKeys()) ?? [];
this.onTable = new Set<string>(keys.map(a => a as string));
// load only latest 10 posts, rest can be loaded on-demand
const latest = await this.table?.orderBy("created_at").reverse().limit(50).toArray();
latest?.forEach(v => this.cache.set(this.key(v), v));
// cleanup older than 7 days
await this.table
?.where("created_at")
.below(unixNow() - MaxCacheWindow)
.delete();
const oldest = await this.table?.orderBy("created_at").first();
this.#oldest = oldest?.created_at;
this.notifyChange(latest?.map(a => this.key(a)) ?? []);
debug(this.name)(`Loaded %d/%d in %d ms`, latest?.length ?? 0, keys.length, (unixNowMs() - start).toLocaleString());
}
async loadMore(system: SystemInterface, session: LoginSession, before: number) {
if (this.#oldest && before <= this.#oldest) {
const rb = new RequestBuilder(`${this.name}-loadmore`);
rb.withFilter()
.kinds(this.#kinds)
.authors(session.follows.item)
.until(before)
.since(before - WindowSize);
await system.Fetch(rb, async evs => {
await this.bulkSet(evs);
});
} else {
const latest = await this.table
?.where("created_at")
.between(before - WindowSize, before)
.reverse()
.sortBy("created_at");
latest?.forEach(v => {
const k = this.key(v);
this.cache.set(k, v);
this.onTable.add(k);
});
this.notifyChange(latest?.map(a => this.key(a)) ?? []);
}
}
/**
* Backfill cache with new follows
*/
async backFill(system: SystemInterface, keys: Array<string>) {
if (keys.length === 0) return;
const rb = new RequestBuilder(`${this.name}-backfill`);
rb.withFilter()
.kinds(this.#kinds)
.authors(keys)
.until(unixNow())
.since(this.#oldest ?? unixNow() - MaxCacheWindow);
await system.Fetch(rb, async evs => {
await this.bulkSet(evs);
});
}
/**
* Backfill cache based on follows list
*/
async backFillIfMissing(system: SystemInterface, keys: Array<string>) {
if (!this.#oldest) return;
const start = unixNowMs();
const everything = await this.table?.toArray();
if ((everything?.length ?? 0) > 0) {
const allKeys = new Set(everything?.map(a => a.pubkey));
const missingKeys = keys.filter(a => !allKeys.has(a));
await this.backFill(system, missingKeys);
debug(this.name)(`Backfilled %d keys in %d ms`, missingKeys.length, (unixNowMs() - start).toLocaleString());
}
}
}

View File

@ -1,9 +1,10 @@
import { FeedCache } from "@snort/shared"; import { EventKind, EventPublisher, RequestBuilder, TaggedNostrEvent } from "@snort/system";
import { EventKind, EventPublisher, TaggedNostrEvent } from "@snort/system";
import { UnwrappedGift, db } from "Db"; import { UnwrappedGift, db } from "Db";
import { findTag, unwrap } from "SnortUtils"; import { findTag, unwrap } from "SnortUtils";
import { RefreshFeedCache } from "./RefreshFeedCache";
import { LoginSession, LoginSessionType } from "Login";
export class GiftWrapCache extends FeedCache<UnwrappedGift> { export class GiftWrapCache extends RefreshFeedCache<UnwrappedGift> {
constructor() { constructor() {
super("GiftWrapCache", db.gifts); super("GiftWrapCache", db.gifts);
} }
@ -12,22 +13,20 @@ export class GiftWrapCache extends FeedCache<UnwrappedGift> {
return of.id; return of.id;
} }
override async preload(): Promise<void> { buildSub(session: LoginSession, rb: RequestBuilder): void {
await super.preload(); const pubkey = session.publicKey;
await this.buffer([...this.onTable]); if (pubkey && session.type === LoginSessionType.PrivateKey) {
} rb.withFilter().kinds([EventKind.GiftWrap]).tag("p", [pubkey]).since(this.newest());
}
newest(): number {
let ret = 0;
this.cache.forEach(v => (ret = v.created_at > ret ? v.created_at : ret));
return ret;
} }
takeSnapshot(): Array<UnwrappedGift> { takeSnapshot(): Array<UnwrappedGift> {
return [...this.cache.values()]; return [...this.cache.values()];
} }
async onEvent(evs: Array<TaggedNostrEvent>, pub: EventPublisher) { override async onEvent(evs: Array<TaggedNostrEvent>, pub?: EventPublisher) {
if (!pub) return;
const unwrapped = ( const unwrapped = (
await Promise.all( await Promise.all(
evs.map(async v => { evs.map(async v => {
@ -41,7 +40,7 @@ export class GiftWrapCache extends FeedCache<UnwrappedGift> {
} catch (e) { } catch (e) {
console.debug(e, v); console.debug(e, v);
} }
}) }),
) )
) )
.filter(a => a !== undefined) .filter(a => a !== undefined)

View File

@ -1,8 +1,9 @@
import { EventKind, NostrEvent, RequestBuilder, TaggedNostrEvent } from "@snort/system"; import { EventKind, NostrEvent, RequestBuilder, TaggedNostrEvent } from "@snort/system";
import { RefreshFeedCache, TWithCreated } from "./RefreshFeedCache"; import { RefreshFeedCache, TWithCreated } from "./RefreshFeedCache";
import { LoginSession } from "Login"; import { LoginSession } from "Login";
import { unixNow } from "SnortUtils";
import { db } from "Db"; import { db } from "Db";
import { Day } from "Const";
import { unixNow } from "@snort/shared";
export class NotificationsCache extends RefreshFeedCache<NostrEvent> { export class NotificationsCache extends RefreshFeedCache<NostrEvent> {
#kinds = [EventKind.TextNote, EventKind.Reaction, EventKind.Repost, EventKind.ZapReceipt]; #kinds = [EventKind.TextNote, EventKind.Reaction, EventKind.Repost, EventKind.ZapReceipt];
@ -17,7 +18,7 @@ export class NotificationsCache extends RefreshFeedCache<NostrEvent> {
rb.withFilter() rb.withFilter()
.kinds(this.#kinds) .kinds(this.#kinds)
.tag("p", [session.publicKey]) .tag("p", [session.publicKey])
.since(newest === 0 ? unixNow() - 60 * 60 * 24 * 30 : newest); .since(newest === 0 ? unixNow() - Day * 30 : newest);
} }
} }

View File

@ -1,12 +1,12 @@
import { FeedCache } from "@snort/shared"; import { FeedCache } from "@snort/shared";
import { RequestBuilder, TaggedNostrEvent } from "@snort/system"; import { EventPublisher, RequestBuilder, TaggedNostrEvent } from "@snort/system";
import { LoginSession } from "Login"; import { LoginSession } from "Login";
export type TWithCreated<T> = T & { created_at: number }; export type TWithCreated<T> = (T | Readonly<T>) & { created_at: number };
export abstract class RefreshFeedCache<T> extends FeedCache<TWithCreated<T>> { export abstract class RefreshFeedCache<T> extends FeedCache<TWithCreated<T>> {
abstract buildSub(session: LoginSession, rb: RequestBuilder): void; abstract buildSub(session: LoginSession, rb: RequestBuilder): void;
abstract onEvent(evs: Readonly<Array<TaggedNostrEvent>>): void; abstract onEvent(evs: Readonly<Array<TaggedNostrEvent>>, pub?: EventPublisher): void;
/** /**
* Get latest event * Get latest event

View File

@ -4,6 +4,7 @@ import { ChatCache } from "./ChatCache";
import { Payments } from "./PaymentsCache"; import { Payments } from "./PaymentsCache";
import { GiftWrapCache } from "./GiftWrapCache"; import { GiftWrapCache } from "./GiftWrapCache";
import { NotificationsCache } from "./Notifications"; import { NotificationsCache } from "./Notifications";
import { FollowsFeedCache } from "./FollowsFeed";
export const UserCache = new UserProfileCache(); export const UserCache = new UserProfileCache();
export const UserRelays = new UserRelaysCache(); export const UserRelays = new UserRelaysCache();
@ -13,6 +14,7 @@ export const PaymentsCache = new Payments();
export const InteractionCache = new EventInteractionCache(); export const InteractionCache = new EventInteractionCache();
export const GiftsCache = new GiftWrapCache(); export const GiftsCache = new GiftWrapCache();
export const Notifications = new NotificationsCache(); export const Notifications = new NotificationsCache();
export const FollowsFeed = new FollowsFeedCache();
export async function preload(follows?: Array<string>) { export async function preload(follows?: Array<string>) {
const preloads = [ const preloads = [
@ -23,6 +25,7 @@ export async function preload(follows?: Array<string>) {
RelayMetrics.preload(), RelayMetrics.preload(),
GiftsCache.preload(), GiftsCache.preload(),
Notifications.preload(), Notifications.preload(),
FollowsFeed.preload(),
]; ];
await Promise.all(preloads); await Promise.all(preloads);
} }

View File

@ -1,5 +1,15 @@
import { RelaySettings } from "@snort/system"; import { RelaySettings } from "@snort/system";
/**
* 1 Hour in seconds
*/
export const Hour = 60 * 60;
/**
* 1 Day in seconds
*/
export const Day = Hour * 24;
/** /**
* Add-on api for snort features * Add-on api for snort features
*/ */

View File

@ -1,8 +1,8 @@
import Dexie, { Table } from "dexie"; import Dexie, { Table } from "dexie";
import { HexKey, NostrEvent, u256 } from "@snort/system"; import { HexKey, NostrEvent, TaggedNostrEvent, u256 } from "@snort/system";
export const NAME = "snortDB"; export const NAME = "snortDB";
export const VERSION = 13; export const VERSION = 14;
export interface SubCache { export interface SubCache {
id: string; id: string;
@ -41,6 +41,7 @@ const STORES = {
payments: "++url", payments: "++url",
gifts: "++id", gifts: "++id",
notifications: "++id", notifications: "++id",
followsFeed: "++id, created_at, kind",
}; };
export class SnortDB extends Dexie { export class SnortDB extends Dexie {
@ -50,6 +51,7 @@ export class SnortDB extends Dexie {
payments!: Table<Payment>; payments!: Table<Payment>;
gifts!: Table<UnwrappedGift>; gifts!: Table<UnwrappedGift>;
notifications!: Table<NostrEvent>; notifications!: Table<NostrEvent>;
followsFeed!: Table<TaggedNostrEvent>;
constructor() { constructor() {
super(NAME); super(NAME);

View File

@ -1,5 +1,5 @@
import "./AsyncButton.css"; import "./AsyncButton.css";
import { useState } from "react"; import React, { useState, ForwardedRef } from "react";
import Spinner from "../Icons/Spinner"; import Spinner from "../Icons/Spinner";
interface AsyncButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { interface AsyncButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
@ -8,7 +8,7 @@ interface AsyncButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
children?: React.ReactNode; children?: React.ReactNode;
} }
export default function AsyncButton(props: AsyncButtonProps) { const AsyncButton = React.forwardRef<HTMLButtonElement, AsyncButtonProps>((props, ref) => {
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
async function handle(e: React.MouseEvent) { async function handle(e: React.MouseEvent) {
@ -28,7 +28,13 @@ export default function AsyncButton(props: AsyncButtonProps) {
} }
return ( return (
<button className="spinner-button" type="button" disabled={loading || props.disabled} {...props} onClick={handle}> <button
ref={ref as ForwardedRef<HTMLButtonElement>}
className="spinner-button"
type="button"
disabled={loading || props.disabled}
{...props}
onClick={handle}>
<span style={{ visibility: loading ? "hidden" : "visible" }}>{props.children}</span> <span style={{ visibility: loading ? "hidden" : "visible" }}>{props.children}</span>
{loading && ( {loading && (
<span className="spinner-wrapper"> <span className="spinner-wrapper">
@ -37,4 +43,6 @@ export default function AsyncButton(props: AsyncButtonProps) {
)} )}
</button> </button>
); );
} });
export default AsyncButton;

View File

@ -1,20 +0,0 @@
.avatar {
border-radius: 50%;
height: 210px;
width: 210px;
background-image: var(--img-url);
border: 1px solid transparent;
background-origin: border-box;
background-clip: content-box, border-box;
background-size: cover;
box-sizing: border-box;
background-color: var(--gray);
}
.avatar[data-domain="snort.social"] {
background-image: var(--img-url), var(--snort-gradient);
}
.avatar[data-domain="strike.army"] {
background-image: var(--img-url), var(--strike-army-gradient);
}

View File

@ -6,18 +6,17 @@
font-size: var(--font-size); font-size: var(--font-size);
display: flex; display: flex;
align-items: center; align-items: center;
border: none !important;
box-shadow: none !important;
} }
.back-button svg { .back-button svg {
margin-right: 0.5em; margin-right: 0.5em;
} }
.back-button:hover { .back-button:hover:hover,
text-decoration: underline; .light .back-button:hover {
}
.back-button:hover {
background: none;
color: var(--font-color);
text-decoration: underline; text-decoration: underline;
box-shadow: none !important;
background: none !important;
} }

View File

@ -1,8 +1,8 @@
import { useState, useMemo, ChangeEvent } from "react"; import { useState, useMemo, ChangeEvent } from "react";
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import { HexKey, TaggedNostrEvent } from "@snort/system"; import { HexKey, TaggedNostrEvent } from "@snort/system";
import Note from "Element/Note"; import Note from "Element/Event/Note";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import { UserCache } from "Cache"; import { UserCache } from "Cache";
@ -16,7 +16,7 @@ interface BookmarksProps {
const Bookmarks = ({ pubkey, bookmarks, related }: BookmarksProps) => { const Bookmarks = ({ pubkey, bookmarks, related }: BookmarksProps) => {
const [onlyPubkey, setOnlyPubkey] = useState<HexKey | "all">("all"); const [onlyPubkey, setOnlyPubkey] = useState<HexKey | "all">("all");
const loginPubKey = useLogin().publicKey; const { publicKey } = useLogin(s => ({ publicKey: s.publicKey }));
const ps = useMemo(() => { const ps = useMemo(() => {
return [...new Set(bookmarks.map(ev => ev.pubkey))]; return [...new Set(bookmarks.map(ev => ev.pubkey))];
}, [bookmarks]); }, [bookmarks]);
@ -28,7 +28,7 @@ const Bookmarks = ({ pubkey, bookmarks, related }: BookmarksProps) => {
return ( return (
<div className="main-content"> <div className="main-content">
<div className="mb10 flex-end"> <div className="flex-end p">
<select <select
disabled={ps.length <= 1} disabled={ps.length <= 1}
value={onlyPubkey} value={onlyPubkey}
@ -47,7 +47,7 @@ const Bookmarks = ({ pubkey, bookmarks, related }: BookmarksProps) => {
key={n.id} key={n.id}
data={n} data={n}
related={related} related={related}
options={{ showTime: false, showBookmarked: true, canUnbookmark: loginPubKey === pubkey }} options={{ showTime: false, showBookmarked: true, canUnbookmark: publicKey === pubkey }}
/> />
); );
})} })}

View File

@ -1,81 +0,0 @@
import { useEffect, useState } from "react";
import { FormattedMessage } from "react-intl";
import useLogin from "Hooks/useLogin";
import { useUserProfile } from "@snort/system-react";
interface Token {
token: Array<{
mint: string;
proofs: Array<{
amount: number;
}>;
}>;
memo?: string;
}
export default function CashuNuts({ token }: { token: string }) {
const login = useLogin();
const profile = useUserProfile(login.publicKey);
async function copyToken(e: React.MouseEvent<HTMLButtonElement>, token: string) {
e.stopPropagation();
await navigator.clipboard.writeText(token);
}
async function redeemToken(e: React.MouseEvent<HTMLButtonElement>, token: string) {
e.stopPropagation();
const lnurl = profile?.lud16 ?? "";
const url = `https://redeem.cashu.me?token=${encodeURIComponent(token)}&lightning=${encodeURIComponent(
lnurl
)}&autopay=yes`;
window.open(url, "_blank");
}
const [cashu, setCashu] = useState<Token>();
useEffect(() => {
try {
if (!token.startsWith("cashuA") || token.length < 10) {
return;
}
import("@cashu/cashu-ts").then(({ getDecodedToken }) => {
const tkn = getDecodedToken(token);
setCashu(tkn);
});
} catch {
// ignored
}
}, [token]);
if (!cashu) return <>{token}</>;
return (
<div className="note-invoice">
<div className="flex f-between">
<div>
<h4>
<FormattedMessage defaultMessage="Cashu token" />
</h4>
<p>
<FormattedMessage
defaultMessage="Amount: {amount} sats"
values={{
amount: cashu.token[0].proofs.reduce((acc, v) => acc + v.amount, 0),
}}
/>
</p>
<small className="xs">
<FormattedMessage defaultMessage="Mint: {url}" values={{ url: cashu.token[0].mint }} />
</small>
</div>
<div>
<button onClick={e => copyToken(e, token)} className="mr5">
<FormattedMessage defaultMessage="Copy" description="Button: Copy Cashu token" />
</button>
<button onClick={e => redeemToken(e, token)}>
<FormattedMessage defaultMessage="Redeem" description="Button: Redeem Cashu token" />
</button>
</div>
</div>
</div>
);
}

View File

@ -0,0 +1,12 @@
import { ChatParticipant } from "chat";
import NoteToSelf from "../User/NoteToSelf";
import ProfileImage from "../User/ProfileImage";
import useLogin from "Hooks/useLogin";
export function ChatParticipantProfile({ participant }: { participant: ChatParticipant }) {
const { publicKey } = useLogin(s => ({ publicKey: s.publicKey }));
if (participant.id === publicKey) {
return <NoteToSelf className="f-grow" pubkey={participant.id} />;
}
return <ProfileImage pubkey={participant.id} className="f-grow" profile={participant.profile} />;
}

View File

@ -1,16 +1,16 @@
import "./DM.css"; import "./DM.css";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import { useInView } from "react-intersection-observer"; import { useInView } from "react-intersection-observer";
import useEventPublisher from "Feed/EventPublisher"; import useEventPublisher from "Hooks/useEventPublisher";
import NoteTime from "Element/NoteTime"; import NoteTime from "Element/Event/NoteTime";
import Text from "Element/Text"; import Text from "Element/Text";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import { Chat, ChatMessage, ChatType, setLastReadIn } from "chat"; import { Chat, ChatMessage, ChatType, setLastReadIn } from "chat";
import ProfileImage from "../User/ProfileImage";
import messages from "./messages"; import messages from "../messages";
import ProfileImage from "./ProfileImage";
export interface DMProps { export interface DMProps {
chat: Chat; chat: Chat;
@ -18,15 +18,14 @@ export interface DMProps {
} }
export default function DM(props: DMProps) { export default function DM(props: DMProps) {
const pubKey = useLogin().publicKey; const { publicKey } = useLogin(s => ({ publicKey: s.publicKey }));
const publisher = useEventPublisher(); const publisher = useEventPublisher();
const msg = props.data; const msg = props.data;
const [content, setContent] = useState(msg.needsDecryption ? "Loading..." : msg.content); const [content, setContent] = useState<string>();
const [decrypted, setDecrypted] = useState(false); const { ref, inView } = useInView({ triggerOnce: true });
const { ref, inView } = useInView();
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const isMe = msg.from === pubKey; const isMe = msg.from === publicKey;
const otherPubkey = isMe ? pubKey : msg.from; const otherPubkey = isMe ? publicKey : msg.from;
async function decrypt() { async function decrypt() {
if (publisher) { if (publisher) {
@ -46,17 +45,24 @@ export default function DM(props: DMProps) {
} }
useEffect(() => { useEffect(() => {
if (!decrypted && inView && msg.needsDecryption) { if (inView) {
setDecrypted(true); if (msg.needsDecryption) {
decrypt().catch(console.error); decrypt().catch(console.error);
} else {
setContent(msg.content);
}
} }
}, [inView, msg]); }, [inView]);
return ( return (
<div className={isMe ? "dm me" : "dm other"} ref={ref}> <div className={isMe ? "dm me" : "dm other"} ref={ref}>
<div> <div>
{sender()} {sender()}
<Text content={content} tags={[]} creator={otherPubkey} /> {content ? (
<Text id={msg.id} content={content} tags={[]} creator={otherPubkey} />
) : (
<FormattedMessage defaultMessage="Loading..." />
)}
</div> </div>
<div> <div>
<NoteTime from={msg.created_at * 1000} fallback={formatMessage(messages.JustNow)} /> <NoteTime from={msg.created_at * 1000} fallback={formatMessage(messages.JustNow)} />

View File

@ -1,35 +1,21 @@
import "./DmWindow.css"; import "./DmWindow.css";
import { useMemo } from "react"; import { useMemo } from "react";
import ProfileImage from "Element/ProfileImage"; import ProfileImage from "Element/User/ProfileImage";
import DM from "Element/DM"; import DM from "Element/Chat/DM";
import NoteToSelf from "Element/NoteToSelf";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import WriteMessage from "Element/WriteMessage"; import WriteMessage from "Element/Chat/WriteMessage";
import { Chat, ChatParticipant, createEmptyChatObject, useChatSystem } from "chat"; import { Chat, createEmptyChatObject, useChatSystem } from "chat";
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import { ChatParticipantProfile } from "./ChatParticipant";
export default function DmWindow({ id }: { id: string }) { export default function DmWindow({ id }: { id: string }) {
const pubKey = useLogin().publicKey;
const dms = useChatSystem(); const dms = useChatSystem();
const chat = dms.find(a => a.id === id) ?? createEmptyChatObject(id); const chat = dms.find(a => a.id === id) ?? createEmptyChatObject(id);
function participant(p: ChatParticipant) {
if (p.id === pubKey) {
return <NoteToSelf className="f-grow mb-10" pubkey={p.id} />;
}
if (p.type === "pubkey") {
return <ProfileImage pubkey={p.id} className="f-grow mb10" />;
}
if (p?.profile) {
return <ProfileImage pubkey={p.id} className="f-grow mb10" profile={p.profile} />;
}
return <ProfileImage pubkey={p.id} className="f-grow mb10" overrideUsername={p.id} />;
}
function sender() { function sender() {
if (chat.participants.length === 1) { if (chat.participants.length === 1) {
return participant(chat.participants[0]); return <ChatParticipantProfile participant={chat.participants[0]} />;
} else { } else {
return ( return (
<div className="flex pfp-overlap mb10"> <div className="flex pfp-overlap mb10">
@ -56,7 +42,7 @@ export default function DmWindow({ id }: { id: string }) {
} }
function DmChatSelected({ chat }: { chat: Chat }) { function DmChatSelected({ chat }: { chat: Chat }) {
const { publicKey: myPubKey } = useLogin(); const { publicKey: myPubKey } = useLogin(s => ({ publicKey: s.publicKey }));
const sortedDms = useMemo(() => { const sortedDms = useMemo(() => {
const myDms = chat?.messages; const myDms = chat?.messages;
if (myPubKey && myDms) { if (myPubKey && myDms) {

View File

@ -1,11 +1,11 @@
import { encodeTLV, NostrPrefix, NostrEvent } from "@snort/system"; import { NostrPrefix, NostrEvent, NostrLink } from "@snort/system";
import useEventPublisher from "Feed/EventPublisher"; import useEventPublisher from "Hooks/useEventPublisher";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import Spinner from "Icons/Spinner"; import Spinner from "Icons/Spinner";
import { useState } from "react"; import { useState } from "react";
import useFileUpload from "Upload"; import useFileUpload from "Upload";
import { openFile } from "SnortUtils"; import { openFile } from "SnortUtils";
import Textarea from "./Textarea"; import Textarea from "../Textarea";
import { System } from "index"; import { System } from "index";
import { Chat } from "chat"; import { Chat } from "chat";
@ -37,7 +37,7 @@ export default function WriteMessage({ chat }: { chat: Chat }) {
if (file) { if (file) {
const rx = await uploader.upload(file, file.name); const rx = await uploader.upload(file, file.name);
if (rx.header) { if (rx.header) {
const link = `nostr:${encodeTLV(NostrPrefix.Event, rx.header.id, undefined, rx.header.kind)}`; const link = `nostr:${new NostrLink(NostrPrefix.Event, rx.header.id, rx.header.kind).encode()}`;
setMsg(`${msg ? `${msg}\n` : ""}${link}`); setMsg(`${msg ? `${msg}\n` : ""}${link}`);
setOtherEvents([...otherEvents, rx.header]); setOtherEvents([...otherEvents, rx.header]);
} else if (rx.url) { } else if (rx.url) {

View File

@ -1,7 +1,7 @@
import { useState, ReactNode } from "react"; import { useState, ReactNode } from "react";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import ShowMore from "Element/ShowMore"; import ShowMore from "Element/Event/ShowMore";
interface CollapsedProps { interface CollapsedProps {
text?: string; text?: string;

View File

@ -1,14 +1,5 @@
.copy { .copy .copy-body {
cursor: pointer;
align-items: center;
}
.copy .body {
font-size: var(--font-size-small); font-size: var(--font-size-small);
color: var(--font-color); color: var(--font-color);
margin-right: 6px; margin-right: 6px;
} }
.copy .icon {
margin-bottom: -4px;
}

View File

@ -13,8 +13,8 @@ export default function Copy({ text, maxSize = 32, className }: CopyProps) {
const trimmed = text.length > maxSize ? `${text.slice(0, sliceLength)}...${text.slice(-sliceLength)}` : text; const trimmed = text.length > maxSize ? `${text.slice(0, sliceLength)}...${text.slice(-sliceLength)}` : text;
return ( return (
<div className={`flex flex-row copy ${className}`} onClick={() => copy(text)}> <div className={`copy flex pointer g8${className ? ` ${className}` : ""}`} onClick={() => copy(text)}>
<span className="body">{trimmed}</span> <span className="copy-body">{trimmed}</span>
<span className="icon" style={{ color: copied ? "var(--success)" : "var(--highlight)" }}> <span className="icon" style={{ color: copied ? "var(--success)" : "var(--highlight)" }}>
{copied ? <Icon name="check" size={14} /> : <Icon name="copy-solid" size={14} />} {copied ? <Icon name="check" size={14} /> : <Icon name="copy-solid" size={14} />}
</span> </span>

View File

@ -0,0 +1,18 @@
import { NostrLink } from "@snort/system";
import { useArticles } from "Feed/ArticlesFeed";
import { orderDescending } from "SnortUtils";
import Note from "../Event/Note";
import { useReactions } from "Feed/Reactions";
export default function Articles() {
const data = useArticles();
const related = useReactions("articles:reactions", data.data?.map(v => NostrLink.fromEvent(v)) ?? []);
return (
<>
{orderDescending(data.data ?? []).map(a => (
<Note data={a} key={a.id} related={related.data ?? []} />
))}
</>
);
}

View File

@ -0,0 +1,12 @@
nav.deck {
width: 48px;
height: calc(100vh - 20px);
padding: 10px 8px;
border-right: 1px solid var(--border-color);
text-align: center;
}
nav.deck .avatar {
width: 40px;
height: 40px;
}

View File

@ -0,0 +1,41 @@
import { useUserProfile } from "@snort/system-react";
import Avatar from "Element/User/Avatar";
import useLogin from "Hooks/useLogin";
import "./Nav.css";
import Icon from "Icons/Icon";
import { Link } from "react-router-dom";
import { profileLink } from "SnortUtils";
export function DeckNav() {
const { publicKey } = useLogin();
const profile = useUserProfile(publicKey);
const unreadDms = 0;
const hasNotifications = false;
return (
<nav className="deck flex-column f-space">
<div className="flex-column f-center g24">
<Link className="btn" to="/messages">
<Icon name="mail" size={24} />
{unreadDms > 0 && <span className="has-unread"></span>}
</Link>
<Link className="btn" to="/notifications">
<Icon name="bell-02" size={24} />
{hasNotifications && <span className="has-unread"></span>}
</Link>
</div>
<div className="flex-column f-center g16">
<Link className="btn" to="/">
<Icon name="grid-01" size={24} />
</Link>
<Link className="btn" to="/settings">
<Icon name="settings-02" size={24} />
</Link>
<Link to={profileLink(publicKey ?? "")}>
<Avatar pubkey={publicKey ?? ""} user={profile} />
</Link>
</div>
</nav>
);
}

View File

@ -10,15 +10,15 @@
background: transparent; background: transparent;
} }
.modal.spotlight img, .spotlight img,
.modal.spotlight video { .spotlight video {
max-width: 100vw; max-width: 100vw;
max-height: 100vh; max-height: 99vh;
aspect-ratio: unset; aspect-ratio: unset;
width: unset; width: unset;
} }
.modal.spotlight .details { .spotlight .details {
text-align: right; text-align: right;
position: absolute; position: absolute;
top: 28px; top: 28px;
@ -29,16 +29,17 @@
font-weight: 400; font-weight: 400;
line-height: 24px; line-height: 24px;
align-items: center; align-items: center;
user-select: none;
} }
.modal.spotlight .left { .spotlight .left {
position: absolute; position: absolute;
left: 24px; left: 24px;
top: 50vh; top: 50vh;
transform: rotate(180deg); transform: rotate(180deg);
} }
.modal.spotlight .right { .spotlight .right {
position: absolute; position: absolute;
right: 24px; right: 24px;
top: 50vh; top: 50vh;

View File

@ -37,7 +37,7 @@ export function SpotlightMedia(props: SpotlightMediaProps) {
}); });
} }
return ( return (
<Modal onClose={props.onClose} className="spotlight"> <div className="spotlight">
<ProxyImg src={image} /> <ProxyImg src={image} />
<div className="details"> <div className="details">
{idx + 1}/{props.images.length} {idx + 1}/{props.images.length}
@ -49,6 +49,14 @@ export function SpotlightMedia(props: SpotlightMediaProps) {
<Icon className="right" name="arrowFront" size={24} onClick={() => inc()} /> <Icon className="right" name="arrowFront" size={24} onClick={() => inc()} />
</> </>
)} )}
</div>
);
}
export function SpotlightMediaModal(props: SpotlightMediaProps) {
return (
<Modal id="spotlight" onClose={props.onClose} className="spotlight">
<SpotlightMedia {...props} />
</Modal> </Modal>
); );
} }

View File

@ -0,0 +1,8 @@
.cashu {
background: var(--cashu-gradient);
}
.cashu h1 {
font-size: 44px;
line-height: 1em;
}

View File

@ -0,0 +1,137 @@
import "./CashuNuts.css";
import { useEffect, useState } from "react";
import { FormattedMessage, FormattedNumber } from "react-intl";
import { useUserProfile } from "@snort/system-react";
import useLogin from "Hooks/useLogin";
import Icon from "Icons/Icon";
interface Token {
token: Array<{
mint: string;
proofs: Array<{
amount: number;
}>;
}>;
memo?: string;
}
export default function CashuNuts({ token }: { token: string }) {
const { publicKey } = useLogin(s => ({ publicKey: s.publicKey }));
const profile = useUserProfile(publicKey);
async function copyToken(e: React.MouseEvent<HTMLButtonElement>, token: string) {
e.stopPropagation();
await navigator.clipboard.writeText(token);
}
async function redeemToken(e: React.MouseEvent<HTMLButtonElement>, token: string) {
e.stopPropagation();
const lnurl = profile?.lud16 ?? "";
const url = `https://redeem.cashu.me?token=${encodeURIComponent(token)}&lightning=${encodeURIComponent(
lnurl,
)}&autopay=yes`;
window.open(url, "_blank");
}
const [cashu, setCashu] = useState<Token>();
useEffect(() => {
try {
if (!token.startsWith("cashuA") || token.length < 10) {
return;
}
import("@cashu/cashu-ts").then(({ getDecodedToken }) => {
const tkn = getDecodedToken(token);
setCashu(tkn);
});
} catch {
// ignored
}
}, [token]);
if (!cashu) return <>{token}</>;
const amount = cashu.token[0].proofs.reduce((acc, v) => acc + v.amount, 0);
return (
<div className="cashu flex f-space p24 br">
<div className="flex-column g8 f-ellipsis">
<div className="flex f-center g16">
<svg width="30" height="39" viewBox="0 0 30 39" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Group 47711">
<path
id="Rectangle 585"
d="M29.3809 2.47055L29.3809 11.7277L26.7913 11.021C23.8493 10.2181 20.727 10.3835 17.8863 11.4929C15.5024 12.4238 12.9113 12.6933 10.3869 12.2728L7.11501 11.7277L7.11501 2.47054L10.3869 3.01557C12.9113 3.43607 15.5024 3.1666 17.8863 2.23566C20.727 1.12632 23.8493 0.960876 26.7913 1.7638L29.3809 2.47055Z"
fill="url(#paint0_linear_1976_19241)"
/>
<path
id="Rectangle 587"
d="M29.3809 27.9803L29.3809 37.2375L26.7913 36.5308C23.8493 35.7278 20.727 35.8933 17.8863 37.0026C15.5024 37.9336 12.9113 38.203 10.3869 37.7825L7.11501 37.2375L7.11501 27.9803L10.3869 28.5253C12.9113 28.9458 15.5024 28.6764 17.8863 27.7454C20.727 26.6361 23.8493 26.4706 26.7913 27.2736L29.3809 27.9803Z"
fill="url(#paint1_linear_1976_19241)"
/>
<path
id="Rectangle 586"
d="M8.494e-08 15.2069L4.89585e-07 24.4641L2.5896 23.7573C5.53159 22.9544 8.6539 23.1198 11.4946 24.2292C13.8784 25.1601 16.4695 25.4296 18.9939 25.0091L22.2658 24.4641L22.2658 15.2069L18.9939 15.7519C16.4695 16.1724 13.8784 15.9029 11.4946 14.972C8.6539 13.8627 5.53159 13.6972 2.5896 14.5001L8.494e-08 15.2069Z"
fill="url(#paint2_linear_1976_19241)"
/>
</g>
<defs>
<linearGradient
id="paint0_linear_1976_19241"
x1="29.3809"
y1="6.7213"
x2="7.11501"
y2="6.7213"
gradientUnits="userSpaceOnUse">
<stop stopColor="white" />
<stop offset="1" stopColor="white" stopOpacity="0.5" />
</linearGradient>
<linearGradient
id="paint1_linear_1976_19241"
x1="29.3809"
y1="32.2311"
x2="7.11501"
y2="32.2311"
gradientUnits="userSpaceOnUse">
<stop stopColor="white" />
<stop offset="1" stopColor="white" stopOpacity="0.5" />
</linearGradient>
<linearGradient
id="paint2_linear_1976_19241"
x1="2.70746e-07"
y1="19.4576"
x2="22.2658"
y2="19.4576"
gradientUnits="userSpaceOnUse">
<stop stopColor="white" />
<stop offset="1" stopColor="white" stopOpacity="0.5" />
</linearGradient>
</defs>
</svg>
<FormattedMessage
defaultMessage="<h1>{n}</h1> Cashu sats"
values={{
h1: c => <h1>{c}</h1>,
n: <FormattedNumber value={amount} />,
}}
/>
</div>
<small className="xs w-max">
<FormattedMessage
defaultMessage="<b>Mint:</b> {url}"
values={{
b: c => <b>{c}</b>,
url: new URL(cashu.token[0].mint).hostname,
}}
/>
</small>
</div>
<div className="flex g8">
<button onClick={e => copyToken(e, token)}>
<Icon name="copy" />
</button>
<button onClick={e => redeemToken(e, token)}>
<FormattedMessage defaultMessage="Redeem" description="Button: Redeem Cashu token" />
</button>
</div>
</div>
);
}

View File

@ -8,6 +8,12 @@
background: var(--invoice-gradient); background: var(--invoice-gradient);
} }
.note-invoice.error {
padding: 8px 12px !important;
color: #aaa;
background: transparent;
}
.note-invoice.expired { .note-invoice.expired {
background: var(--expired-invoice-gradient); background: var(--expired-invoice-gradient);
color: var(--font-secondary-color); color: var(--font-secondary-color);

View File

@ -8,7 +8,7 @@ import SendSats from "Element/SendSats";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { useWallet } from "Wallet"; import { useWallet } from "Wallet";
import messages from "./messages"; import messages from "../messages";
export interface InvoiceProps { export interface InvoiceProps {
invoice: string; invoice: string;
@ -75,7 +75,7 @@ export default function Invoice(props: InvoiceProps) {
{description && <p>{description}</p>} {description && <p>{description}</p>}
{isPaid ? ( {isPaid ? (
<div className="paid"> <div className="paid">
<FormattedMessage {...messages.Paid} /> <FormattedMessage defaultMessage="Paid" />
</div> </div>
) : ( ) : (
<button disabled={isExpired} type="button" onClick={payInvoice}> <button disabled={isExpired} type="button" onClick={payInvoice}>

View File

@ -40,12 +40,23 @@
margin: 0 0 15px 0 !important; margin: 0 0 15px 0 !important;
border-radius: 0 !important; border-radius: 0 !important;
background-image: var(--img-url); background-image: var(--img-url);
min-height: 250px; min-height: 220px;
max-height: 500px; max-height: 500px;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
} }
.light .link-preview-container { .light .link-preview-container {
background: #ddd; background: #fff;
border: 1px solid var(--border-color);
}
.light .link-preview-container:hover {
box-shadow: rgba(0, 0, 0, 0.08) 0 1px 3px;
}
@media (min-width: 1025px) {
.link-preview-image {
min-height: 342px;
}
} }

View File

@ -4,7 +4,7 @@ import { CSSProperties, useEffect, useState } from "react";
import Spinner from "Icons/Spinner"; import Spinner from "Icons/Spinner";
import SnortApi, { LinkPreviewData } from "SnortApi"; import SnortApi, { LinkPreviewData } from "SnortApi";
import useImgProxy from "Hooks/useImgProxy"; import useImgProxy from "Hooks/useImgProxy";
import { MediaElement } from "Element/MediaElement"; import { MediaElement } from "Element/Embed/MediaElement";
async function fetchUrlPreviewInfo(url: string) { async function fetchUrlPreviewInfo(url: string) {
const api = new SnortApi(); const api = new SnortApi();

View File

@ -1,4 +1,4 @@
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import { Magnet } from "SnortUtils"; import { Magnet } from "SnortUtils";

View File

@ -4,7 +4,7 @@ import { HexKey } from "@snort/system";
import { useUserProfile } from "@snort/system-react"; import { useUserProfile } from "@snort/system-react";
import { profileLink } from "SnortUtils"; import { profileLink } from "SnortUtils";
import { getDisplayName } from "Element/ProfileImage"; import { getDisplayName } from "Element/User/ProfileImage";
export default function Mention({ pubkey, relays }: { pubkey: HexKey; relays?: Array<string> | string }) { export default function Mention({ pubkey, relays }: { pubkey: HexKey; relays?: Array<string> | string }) {
const user = useUserProfile(pubkey); const user = useUserProfile(pubkey);

View File

@ -4,8 +4,8 @@ import useLogin from "Hooks/useLogin";
const MixCloudEmbed = ({ link }: { link: string }) => { const MixCloudEmbed = ({ link }: { link: string }) => {
const feedPath = (MixCloudRegex.test(link) && RegExp.$1) + "%2F" + (MixCloudRegex.test(link) && RegExp.$2); const feedPath = (MixCloudRegex.test(link) && RegExp.$1) + "%2F" + (MixCloudRegex.test(link) && RegExp.$2);
const lightTheme = useLogin().preferences.theme === "light"; const { theme } = useLogin(s => ({ theme: s.preferences.theme }));
const lightParams = lightTheme ? "light=1" : "light=0"; const lightParams = theme === "light" ? "light=1" : "light=0";
return ( return (
<> <>
<br /> <br />

View File

@ -1,8 +1,8 @@
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { NostrPrefix, tryParseNostrLink } from "@snort/system"; import { NostrPrefix, tryParseNostrLink } from "@snort/system";
import Mention from "Element/Mention"; import Mention from "Element/Embed/Mention";
import NoteQuote from "Element/NoteQuote"; import NoteQuote from "Element/Event/NoteQuote";
export default function NostrLink({ link, depth }: { link: string; depth?: number }) { export default function NostrLink({ link, depth }: { link: string; depth?: number }) {
const nav = tryParseNostrLink(link); const nav = tryParseNostrLink(link);

View File

@ -3,14 +3,14 @@ import { FormattedMessage, FormattedNumber } from "react-intl";
import { LNURL } from "@snort/shared"; import { LNURL } from "@snort/shared";
import { dedupe, hexToBech32 } from "SnortUtils"; import { dedupe, hexToBech32 } from "SnortUtils";
import FollowListBase from "Element/FollowListBase"; import FollowListBase from "Element/User/FollowListBase";
import AsyncButton from "Element/AsyncButton"; import AsyncButton from "Element/AsyncButton";
import { useWallet } from "Wallet"; import { useWallet } from "Wallet";
import { Toastore } from "Toaster"; import { Toastore } from "Toaster";
import { getDisplayName } from "Element/ProfileImage"; import { getDisplayName } from "Element/User/ProfileImage";
import { UserCache } from "Cache"; import { UserCache } from "Cache";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import useEventPublisher from "Feed/EventPublisher"; import useEventPublisher from "Hooks/useEventPublisher";
import { WalletInvoiceState } from "Wallet"; import { WalletInvoiceState } from "Wallet";
export default function PubkeyList({ ev, className }: { ev: NostrEvent; className?: string }) { export default function PubkeyList({ ev, className }: { ev: NostrEvent; className?: string }) {
@ -34,7 +34,7 @@ export default function PubkeyList({ ev, className }: { ev: NostrEvent; classNam
pk, pk,
Object.keys(login.relays.item), Object.keys(login.relays.item),
undefined, undefined,
`Zap from ${hexToBech32("note", ev.id)}` `Zap from ${hexToBech32("note", ev.id)}`,
); );
const invoice = await svc.getInvoice(amtSend, undefined, zap); const invoice = await svc.getInvoice(amtSend, undefined, zap);
if (invoice.pr) { if (invoice.pr) {

View File

@ -1,10 +1,10 @@
import "./ZapstrEmbed.css"; import "./ZapstrEmbed.css";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { encodeTLV, NostrPrefix, NostrEvent } from "@snort/system"; import { NostrEvent, NostrLink } from "@snort/system";
import { ProxyImg } from "Element/ProxyImg"; import { ProxyImg } from "Element/ProxyImg";
import ProfileImage from "Element/ProfileImage"; import ProfileImage from "Element/User/ProfileImage";
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
export default function ZapstrEmbed({ ev }: { ev: NostrEvent }) { export default function ZapstrEmbed({ ev }: { ev: NostrEvent }) {
const media = ev.tags.find(a => a[0] === "media"); const media = ev.tags.find(a => a[0] === "media");
@ -12,13 +12,7 @@ export default function ZapstrEmbed({ ev }: { ev: NostrEvent }) {
const subject = ev.tags.find(a => a[0] === "subject"); const subject = ev.tags.find(a => a[0] === "subject");
const refPersons = ev.tags.filter(a => a[0] === "p"); const refPersons = ev.tags.filter(a => a[0] === "p");
const link = encodeTLV( const link = NostrLink.fromEvent(ev).encode();
NostrPrefix.Address,
ev.tags.find(a => a[0] === "d")?.[1] ?? "",
undefined,
ev.kind,
ev.pubkey
);
return ( return (
<> <>
<div className="flex zapstr mb10 card"> <div className="flex zapstr mb10 card">

View File

@ -1,11 +1,11 @@
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import { NostrEvent, NostrLink } from "@snort/system"; import { NostrEvent, NostrLink } from "@snort/system";
import { findTag } from "SnortUtils"; import { findTag } from "SnortUtils";
import useEventFeed from "Feed/EventFeed"; import { useEventFeed } from "Feed/EventFeed";
import PageSpinner from "Element/PageSpinner"; import PageSpinner from "Element/PageSpinner";
import Reveal from "Element/Reveal"; import Reveal from "Element/Event/Reveal";
import { MediaElement } from "Element/MediaElement"; import { MediaElement } from "Element/Embed/MediaElement";
export default function NostrFileHeader({ link }: { link: NostrLink }) { export default function NostrFileHeader({ link }: { link: NostrLink }) {
const ev = useEventFeed(link); const ev = useEventFeed(link);

View File

@ -2,7 +2,7 @@
min-height: 110px; min-height: 110px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 12px; gap: 16px;
} }
.note:hover { .note:hover {
@ -65,6 +65,7 @@
border: 1px solid var(--gray-superdark); border: 1px solid var(--gray-superdark);
border-radius: 12px; border-radius: 12px;
padding: 8px 16px 16px 16px; padding: 8px 16px 16px 16px;
margin-top: 16px;
} }
.note .footer .footer-reactions { .note .footer .footer-reactions {
@ -163,10 +164,6 @@
min-height: unset; min-height: unset;
} }
.hidden-note button {
max-height: 30px;
}
.expand-note { .expand-note {
padding: 0 0 16px 0; padding: 0 0 16px 0;
font-weight: 400; font-weight: 400;

View File

@ -3,15 +3,14 @@ import React, { useMemo, useState, ReactNode } from "react";
import { useNavigate, Link } from "react-router-dom"; import { useNavigate, Link } from "react-router-dom";
import { useInView } from "react-intersection-observer"; import { useInView } from "react-intersection-observer";
import { useIntl, FormattedMessage } from "react-intl"; import { useIntl, FormattedMessage } from "react-intl";
import { TaggedNostrEvent, HexKey, EventKind, NostrPrefix, Lists, EventExt, parseZap } from "@snort/system"; import { TaggedNostrEvent, HexKey, EventKind, NostrPrefix, Lists, EventExt, parseZap, NostrLink } from "@snort/system";
import { System } from "index"; import { System } from "index";
import useEventPublisher from "Feed/EventPublisher"; import useEventPublisher from "Hooks/useEventPublisher";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import ProfileImage from "Element/ProfileImage"; import ProfileImage from "Element/User/ProfileImage";
import Text from "Element/Text"; import Text from "Element/Text";
import { import {
eventLink,
getReactions, getReactions,
dedupeByPubkey, dedupeByPubkey,
tagFilterOfTextRepost, tagFilterOfTextRepost,
@ -21,23 +20,26 @@ import {
profileLink, profileLink,
findTag, findTag,
} from "SnortUtils"; } from "SnortUtils";
import NoteFooter from "Element/NoteFooter"; import NoteFooter from "Element/Event/NoteFooter";
import NoteTime from "Element/NoteTime"; import NoteTime from "Element/Event/NoteTime";
import Reveal from "Element/Reveal"; import Reveal from "Element/Event/Reveal";
import useModeration from "Hooks/useModeration"; import useModeration from "Hooks/useModeration";
import { UserCache } from "Cache"; import { UserCache } from "Cache";
import Poll from "Element/Poll"; import Poll from "Element/Event/Poll";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import { setBookmarked, setPinned } from "Login"; import { setBookmarked, setPinned } from "Login";
import { NostrFileElement } from "Element/NostrFileHeader"; import { NostrFileElement } from "Element/Event/NostrFileHeader";
import ZapstrEmbed from "Element/ZapstrEmbed"; import ZapstrEmbed from "Element/Embed/ZapstrEmbed";
import PubkeyList from "Element/PubkeyList"; import PubkeyList from "Element/Embed/PubkeyList";
import { LiveEvent } from "Element/LiveEvent"; import { LiveEvent } from "Element/LiveEvent";
import { NoteContextMenu, NoteTranslation } from "Element/NoteContextMenu"; import { NoteContextMenu, NoteTranslation } from "Element/Event/NoteContextMenu";
import Reactions from "Element/Reactions"; import Reactions from "Element/Event/Reactions";
import { ZapGoal } from "Element/ZapGoal"; import { ZapGoal } from "Element/Event/ZapGoal";
import NoteReaction from "Element/Event/NoteReaction";
import ProfilePreview from "Element/User/ProfilePreview";
import { ProxyImg } from "Element/ProxyImg";
import messages from "./messages"; import messages from "../messages";
export interface NoteProps { export interface NoteProps {
data: TaggedNostrEvent; data: TaggedNostrEvent;
@ -60,20 +62,21 @@ export interface NoteProps {
canUnpin?: boolean; canUnpin?: boolean;
canUnbookmark?: boolean; canUnbookmark?: boolean;
canClick?: boolean; canClick?: boolean;
showMediaSpotlight?: boolean;
}; };
} }
const HiddenNote = ({ children }: { children: React.ReactNode }) => { const HiddenNote = ({ children }: { children: React.ReactNode }) => {
const [show, setShow] = useState(false); const [show, setShow] = useState(false);
return show ? ( return show ? (
<>{children}</> children
) : ( ) : (
<div className="card note hidden-note"> <div className="card note hidden-note">
<div className="header"> <div className="header">
<p> <p>
<FormattedMessage {...messages.MutedAuthor} /> <FormattedMessage defaultMessage="This note has been muted" />
</p> </p>
<button onClick={() => setShow(true)}> <button type="button" onClick={() => setShow(true)}>
<FormattedMessage {...messages.Show} /> <FormattedMessage {...messages.Show} />
</button> </button>
</div> </div>
@ -82,8 +85,10 @@ const HiddenNote = ({ children }: { children: React.ReactNode }) => {
}; };
export default function Note(props: NoteProps) { export default function Note(props: NoteProps) {
const { data: ev, related, highlight, options: opt, ignoreModeration = false, className } = props; const { data: ev, className } = props;
if (ev.kind === EventKind.Repost) {
return <NoteReaction data={ev} key={ev.id} root={undefined} depth={(props.depth ?? 0) + 1} />;
}
if (ev.kind === EventKind.FileHeader) { if (ev.kind === EventKind.FileHeader) {
return <NostrFileElement ev={ev} />; return <NostrFileElement ev={ev} />;
} }
@ -96,16 +101,24 @@ export default function Note(props: NoteProps) {
if (ev.kind === EventKind.LiveEvent) { if (ev.kind === EventKind.LiveEvent) {
return <LiveEvent ev={ev} />; return <LiveEvent ev={ev} />;
} }
if (ev.kind === EventKind.SetMetadata) {
return <ProfilePreview actions={<></>} pubkey={ev.pubkey} className="card" />;
}
if (ev.kind === (9041 as EventKind)) { if (ev.kind === (9041 as EventKind)) {
return <ZapGoal ev={ev} />; return <ZapGoal ev={ev} />;
} }
return <NoteInner {...props} />;
}
export function NoteInner(props: NoteProps) {
const { data: ev, related, highlight, options: opt, ignoreModeration = false, className } = props;
const baseClassName = `note card${className ? ` ${className}` : ""}`; const baseClassName = `note card${className ? ` ${className}` : ""}`;
const navigate = useNavigate(); const navigate = useNavigate();
const [showReactions, setShowReactions] = useState(false); const [showReactions, setShowReactions] = useState(false);
const deletions = useMemo(() => getReactions(related, ev.id, EventKind.Deletion), [related]); const deletions = useMemo(() => getReactions(related, ev.id, EventKind.Deletion), [related]);
const { isMuted } = useModeration(); const { isEventMuted } = useModeration();
const isOpMuted = isMuted(ev?.pubkey);
const { ref, inView } = useInView({ triggerOnce: true }); const { ref, inView } = useInView({ triggerOnce: true });
const login = useLogin(); const login = useLogin();
const { pinned, bookmarked } = login; const { pinned, bookmarked } = login;
@ -123,7 +136,7 @@ export default function Note(props: NoteProps) {
{ {
[Reaction.Positive]: [] as TaggedNostrEvent[], [Reaction.Positive]: [] as TaggedNostrEvent[],
[Reaction.Negative]: [] as TaggedNostrEvent[], [Reaction.Negative]: [] as TaggedNostrEvent[],
} },
); );
return { return {
[Reaction.Positive]: dedupeByPubkey(result[Reaction.Positive]), [Reaction.Positive]: dedupeByPubkey(result[Reaction.Positive]),
@ -138,7 +151,7 @@ export default function Note(props: NoteProps) {
...getReactions(related, ev.id, EventKind.TextNote).filter(e => e.tags.some(tagFilterOfTextRepost(e, ev.id))), ...getReactions(related, ev.id, EventKind.TextNote).filter(e => e.tags.some(tagFilterOfTextRepost(e, ev.id))),
...getReactions(related, ev.id, EventKind.Repost), ...getReactions(related, ev.id, EventKind.Repost),
]), ]),
[related, ev] [related, ev],
); );
const zaps = useMemo(() => { const zaps = useMemo(() => {
const sortedZaps = getReactions(related, ev.id, EventKind.ZapReceipt) const sortedZaps = getReactions(related, ev.id, EventKind.ZapReceipt)
@ -181,8 +194,49 @@ export default function Note(props: NoteProps) {
} }
} }
const innerContent = () => {
if (ev.kind === EventKind.LongFormTextNote) {
const title = findTag(ev, "title");
const summary = findTag(ev, "simmary");
const image = findTag(ev, "image");
return (
<div className="long-form-note">
<h3>{title}</h3>
<div className="text">
<p>{summary}</p>
<Text
id={ev.id}
content={ev.content}
highlighText={props.searchedValue}
tags={ev.tags}
creator={ev.pubkey}
depth={props.depth}
truncate={255}
disableLinkPreview={true}
disableMediaSpotlight={!(props.options?.showMediaSpotlight ?? true)}
/>
{image && <ProxyImg src={image} />}
</div>
</div>
);
} else {
const body = ev?.content ?? "";
return (
<Text
id={ev.id}
highlighText={props.searchedValue}
content={body}
tags={ev.tags}
creator={ev.pubkey}
depth={props.depth}
disableMedia={!(options.showMedia ?? true)}
disableMediaSpotlight={!(props.options?.showMediaSpotlight ?? true)}
/>
);
}
};
const transformBody = () => { const transformBody = () => {
const body = ev?.content ?? "";
if (deletions?.length > 0) { if (deletions?.length > 0) {
return ( return (
<b className="error"> <b className="error">
@ -196,40 +250,39 @@ export default function Note(props: NoteProps) {
<Reveal <Reveal
message={ message={
<> <>
<FormattedMessage defaultMessage="This note has been marked as sensitive, click here to reveal" /> <FormattedMessage
defaultMessage="The author has marked this note as a <i>sensitive topic</i>"
values={{
i: c => <i>{c}</i>,
}}
/>
{contentWarning[1] && ( {contentWarning[1] && (
<> <>
<br /> &nbsp;
<FormattedMessage <FormattedMessage
defaultMessage="Reason: {reason}" defaultMessage="Reason: <i>{reason}</i>"
values={{ values={{
i: c => <i>{c}</i>,
reason: contentWarning[1], reason: contentWarning[1],
}} }}
/> />
</> </>
)} )}
&nbsp;
<FormattedMessage defaultMessage="Click here to load anyway" />
</> </>
}> }>
<Text highlighText={props.searchedValue} content={body} tags={ev.tags} creator={ev.pubkey} /> {innerContent()}
</Reveal> </Reveal>
); );
} }
return ( return innerContent();
<Text
highlighText={props.searchedValue}
content={body}
tags={ev.tags}
creator={ev.pubkey}
depth={props.depth}
disableMedia={!(options.showMedia ?? true)}
/>
);
}; };
function goToEvent( function goToEvent(
e: React.MouseEvent, e: React.MouseEvent,
eTarget: TaggedNostrEvent, eTarget: TaggedNostrEvent,
isTargetAllowed: boolean = e.target === e.currentTarget isTargetAllowed: boolean = e.target === e.currentTarget,
) { ) {
if (!isTargetAllowed || opt?.canClick === false) { if (!isTargetAllowed || opt?.canClick === false) {
return; return;
@ -241,13 +294,13 @@ export default function Note(props: NoteProps) {
return; return;
} }
const link = eventLink(eTarget.id, eTarget.relays); const link = NostrLink.fromEvent(eTarget);
// detect cmd key and open in new tab // detect cmd key and open in new tab
if (e.metaKey) { if (e.metaKey) {
window.open(link, "_blank"); window.open(`/e/${link.encode()}`, "_blank");
} else { } else {
navigate(link, { navigate(`/e/${link.encode()}`, {
state: ev, state: eTarget,
}); });
} }
} }
@ -259,8 +312,12 @@ export default function Note(props: NoteProps) {
} }
const maxMentions = 2; const maxMentions = 2;
const replyId = thread?.replyTo?.value ?? thread?.root?.value; const replyTo = thread?.replyTo ?? thread?.root;
const replyRelayHints = thread?.replyTo?.relay ?? thread.root?.relay; const replyLink = replyTo
? NostrLink.fromTag(
[replyTo.key, replyTo.value ?? "", replyTo.relay ?? "", replyTo.marker ?? ""].filter(a => a.length > 0),
)
: undefined;
const mentions: { pk: string; name: string; link: ReactNode }[] = []; const mentions: { pk: string; name: string; link: ReactNode }[] = [];
for (const pk of thread?.pubKeys ?? []) { for (const pk of thread?.pubKeys ?? []) {
const u = UserCache.getFromCache(pk); const u = UserCache.getFromCache(pk);
@ -293,23 +350,19 @@ export default function Note(props: NoteProps) {
{pubMentions} {others} {pubMentions} {others}
</> </>
) : ( ) : (
replyId && ( replyLink && <Link to={`/e/${replyLink.encode()}`}>{replyLink.encode().substring(0, 12)}</Link>
<Link to={eventLink(replyId, replyRelayHints)}>
{hexToBech32(NostrPrefix.Event, replyId)?.substring(0, 12)}
</Link>
)
)} )}
</div> </div>
); );
} }
const canRenderAsTextNote = [EventKind.TextNote, EventKind.Polls]; const canRenderAsTextNote = [EventKind.TextNote, EventKind.Polls, EventKind.LongFormTextNote];
if (!canRenderAsTextNote.includes(ev.kind)) { if (!canRenderAsTextNote.includes(ev.kind)) {
const alt = findTag(ev, "alt"); const alt = findTag(ev, "alt");
if (alt) { if (alt) {
return ( return (
<div className="note-quote"> <div className="note-quote">
<Text content={alt} tags={[]} creator={ev.pubkey} /> <Text id={ev.id} content={alt} tags={[]} creator={ev.pubkey} />
</div> </div>
); );
} else { } else {
@ -418,5 +471,5 @@ export default function Note(props: NoteProps) {
</div> </div>
); );
return !ignoreModeration && isOpMuted ? <HiddenNote>{note}</HiddenNote> : note; return !ignoreModeration && isEventMuted(ev) ? <HiddenNote>{note}</HiddenNote> : note;
} }

View File

@ -1,23 +1,17 @@
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import { HexKey, Lists, NostrPrefix, TaggedNostrEvent, encodeTLV } from "@snort/system"; import { HexKey, Lists, NostrLink, TaggedNostrEvent } from "@snort/system";
import { Menu, MenuItem } from "@szhsin/react-menu"; import { Menu, MenuItem } from "@szhsin/react-menu";
import { useDispatch, useSelector } from "react-redux";
import { TranslateHost } from "Const"; import { TranslateHost } from "Const";
import { System } from "index"; import { System } from "index";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { setPinned, setBookmarked } from "Login"; import { setPinned, setBookmarked } from "Login";
import {
setNote as setReBroadcastNote,
setShow as setReBroadcastShow,
reset as resetReBroadcast,
} from "State/ReBroadcast";
import messages from "Element/messages"; import messages from "Element/messages";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import useModeration from "Hooks/useModeration"; import useModeration from "Hooks/useModeration";
import useEventPublisher from "Feed/EventPublisher"; import useEventPublisher from "Hooks/useEventPublisher";
import { RootState } from "State/Store"; import { ReBroadcaster } from "../ReBroadcaster";
import { ReBroadcaster } from "./ReBroadcaster"; import { useState } from "react";
export interface NoteTranslation { export interface NoteTranslation {
text: string; text: string;
@ -33,20 +27,16 @@ interface NosteContextMenuProps {
} }
export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) { export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
const dispatch = useDispatch();
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const login = useLogin(); const login = useLogin();
const { pinned, bookmarked, publicKey, preferences: prefs } = login;
const { mute, block } = useModeration(); const { mute, block } = useModeration();
const publisher = useEventPublisher(); const publisher = useEventPublisher();
const showReBroadcastModal = useSelector((s: RootState) => s.reBroadcast.show); const [showBroadcast, setShowBroadcast] = useState(false);
const reBroadcastNote = useSelector((s: RootState) => s.reBroadcast.note);
const willRenderReBroadcast = showReBroadcastModal && reBroadcastNote && reBroadcastNote?.id === ev.id;
const lang = window.navigator.language; const lang = window.navigator.language;
const langNames = new Intl.DisplayNames([...window.navigator.languages], { const langNames = new Intl.DisplayNames([...window.navigator.languages], {
type: "language", type: "language",
}); });
const isMine = ev.pubkey === publicKey; const isMine = ev.pubkey === login.publicKey;
async function deleteEvent() { async function deleteEvent() {
if (window.confirm(formatMessage(messages.ConfirmDeletion, { id: ev.id.substring(0, 8) })) && publisher) { if (window.confirm(formatMessage(messages.ConfirmDeletion, { id: ev.id.substring(0, 8) })) && publisher) {
@ -56,7 +46,7 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
} }
async function share() { async function share() {
const link = encodeTLV(NostrPrefix.Event, ev.id, ev.relays); const link = NostrLink.fromEvent(ev).encode();
const url = `${window.location.protocol}//${window.location.host}/e/${link}`; const url = `${window.location.protocol}//${window.location.host}/e/${link}`;
if ("share" in window.navigator) { if ("share" in window.navigator) {
await window.navigator.share({ await window.navigator.share({
@ -92,13 +82,13 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
} }
async function copyId() { async function copyId() {
const link = encodeTLV(NostrPrefix.Event, ev.id, ev.relays); const link = NostrLink.fromEvent(ev).encode();
await navigator.clipboard.writeText(link); await navigator.clipboard.writeText(link);
} }
async function pin(id: HexKey) { async function pin(id: HexKey) {
if (publisher) { if (publisher) {
const es = [...pinned.item, id]; const es = [...login.pinned.item, id];
const ev = await publisher.noteList(es, Lists.Pinned); const ev = await publisher.noteList(es, Lists.Pinned);
System.BroadcastEvent(ev); System.BroadcastEvent(ev);
setPinned(login, es, ev.created_at * 1000); setPinned(login, es, ev.created_at * 1000);
@ -107,7 +97,7 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
async function bookmark(id: HexKey) { async function bookmark(id: HexKey) {
if (publisher) { if (publisher) {
const es = [...bookmarked.item, id]; const es = [...login.bookmarked.item, id];
const ev = await publisher.noteList(es, Lists.Bookmarked); const ev = await publisher.noteList(es, Lists.Bookmarked);
System.BroadcastEvent(ev); System.BroadcastEvent(ev);
setBookmarked(login, es, ev.created_at * 1000); setBookmarked(login, es, ev.created_at * 1000);
@ -119,12 +109,7 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
} }
const handleReBroadcastButtonClick = () => { const handleReBroadcastButtonClick = () => {
if (reBroadcastNote?.id !== ev.id) { setShowBroadcast(true);
dispatch(resetReBroadcast());
}
dispatch(setReBroadcastNote(ev));
dispatch(setReBroadcastShow(!showReBroadcastModal));
}; };
function menuItems() { function menuItems() {
@ -145,13 +130,13 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
<Icon name="share" /> <Icon name="share" />
<FormattedMessage {...messages.Share} /> <FormattedMessage {...messages.Share} />
</MenuItem> </MenuItem>
{!pinned.item.includes(ev.id) && ( {!login.pinned.item.includes(ev.id) && !login.readonly && (
<MenuItem onClick={() => pin(ev.id)}> <MenuItem onClick={() => pin(ev.id)}>
<Icon name="pin" /> <Icon name="pin" />
<FormattedMessage {...messages.Pin} /> <FormattedMessage {...messages.Pin} />
</MenuItem> </MenuItem>
)} )}
{!bookmarked.item.includes(ev.id) && ( {!login.bookmarked.item.includes(ev.id) && !login.readonly && (
<MenuItem onClick={() => bookmark(ev.id)}> <MenuItem onClick={() => bookmark(ev.id)}>
<Icon name="bookmark" /> <Icon name="bookmark" />
<FormattedMessage {...messages.Bookmark} /> <FormattedMessage {...messages.Bookmark} />
@ -161,23 +146,23 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
<Icon name="copy" /> <Icon name="copy" />
<FormattedMessage {...messages.CopyID} /> <FormattedMessage {...messages.CopyID} />
</MenuItem> </MenuItem>
<MenuItem onClick={() => mute(ev.pubkey)}> {!login.readonly && (
<Icon name="mute" /> <MenuItem onClick={() => mute(ev.pubkey)}>
<FormattedMessage {...messages.Mute} /> <Icon name="mute" />
</MenuItem> <FormattedMessage {...messages.Mute} />
{prefs.enableReactions && ( </MenuItem>
)}
{login.preferences.enableReactions && !login.readonly && (
<MenuItem onClick={() => props.react("-")}> <MenuItem onClick={() => props.react("-")}>
<Icon name="dislike" /> <Icon name="dislike" />
<FormattedMessage {...messages.DislikeAction} /> <FormattedMessage {...messages.DislikeAction} />
</MenuItem> </MenuItem>
)} )}
{ev.pubkey === publicKey && ( <MenuItem onClick={handleReBroadcastButtonClick}>
<MenuItem onClick={handleReBroadcastButtonClick}> <Icon name="relay" />
<Icon name="relay" /> <FormattedMessage defaultMessage="Broadcast Event" />
<FormattedMessage {...messages.ReBroadcast} /> </MenuItem>
</MenuItem> {ev.pubkey !== login.publicKey && !login.readonly && (
)}
{ev.pubkey !== publicKey && (
<MenuItem onClick={() => block(ev.pubkey)}> <MenuItem onClick={() => block(ev.pubkey)}>
<Icon name="block" /> <Icon name="block" />
<FormattedMessage {...messages.Block} /> <FormattedMessage {...messages.Block} />
@ -187,13 +172,13 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
<Icon name="translate" /> <Icon name="translate" />
<FormattedMessage {...messages.TranslateTo} values={{ lang: langNames.of(lang.split("-")[0]) }} /> <FormattedMessage {...messages.TranslateTo} values={{ lang: langNames.of(lang.split("-")[0]) }} />
</MenuItem> </MenuItem>
{prefs.showDebugMenus && ( {login.preferences.showDebugMenus && (
<MenuItem onClick={() => copyEvent()}> <MenuItem onClick={() => copyEvent()}>
<Icon name="json" /> <Icon name="json" />
<FormattedMessage {...messages.CopyJSON} /> <FormattedMessage {...messages.CopyJSON} />
</MenuItem> </MenuItem>
)} )}
{isMine && ( {isMine && !login.readonly && (
<MenuItem onClick={() => deleteEvent()}> <MenuItem onClick={() => deleteEvent()}>
<Icon name="trash" className="red" /> <Icon name="trash" className="red" />
<FormattedMessage {...messages.Delete} /> <FormattedMessage {...messages.Delete} />
@ -214,7 +199,7 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
menuClassName="ctx-menu"> menuClassName="ctx-menu">
{menuItems()} {menuItems()}
</Menu> </Menu>
{willRenderReBroadcast && <ReBroadcaster />} {showBroadcast && <ReBroadcaster ev={ev} onClose={() => setShowBroadcast(false)} />}
</> </>
); );
} }

View File

@ -2,18 +2,25 @@
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 12px; border-radius: 12px;
box-shadow: 0px 0px 6px 1px rgba(182, 108, 156, 0.3); box-shadow: 0px 0px 6px 1px rgba(182, 108, 156, 0.3);
background: linear-gradient(var(--gray-superdark), var(--gray-superdark)) padding-box, background:
linear-gradient(var(--gray-superdark), var(--gray-superdark)) padding-box,
linear-gradient(90deg, #ef9644, #fd7c49, #ff5e58, #ff3b70, #ff088e, #eb00b1, #c31ed5, #7b41f6) border-box; linear-gradient(90deg, #ef9644, #fd7c49, #ff5e58, #ff3b70, #ff088e, #eb00b1, #c31ed5, #7b41f6) border-box;
} }
.note-creator-modal .modal-body { .note-creator-modal .modal-body > div {
display: flex;
flex-direction: column;
gap: 16px; gap: 16px;
} }
.note-creator-modal .note.card { .note-creator-modal .note.card {
padding: 0;
border: none;
}
.note-creator-modal .note.card.note-quote {
border: 1px solid var(--gray);
padding: 8px 12px; padding: 8px 12px;
border-radius: 12px;
background-color: var(--gray-dark);
} }
.note-creator-modal h4 { .note-creator-modal h4 {
@ -80,13 +87,13 @@
.note-create-button { .note-create-button {
width: 48px; width: 48px;
height: 48px; height: 48px;
background-color: var(--highlight);
color: white; color: white;
background: linear-gradient(90deg, rgba(239, 150, 68, 1) 0%, rgba(123, 65, 246, 1) 100%);
border: none; border: none;
border-radius: 100%; border-radius: 100%;
position: fixed; position: fixed;
bottom: 50px; bottom: 40px;
right: calc(((100vw - 640px) / 2) - 60px); right: calc(((100vw - 640px) / 2) - 75px);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -97,3 +104,14 @@
right: 16px; right: 16px;
} }
} }
.light .note-creator textarea {
background-color: #fff;
}
.light .note-creator {
box-shadow: 0px 0px 6px 1px rgba(182, 108, 156, 0.3);
background:
linear-gradient(var(--gray-superdark), var(--gray-superdark)) padding-box,
linear-gradient(90deg, #ef9644, #fd7c49, #ff5e58, #ff3b70, #ff088e, #eb00b1, #c31ed5, #7b41f6) border-box;
}

View File

@ -0,0 +1,512 @@
import "./NoteCreator.css";
import { FormattedMessage, useIntl } from "react-intl";
import {
EventKind,
NostrPrefix,
TaggedNostrEvent,
EventBuilder,
tryParseNostrLink,
NostrLink,
NostrEvent,
} from "@snort/system";
import Icon from "Icons/Icon";
import useEventPublisher from "Hooks/useEventPublisher";
import { openFile } from "SnortUtils";
import Textarea from "Element/Textarea";
import Modal from "Element/Modal";
import ProfileImage from "Element/User/ProfileImage";
import useFileUpload from "Upload";
import Note from "Element/Event/Note";
import { ClipboardEventHandler } from "react";
import useLogin from "Hooks/useLogin";
import { System, WasmPowWorker } from "index";
import AsyncButton from "Element/AsyncButton";
import { AsyncIcon } from "Element/AsyncIcon";
import { fetchNip05Pubkey } from "@snort/shared";
import { ZapTarget } from "Zapper";
import { useNoteCreator } from "State/NoteCreator";
export function NoteCreator() {
const { formatMessage } = useIntl();
const uploader = useFileUpload();
const login = useLogin(s => ({ relays: s.relays, publicKey: s.publicKey, pow: s.preferences.pow }));
const publisher = login.pow ? useEventPublisher()?.pow(login.pow, new WasmPowWorker()) : useEventPublisher();
const note = useNoteCreator();
const relays = login.relays;
async function buildNote() {
try {
note.update(v => (v.error = ""));
if (note && publisher) {
let extraTags: Array<Array<string>> | undefined;
if (note.zapSplits) {
const parsedSplits = [] as Array<ZapTarget>;
for (const s of note.zapSplits) {
if (s.value.startsWith(NostrPrefix.PublicKey) || s.value.startsWith(NostrPrefix.Profile)) {
const link = tryParseNostrLink(s.value);
if (link) {
parsedSplits.push({ ...s, value: link.id });
} else {
throw new Error(
formatMessage(
{
defaultMessage: "Failed to parse zap split: {input}",
},
{
input: s.value,
},
),
);
}
} else if (s.value.includes("@")) {
const [name, domain] = s.value.split("@");
const pubkey = await fetchNip05Pubkey(name, domain);
if (pubkey) {
parsedSplits.push({ ...s, value: pubkey });
} else {
throw new Error(
formatMessage(
{
defaultMessage: "Failed to parse zap split: {input}",
},
{
input: s.value,
},
),
);
}
} else {
throw new Error(
formatMessage(
{
defaultMessage: "Invalid zap split: {input}",
},
{
input: s.value,
},
),
);
}
}
extraTags = parsedSplits.map(v => ["zap", v.value, "", String(v.weight)]);
}
if (note.sensitive) {
extraTags ??= [];
extraTags.push(["content-warning", note.sensitive]);
}
const kind = note.pollOptions ? EventKind.Polls : EventKind.TextNote;
if (note.pollOptions) {
extraTags ??= [];
extraTags.push(...note.pollOptions.map((a, i) => ["poll_option", i.toString(), a]));
}
const hk = (eb: EventBuilder) => {
extraTags?.forEach(t => eb.tag(t));
eb.kind(kind);
return eb;
};
const ev = note.replyTo
? await publisher.reply(note.replyTo, note.note, hk)
: await publisher.note(note.note, hk);
return ev;
}
} catch (e) {
note.update(v => {
if (e instanceof Error) {
v.error = e.message;
} else {
v.error = e as string;
}
});
}
}
async function sendEventToRelays(ev: NostrEvent) {
if (note.selectedCustomRelays) {
await Promise.all(note.selectedCustomRelays.map(r => System.WriteOnceToRelay(r, ev)));
} else {
System.BroadcastEvent(ev);
}
}
async function sendNote() {
const ev = await buildNote();
if (ev) {
await sendEventToRelays(ev);
for (const oe of note.otherEvents ?? []) {
await sendEventToRelays(oe);
}
note.update(v => {
v.reset();
v.show = false;
});
}
}
async function attachFile() {
try {
const file = await openFile();
if (file) {
uploadFile(file);
}
} catch (e) {
note.update(v => {
if (e instanceof Error) {
v.error = e.message;
} else {
v.error = e as string;
}
});
}
}
async function uploadFile(file: File | Blob) {
try {
if (file) {
const rx = await uploader.upload(file, file.name);
note.update(v => {
if (rx.header) {
const link = `nostr:${new NostrLink(NostrPrefix.Event, rx.header.id, rx.header.kind).encode()}`;
v.note = `${v.note ? `${v.note}\n` : ""}${link}`;
v.otherEvents = [...(v.otherEvents ?? []), rx.header];
} else if (rx.url) {
v.note = `${v.note ? `${v.note}\n` : ""}${rx.url}`;
} else if (rx?.error) {
v.error = rx.error;
}
});
}
} catch (e) {
note.update(v => {
if (e instanceof Error) {
v.error = e.message;
} else {
v.error = e as string;
}
});
}
}
function onChange(ev: React.ChangeEvent<HTMLTextAreaElement>) {
const { value } = ev.target;
note.update(n => (n.note = value));
}
function cancel() {
note.update(v => {
v.show = false;
v.reset();
});
}
async function onSubmit(ev: React.MouseEvent<HTMLButtonElement>) {
ev.stopPropagation();
await sendNote();
}
async function loadPreview() {
if (note.preview) {
note.update(v => (v.preview = undefined));
} else if (publisher) {
const tmpNote = await buildNote();
note.update(v => (v.preview = tmpNote));
}
}
function getPreviewNote() {
if (note.preview) {
return (
<Note
data={note.preview as TaggedNostrEvent}
related={[]}
options={{
showContextMenu: false,
showFooter: false,
canClick: false,
showTime: false,
}}
/>
);
}
}
function renderPollOptions() {
if (note.pollOptions) {
return (
<>
<h4>
<FormattedMessage defaultMessage="Poll Options" />
</h4>
{note.pollOptions?.map((a, i) => (
<div className="form-group w-max" key={`po-${i}`}>
<div>
<FormattedMessage defaultMessage="Option: {n}" values={{ n: i + 1 }} />
</div>
<div>
<input type="text" value={a} onChange={e => changePollOption(i, e.target.value)} />
{i > 1 && (
<button onClick={() => removePollOption(i)} className="ml5">
<Icon name="close" size={14} />
</button>
)}
</div>
</div>
))}
<button onClick={() => note.update(v => (v.pollOptions = [...(note.pollOptions ?? []), ""]))}>
<Icon name="plus" size={14} />
</button>
</>
);
}
}
function changePollOption(i: number, v: string) {
if (note.pollOptions) {
const copy = [...note.pollOptions];
copy[i] = v;
note.update(v => (v.pollOptions = copy));
}
}
function removePollOption(i: number) {
if (note.pollOptions) {
const copy = [...note.pollOptions];
copy.splice(i, 1);
note.update(v => (v.pollOptions = copy));
}
}
function renderRelayCustomisation() {
return (
<div className="flex-column g8">
{Object.keys(relays.item || {})
.filter(el => relays.item[el].write)
.map((r, i, a) => (
<div className="p flex f-space note-creator-relay">
<div>{r}</div>
<div>
<input
type="checkbox"
checked={!note.selectedCustomRelays || note.selectedCustomRelays.includes(r)}
onChange={e => {
note.update(
v =>
(v.selectedCustomRelays =
// set false if all relays selected
e.target.checked &&
note.selectedCustomRelays &&
note.selectedCustomRelays.length == a.length - 1
? undefined
: // otherwise return selectedCustomRelays with target relay added / removed
a.filter(el =>
el === r
? e.target.checked
: !note.selectedCustomRelays || note.selectedCustomRelays.includes(el),
)),
);
}}
/>
</div>
</div>
))}
</div>
);
}
/*function listAccounts() {
return LoginStore.getSessions().map(a => (
<MenuItem
onClick={ev => {
ev.stopPropagation = true;
LoginStore.switchAccount(a);
}}>
<ProfileImage pubkey={a} link={""} />
</MenuItem>
));
}*/
const handlePaste: ClipboardEventHandler<HTMLDivElement> = evt => {
if (evt.clipboardData) {
const clipboardItems = evt.clipboardData.items;
const items: DataTransferItem[] = Array.from(clipboardItems).filter(function (item: DataTransferItem) {
// Filter the image items only
return /^image\//.test(item.type);
});
if (items.length === 0) {
return;
}
const item = items[0];
const blob = item.getAsFile();
if (blob) {
uploadFile(blob);
}
}
};
if (!note.show) return null;
return (
<Modal id="note-creator" className="note-creator-modal" onClose={() => note.update(v => (v.show = false))}>
{note.replyTo && (
<Note
data={note.replyTo}
related={[]}
options={{
showFooter: false,
showContextMenu: false,
showTime: false,
canClick: false,
showMedia: false,
}}
/>
)}
{note.preview && getPreviewNote()}
{!note.preview && (
<div onPaste={handlePaste} className={`note-creator${note.pollOptions ? " poll" : ""}`}>
<Textarea
autoFocus
className={`textarea ${note.active ? "textarea--focused" : ""}`}
onChange={c => onChange(c)}
value={note.note}
onFocus={() => note.update(v => (v.active = true))}
onKeyDown={e => {
if (e.key === "Enter" && e.metaKey) {
sendNote().catch(console.warn);
}
}}
/>
{renderPollOptions()}
</div>
)}
<div className="flex f-space">
<div className="flex g8">
<ProfileImage
pubkey={login.publicKey ?? ""}
className="note-creator-icon"
link=""
showUsername={false}
showFollowingMark={false}
/>
{note.pollOptions === undefined && !note.replyTo && (
<div className="note-creator-icon">
<Icon name="pie-chart" onClick={() => note.update(v => (v.pollOptions = ["A", "B"]))} size={24} />
</div>
)}
<AsyncIcon iconName="image-plus" iconSize={24} onClick={attachFile} className="note-creator-icon" />
<button className="secondary" onClick={() => note.update(v => (v.advanced = !v.advanced))}>
<FormattedMessage defaultMessage="Advanced" />
</button>
</div>
<div className="flex g8">
<button className="secondary" onClick={cancel}>
<FormattedMessage defaultMessage="Cancel" />
</button>
<AsyncButton onClick={onSubmit}>
{note.replyTo ? <FormattedMessage defaultMessage="Reply" /> : <FormattedMessage defaultMessage="Send" />}
</AsyncButton>
</div>
</div>
{note.error && <span className="error">{note.error}</span>}
{note.advanced && (
<>
<button className="secondary" onClick={loadPreview}>
<FormattedMessage defaultMessage="Toggle Preview" />
</button>
<div>
<h4>
<FormattedMessage defaultMessage="Custom Relays" />
</h4>
<p>
<FormattedMessage defaultMessage="Send note to a subset of your write relays" />
</p>
{renderRelayCustomisation()}
</div>
<div className="flex-column g8">
<h4>
<FormattedMessage defaultMessage="Zap Splits" />
</h4>
<FormattedMessage defaultMessage="Zaps on this note will be split to the following users." />
<div className="flex-column g8">
{[...(note.zapSplits ?? [])].map((v, i, arr) => (
<div className="flex f-center g8">
<div className="flex-column f-4 g4">
<h4>
<FormattedMessage defaultMessage="Recipient" />
</h4>
<input
type="text"
value={v.value}
onChange={e =>
note.update(
v => (v.zapSplits = arr.map((vv, ii) => (ii === i ? { ...vv, value: e.target.value } : vv))),
)
}
placeholder={formatMessage({ defaultMessage: "npub / nprofile / nostr address" })}
/>
</div>
<div className="flex-column f-1 g4">
<h4>
<FormattedMessage defaultMessage="Weight" />
</h4>
<input
type="number"
min={0}
value={v.weight}
onChange={e =>
note.update(
v =>
(v.zapSplits = arr.map((vv, ii) =>
ii === i ? { ...vv, weight: Number(e.target.value) } : vv,
)),
)
}
/>
</div>
<div className="flex-column f-shrink g4">
<div>&nbsp;</div>
<Icon
name="close"
onClick={() => note.update(v => (v.zapSplits = (v.zapSplits ?? []).filter((_v, ii) => ii !== i)))}
/>
</div>
</div>
))}
<button
type="button"
onClick={() =>
note.update(v => (v.zapSplits = [...(v.zapSplits ?? []), { type: "pubkey", value: "", weight: 1 }]))
}>
<FormattedMessage defaultMessage="Add" />
</button>
</div>
<span className="warning">
<FormattedMessage defaultMessage="Not all clients support this, you may still receive some zaps as if zap splits was not configured" />
</span>
</div>
<div className="flex-column g8">
<h4>
<FormattedMessage defaultMessage="Sensitive Content" />
</h4>
<FormattedMessage defaultMessage="Users must accept the content warning to show the content of your note." />
<input
className="w-max"
type="text"
value={note.sensitive}
onChange={e => note.update(v => (v.sensitive = e.target.value))}
maxLength={50}
minLength={1}
placeholder={formatMessage({
defaultMessage: "Reason",
})}
/>
<span className="warning">
<FormattedMessage defaultMessage="Not all clients support this yet" />
</span>
</div>
</>
)}
</Modal>
);
}

View File

@ -1,19 +1,15 @@
import React, { HTMLProps, useEffect, useState } from "react"; import React, { HTMLProps, useContext, useEffect, useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { useIntl } from "react-intl"; import { useIntl } from "react-intl";
import { useLongPress } from "use-long-press"; import { useLongPress } from "use-long-press";
import { TaggedNostrEvent, HexKey, u256, ParsedZap, countLeadingZeros } from "@snort/system"; import { TaggedNostrEvent, ParsedZap, countLeadingZeros, NostrLink } from "@snort/system";
import { LNURL } from "@snort/shared"; import { SnortContext, useUserProfile } from "@snort/system-react";
import { useUserProfile } from "@snort/system-react";
import { formatShort } from "Number"; import { formatShort } from "Number";
import useEventPublisher from "Feed/EventPublisher"; import useEventPublisher from "Hooks/useEventPublisher";
import { delay, findTag, normalizeReaction, unwrap } from "SnortUtils"; import { delay, findTag, normalizeReaction } from "SnortUtils";
import { NoteCreator } from "Element/NoteCreator"; import { NoteCreator } from "Element/Event/NoteCreator";
import SendSats from "Element/SendSats"; import SendSats from "Element/SendSats";
import { ZapsSummary } from "Element/Zap"; import { ZapsSummary } from "Element/Event/Zap";
import { RootState } from "State/Store";
import { setReplyTo, setShow, reset } from "State/NoteCreator";
import { AsyncIcon } from "Element/AsyncIcon"; import { AsyncIcon } from "Element/AsyncIcon";
import { useWallet } from "Wallet"; import { useWallet } from "Wallet";
@ -21,8 +17,11 @@ import useLogin from "Hooks/useLogin";
import { useInteractionCache } from "Hooks/useInteractionCache"; import { useInteractionCache } from "Hooks/useInteractionCache";
import { ZapPoolController } from "ZapPoolController"; import { ZapPoolController } from "ZapPoolController";
import { System } from "index"; import { System } from "index";
import { Zapper, ZapTarget } from "Zapper";
import { getDisplayName } from "../User/ProfileImage";
import { useNoteCreator } from "State/NoteCreator";
import messages from "./messages"; import messages from "../messages";
let isZapperBusy = false; let isZapperBusy = false;
const barrierZapper = async <T,>(then: () => Promise<T>): Promise<T> => { const barrierZapper = async <T,>(then: () => Promise<T>): Promise<T> => {
@ -46,21 +45,24 @@ export interface NoteFooterProps {
export default function NoteFooter(props: NoteFooterProps) { export default function NoteFooter(props: NoteFooterProps) {
const { ev, positive, reposts, zaps } = props; const { ev, positive, reposts, zaps } = props;
const dispatch = useDispatch(); const system = useContext(SnortContext);
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const login = useLogin(); const {
const { publicKey, preferences: prefs, relays } = login; publicKey,
preferences: prefs,
readonly,
} = useLogin(s => ({ preferences: s.preferences, publicKey: s.publicKey, readonly: s.readonly }));
const author = useUserProfile(ev.pubkey); const author = useUserProfile(ev.pubkey);
const interactionCache = useInteractionCache(publicKey, ev.id); const interactionCache = useInteractionCache(publicKey, ev.id);
const publisher = useEventPublisher(); const publisher = useEventPublisher();
const showNoteCreatorModal = useSelector((s: RootState) => s.noteCreator.show); const note = useNoteCreator(n => ({ show: n.show, replyTo: n.replyTo, update: n.update }));
const replyTo = useSelector((s: RootState) => s.noteCreator.replyTo); const willRenderNoteCreator = note.show && note.replyTo?.id === ev.id;
const willRenderNoteCreator = showNoteCreatorModal && replyTo?.id === ev.id;
const [tip, setTip] = useState(false); const [tip, setTip] = useState(false);
const [zapping, setZapping] = useState(false); const [zapping, setZapping] = useState(false);
const walletState = useWallet(); const walletState = useWallet();
const wallet = walletState.wallet; const wallet = walletState.wallet;
const canFastZap = wallet?.isReady() && !readonly;
const isMine = ev.pubkey === publicKey; const isMine = ev.pubkey === publicKey;
const zapTotal = zaps.reduce((acc, z) => acc + z.amount, 0); const zapTotal = zaps.reduce((acc, z) => acc + z.amount, 0);
const didZap = interactionCache.data.zapped || zaps.some(a => a.sender === publicKey); const didZap = interactionCache.data.zapped || zaps.some(a => a.sender === publicKey);
@ -71,7 +73,7 @@ export default function NoteFooter(props: NoteFooterProps) {
}, },
{ {
captureEvent: true, captureEvent: true,
} },
); );
function hasReacted(emoji: string) { function hasReacted(emoji: string) {
@ -103,27 +105,36 @@ export default function NoteFooter(props: NoteFooterProps) {
} }
} }
function getLNURL() { function getZapTarget(): Array<ZapTarget> | undefined {
return ev.tags.find(a => a[0] === "zap")?.[1] || author?.lud16 || author?.lud06; if (ev.tags.some(v => v[0] === "zap")) {
} return Zapper.fromEvent(ev);
}
function getTargetName() { const authorTarget = author?.lud16 || author?.lud06;
const zapTarget = ev.tags.find(a => a[0] === "zap")?.[1]; if (authorTarget) {
if (zapTarget) { return [
return new LNURL(zapTarget).name; {
} else { type: "lnurl",
return author?.display_name || author?.name; value: authorTarget,
weight: 1,
name: getDisplayName(author, ev.pubkey),
zap: {
pubkey: ev.pubkey,
event: NostrLink.fromEvent(ev),
},
} as ZapTarget,
];
} }
} }
async function fastZap(e?: React.MouseEvent) { async function fastZap(e?: React.MouseEvent) {
if (zapping || e?.isPropagationStopped()) return; if (zapping || e?.isPropagationStopped()) return;
const lnurl = getLNURL(); const lnurl = getZapTarget();
if (wallet?.isReady() && lnurl) { if (canFastZap && lnurl) {
setZapping(true); setZapping(true);
try { try {
await fastZapInner(lnurl, prefs.defaultZapAmount, ev.pubkey, ev.id); await fastZapInner(lnurl, prefs.defaultZapAmount);
} catch (e) { } catch (e) {
console.warn("Fast zap failed", e); console.warn("Fast zap failed", e);
if (!(e instanceof Error) || e.message !== "User rejected") { if (!(e instanceof Error) || e.message !== "User rejected") {
@ -137,30 +148,29 @@ export default function NoteFooter(props: NoteFooterProps) {
} }
} }
async function fastZapInner(lnurl: string, amount: number, key: HexKey, id?: u256) { async function fastZapInner(targets: Array<ZapTarget>, amount: number) {
// only allow 1 invoice req/payment at a time to avoid hitting rate limits if (wallet) {
await barrierZapper(async () => { // only allow 1 invoice req/payment at a time to avoid hitting rate limits
const handler = new LNURL(lnurl); await barrierZapper(async () => {
await handler.load(); const zapper = new Zapper(system, publisher);
const result = await zapper.send(wallet, targets, amount);
const zr = Object.keys(relays.item); const totalSent = result.reduce((acc, v) => (acc += v.sent), 0);
const zap = handler.canZap && publisher ? await publisher.zap(amount * 1000, key, zr, id) : undefined; if (totalSent > 0) {
const invoice = await handler.getInvoice(amount, undefined, zap); ZapPoolController.allocate(totalSent);
await wallet?.payInvoice(unwrap(invoice.pr)); await interactionCache.zap();
ZapPoolController.allocate(amount); }
});
await interactionCache.zap(); }
});
} }
useEffect(() => { useEffect(() => {
if (prefs.autoZap && !didZap && !isMine && !zapping) { if (prefs.autoZap && !didZap && !isMine && !zapping) {
const lnurl = getLNURL(); const lnurl = getZapTarget();
if (wallet?.isReady() && lnurl) { if (wallet?.isReady() && lnurl) {
setZapping(true); setZapping(true);
queueMicrotask(async () => { queueMicrotask(async () => {
try { try {
await fastZapInner(lnurl, prefs.defaultZapAmount, ev.pubkey, ev.id); await fastZapInner(lnurl, prefs.defaultZapAmount);
} catch { } catch {
// ignored // ignored
} finally { } finally {
@ -181,14 +191,14 @@ export default function NoteFooter(props: NoteFooterProps) {
} }
function tipButton() { function tipButton() {
const service = getLNURL(); const targets = getZapTarget();
if (service) { if (targets) {
return ( return (
<AsyncFooterIcon <AsyncFooterIcon
className={didZap ? "reacted" : ""} className={didZap ? "reacted" : ""}
{...longPress()} {...longPress()}
title={formatMessage({ defaultMessage: "Zap" })} title={formatMessage({ defaultMessage: "Zap" })}
iconName={wallet?.isReady() ? "zapFast" : "zap"} iconName={canFastZap ? "zapFast" : "zap"}
value={zapTotal} value={zapTotal}
onClick={e => fastZap(e)} onClick={e => fastZap(e)}
/> />
@ -198,13 +208,17 @@ export default function NoteFooter(props: NoteFooterProps) {
} }
function repostIcon() { function repostIcon() {
if (readonly) return;
return ( return (
<AsyncFooterIcon <AsyncFooterIcon
className={hasReposted() ? "reacted" : ""} className={hasReposted() ? "reacted" : ""}
iconName="repeat" iconName="repeat"
title={formatMessage({ defaultMessage: "Repost" })} title={formatMessage({ defaultMessage: "Repost" })}
value={reposts.length} value={reposts.length}
onClick={() => repost()} onClick={async () => {
if (readonly) return;
await repost();
}}
/> />
); );
} }
@ -220,15 +234,19 @@ export default function NoteFooter(props: NoteFooterProps) {
iconName={reacted ? "heart-solid" : "heart"} iconName={reacted ? "heart-solid" : "heart"}
title={formatMessage({ defaultMessage: "Like" })} title={formatMessage({ defaultMessage: "Like" })}
value={positive.length} value={positive.length}
onClick={() => react(prefs.reactionEmoji)} onClick={async () => {
if (readonly) return;
await react(prefs.reactionEmoji);
}}
/> />
); );
} }
function replyIcon() { function replyIcon() {
if (readonly) return;
return ( return (
<AsyncFooterIcon <AsyncFooterIcon
className={showNoteCreatorModal ? "reacted" : ""} className={note.show ? "reacted" : ""}
iconName="reply" iconName="reply"
title={formatMessage({ defaultMessage: "Reply" })} title={formatMessage({ defaultMessage: "Reply" })}
value={0} value={0}
@ -238,34 +256,27 @@ export default function NoteFooter(props: NoteFooterProps) {
} }
const handleReplyButtonClick = () => { const handleReplyButtonClick = () => {
if (replyTo?.id !== ev.id) { note.update(v => {
dispatch(reset()); if (v.replyTo?.id !== ev.id) {
} v.reset();
}
dispatch(setReplyTo(ev)); v.show = true;
dispatch(setShow(!showNoteCreatorModal)); v.replyTo = ev;
});
}; };
return ( return (
<> <>
<div className="footer"> <div className="footer">
<div className="footer-reactions"> <div className="footer-reactions">
{tipButton()}
{reactionIcon()}
{repostIcon()}
{replyIcon()} {replyIcon()}
{repostIcon()}
{reactionIcon()}
{tipButton()}
{powIcon()} {powIcon()}
</div> </div>
{willRenderNoteCreator && <NoteCreator />} {willRenderNoteCreator && <NoteCreator key={`note-creator-${ev.id}`} />}
<SendSats <SendSats targets={getZapTarget()} onClose={() => setTip(false)} show={tip} note={ev.id} allocatePool={true} />
lnurl={getLNURL()}
onClose={() => setTip(false)}
show={tip}
author={author?.pubkey}
target={getTargetName()}
note={ev.id}
allocatePool={true}
/>
</div> </div>
<ZapsSummary zaps={zaps} /> <ZapsSummary zaps={zaps} />
</> </>

View File

@ -1,5 +1,5 @@
import "./Note.css"; import "./Note.css";
import ProfileImage from "Element/ProfileImage"; import ProfileImage from "Element/User/ProfileImage";
interface NoteGhostProps { interface NoteGhostProps {
className?: string; className?: string;

View File

@ -1,6 +1,6 @@
import useEventFeed from "Feed/EventFeed"; import { useEventFeed } from "Feed/EventFeed";
import { NostrLink } from "@snort/system"; import { NostrLink } from "@snort/system";
import Note from "Element/Note"; import Note from "Element/Event/Note";
import PageSpinner from "Element/PageSpinner"; import PageSpinner from "Element/PageSpinner";
export default function NoteQuote({ link, depth }: { link: NostrLink; depth?: number }) { export default function NoteQuote({ link, depth }: { link: NostrLink; depth?: number }) {

View File

@ -1,24 +1,27 @@
import "./NoteReaction.css"; import "./NoteReaction.css";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useMemo } from "react"; import { useMemo } from "react";
import { EventKind, NostrEvent, TaggedNostrEvent, NostrPrefix } from "@snort/system"; import { EventKind, NostrEvent, TaggedNostrEvent, NostrPrefix, EventExt } from "@snort/system";
import Note from "Element/Note"; import Note from "Element/Event/Note";
import { getDisplayName } from "Element/ProfileImage"; import { getDisplayName } from "Element/User/ProfileImage";
import { eventLink, hexToBech32 } from "SnortUtils"; import { eventLink, hexToBech32 } from "SnortUtils";
import useModeration from "Hooks/useModeration"; import useModeration from "Hooks/useModeration";
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { useUserProfile } from "@snort/system-react"; import { useUserProfile } from "@snort/system-react";
import { useInView } from "react-intersection-observer";
export interface NoteReactionProps { export interface NoteReactionProps {
data: TaggedNostrEvent; data: TaggedNostrEvent;
root?: TaggedNostrEvent; root?: TaggedNostrEvent;
depth?: number;
} }
export default function NoteReaction(props: NoteReactionProps) { export default function NoteReaction(props: NoteReactionProps) {
const { data: ev } = props; const { data: ev } = props;
const { isMuted } = useModeration(); const { isMuted } = useModeration();
const profile = useUserProfile(ev.pubkey); const { inView, ref } = useInView({ triggerOnce: true });
const profile = useUserProfile(inView ? ev.pubkey : "");
const refEvent = useMemo(() => { const refEvent = useMemo(() => {
if (ev) { if (ev) {
@ -43,9 +46,15 @@ export default function NoteReaction(props: NoteReactionProps) {
* Some clients embed the reposted note in the content * Some clients embed the reposted note in the content
*/ */
function extractRoot() { function extractRoot() {
if (!inView) return null;
if (ev?.kind === EventKind.Repost && ev.content.length > 0 && ev.content !== "#[0]") { if (ev?.kind === EventKind.Repost && ev.content.length > 0 && ev.content !== "#[0]") {
try { try {
const r: NostrEvent = JSON.parse(ev.content); const r: NostrEvent = JSON.parse(ev.content);
EventExt.fixupEvent(r);
if (!EventExt.verify(r)) {
console.debug("Event in repost is invalid");
return undefined;
}
return r as TaggedNostrEvent; return r as TaggedNostrEvent;
} catch (e) { } catch (e) {
console.error("Could not load reposted content", e); console.error("Could not load reposted content", e);
@ -54,7 +63,11 @@ export default function NoteReaction(props: NoteReactionProps) {
return props.root; return props.root;
} }
const root = extractRoot(); const root = useMemo(() => extractRoot(), [ev, props.root, inView]);
if (!inView) {
return <div className="card reaction" ref={ref}></div>;
}
const isOpMuted = root && isMuted(root.pubkey); const isOpMuted = root && isMuted(root.pubkey);
const shouldNotBeRendered = isOpMuted || root?.kind !== EventKind.TextNote; const shouldNotBeRendered = isOpMuted || root?.kind !== EventKind.TextNote;
const opt = { const opt = {
@ -73,7 +86,7 @@ export default function NoteReaction(props: NoteReactionProps) {
}} }}
/> />
</div> </div>
{root ? <Note data={root} options={opt} related={[]} /> : null} {root ? <Note data={root} options={opt} related={[]} depth={props.depth} /> : null}
{!root && refEvent ? ( {!root && refEvent ? (
<p> <p>
<Link to={eventLink(refEvent[1] ?? "", refEvent[2])}> <Link to={eventLink(refEvent[1] ?? "", refEvent[2])}>

View File

@ -4,8 +4,7 @@ import { useState } from "react";
import { FormattedMessage, FormattedNumber, useIntl } from "react-intl"; import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
import { useUserProfile } from "@snort/system-react"; import { useUserProfile } from "@snort/system-react";
import Text from "Element/Text"; import useEventPublisher from "Hooks/useEventPublisher";
import useEventPublisher from "Feed/EventPublisher";
import { useWallet } from "Wallet"; import { useWallet } from "Wallet";
import { unwrap } from "SnortUtils"; import { unwrap } from "SnortUtils";
import { formatShort } from "Number"; import { formatShort } from "Number";
@ -18,12 +17,15 @@ interface PollProps {
zaps: Array<ParsedZap>; zaps: Array<ParsedZap>;
} }
type PollTally = "zaps" | "pubkeys";
export default function Poll(props: PollProps) { export default function Poll(props: PollProps) {
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const publisher = useEventPublisher(); const publisher = useEventPublisher();
const { wallet } = useWallet(); const { wallet } = useWallet();
const { preferences: prefs, publicKey: myPubKey, relays } = useLogin(); const { preferences: prefs, publicKey: myPubKey, relays } = useLogin();
const pollerProfile = useUserProfile(props.ev.pubkey); const pollerProfile = useUserProfile(props.ev.pubkey);
const [tallyBy, setTallyBy] = useState<PollTally>("pubkeys");
const [error, setError] = useState(""); const [error, setError] = useState("");
const [invoice, setInvoice] = useState(""); const [invoice, setInvoice] = useState("");
const [voting, setVoting] = useState<number>(); const [voting, setVoting] = useState<number>();
@ -31,7 +33,10 @@ export default function Poll(props: PollProps) {
const isMyPoll = props.ev.pubkey === myPubKey; const isMyPoll = props.ev.pubkey === myPubKey;
const showResults = didVote || isMyPoll; const showResults = didVote || isMyPoll;
const options = props.ev.tags.filter(a => a[0] === "poll_option").sort((a, b) => Number(a[1]) - Number(b[1])); const options = props.ev.tags
.filter(a => a[0] === "poll_option")
.sort((a, b) => (Number(a[1]) > Number(b[1]) ? 1 : -1));
async function zapVote(ev: React.MouseEvent, opt: number) { async function zapVote(ev: React.MouseEvent, opt: number) {
ev.stopPropagation(); ev.stopPropagation();
if (voting || !publisher) return; if (voting || !publisher) return;
@ -46,15 +51,15 @@ export default function Poll(props: PollProps) {
}, },
{ {
amount, amount,
} },
) ),
); );
} }
setVoting(opt); setVoting(opt);
const r = Object.keys(relays.item); const r = Object.keys(relays.item);
const zap = await publisher.zap(amount * 1000, props.ev.pubkey, r, props.ev.id, undefined, eb => const zap = await publisher.zap(amount * 1000, props.ev.pubkey, r, props.ev.id, undefined, eb =>
eb.tag(["poll_option", opt.toString()]) eb.tag(["poll_option", opt.toString()]),
); );
const lnurl = props.ev.tags.find(a => a[0] === "zap")?.[1] || pollerProfile?.lud16 || pollerProfile?.lud06; const lnurl = props.ev.tags.find(a => a[0] === "zap")?.[1] || pollerProfile?.lud16 || pollerProfile?.lud06;
@ -67,7 +72,7 @@ export default function Poll(props: PollProps) {
throw new Error( throw new Error(
formatMessage({ formatMessage({
defaultMessage: "Can't vote because LNURL service does not support zaps", defaultMessage: "Can't vote because LNURL service does not support zaps",
}) }),
); );
} }
@ -84,7 +89,7 @@ export default function Poll(props: PollProps) {
setError( setError(
formatMessage({ formatMessage({
defaultMessage: "Failed to send vote", defaultMessage: "Failed to send vote",
}) }),
); );
} }
} finally { } finally {
@ -92,33 +97,57 @@ export default function Poll(props: PollProps) {
} }
} }
const allTotal = props.zaps.filter(a => a.pollOption !== undefined).reduce((acc, v) => (acc += v.amount), 0); const totalVotes = (() => {
switch (tallyBy) {
case "zaps":
return props.zaps.filter(a => a.pollOption !== undefined).reduce((acc, v) => (acc += v.amount), 0);
case "pubkeys":
return new Set(props.zaps.filter(a => a.pollOption !== undefined).map(a => unwrap(a.sender))).size;
}
})();
return ( return (
<> <>
<small> <div className="flex f-space p">
<FormattedMessage <small>
defaultMessage="You are voting with {amount} sats" <FormattedMessage
values={{ defaultMessage="You are voting with {amount} sats"
amount: formatShort(prefs.defaultZapAmount), values={{
}} amount: formatShort(prefs.defaultZapAmount),
/> }}
</small> />
</small>
<button type="button" onClick={() => setTallyBy(s => (s !== "zaps" ? "zaps" : "pubkeys"))}>
<FormattedMessage
defaultMessage="Votes by {type}"
values={{
type:
tallyBy === "zaps" ? (
<FormattedMessage defaultMessage="zap" />
) : (
<FormattedMessage defaultMessage="user" />
),
}}
/>
</button>
</div>
<div className="poll-body"> <div className="poll-body">
{options.map(a => { {options.map(a => {
const opt = Number(a[1]); const opt = Number(a[1]);
const desc = a[2]; const desc = a[2];
const zapsOnOption = props.zaps.filter(b => b.pollOption === opt); const zapsOnOption = props.zaps.filter(b => b.pollOption === opt);
const total = zapsOnOption.reduce((acc, v) => (acc += v.amount), 0); const total = (() => {
const weight = allTotal === 0 ? 0 : total / allTotal; switch (tallyBy) {
case "zaps":
return zapsOnOption.reduce((acc, v) => (acc += v.amount), 0);
case "pubkeys":
return new Set(zapsOnOption.map(a => unwrap(a.sender))).size;
}
})();
const weight = totalVotes === 0 ? 0 : total / totalVotes;
return ( return (
<div key={a[1]} className="flex" onClick={e => zapVote(e, opt)}> <div key={a[1]} className="flex" onClick={e => zapVote(e, opt)}>
<div className="f-grow"> <div className="f-grow">{opt === voting ? <Spinner /> : <>{desc}</>}</div>
{opt === voting ? (
<Spinner />
) : (
<Text content={desc} tags={props.ev.tags} creator={props.ev.pubkey} disableMediaSpotlight={true} />
)}
</div>
{showResults && ( {showResults && (
<> <>
<div className="flex"> <div className="flex">

View File

@ -29,11 +29,31 @@
color: var(--font-tertiary-color); color: var(--font-tertiary-color);
} }
.reactions-modal .modal-body .tabs.p {
padding: 12px 0;
}
.reactions-modal .modal-body .reactions-header { .reactions-modal .modal-body .reactions-header {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
margin-bottom: 32px; margin-bottom: 12px;
}
.reactions-modal .modal-body .tab {
background: none;
border: none;
}
.reactions-modal .modal-body .tab.active {
background: #fff;
color: #000;
}
.reactions-modal .modal-body .tab:hover {
background: rgba(255, 255, 255, 0.8);
color: #000;
border: none;
} }
.reactions-modal .modal-body .reactions-header h2 { .reactions-modal .modal-body .reactions-header h2 {
@ -47,8 +67,11 @@
.reactions-modal .modal-body .reactions-body { .reactions-modal .modal-body .reactions-body {
overflow: scroll; overflow: scroll;
height: 40vh; height: 40vh;
-ms-overflow-style: none; /* for Internet Explorer, Edge */ -ms-overflow-style: none;
scrollbar-width: none; /* Firefox */ /* for Internet Explorer, Edge */
scrollbar-width: none;
/* Firefox */
margin-top: 12px;
} }
.reactions-modal .modal-body .reactions-body::-webkit-scrollbar { .reactions-modal .modal-body .reactions-body::-webkit-scrollbar {

View File

@ -7,11 +7,11 @@ import { TaggedNostrEvent, ParsedZap } from "@snort/system";
import { formatShort } from "Number"; import { formatShort } from "Number";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { Tab } from "Element/Tabs"; import { Tab } from "Element/Tabs";
import ProfileImage from "Element/ProfileImage"; import ProfileImage from "Element/User/ProfileImage";
import Tabs from "Element/Tabs"; import Tabs from "Element/Tabs";
import Modal from "Element/Modal"; import Modal from "Element/Modal";
import messages from "./messages"; import messages from "../messages";
interface ReactionsProps { interface ReactionsProps {
show: boolean; show: boolean;
@ -60,7 +60,7 @@ const Reactions = ({ show, setShow, positive, negative, reposts, zaps }: Reactio
value: 3, value: 3,
}, },
] ]
: [] : [],
); );
const [tab, setTab] = useState(tabs[0]); const [tab, setTab] = useState(tabs[0]);
@ -72,7 +72,7 @@ const Reactions = ({ show, setShow, positive, negative, reposts, zaps }: Reactio
}, [show]); }, [show]);
return show ? ( return show ? (
<Modal className="reactions-modal" onClose={onClose}> <Modal id="reactions" className="reactions-modal" onClose={onClose}>
<div className="close" onClick={onClose}> <div className="close" onClick={onClose}>
<Icon name="close" /> <Icon name="close" />
</div> </div>

View File

@ -1,3 +1,5 @@
import "../Reveal.css";
import Icon from "Icons/Icon";
import { useState } from "react"; import { useState } from "react";
interface RevealProps { interface RevealProps {
@ -15,8 +17,9 @@ export default function Reveal(props: RevealProps): JSX.Element {
e.stopPropagation(); e.stopPropagation();
setReveal(true); setReveal(true);
}} }}
className="note-invoice"> className="note-notice flex g8">
{props.message} <Icon name="alert-circle" size={24} />
<div>{props.message}</div>
</div> </div>
); );
} else { } else {

View File

@ -1,9 +1,10 @@
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import { FileExtensionRegex } from "Const"; import { FileExtensionRegex } from "Const";
import Reveal from "Element/Reveal"; import Reveal from "Element/Event/Reveal";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import { MediaElement } from "Element/MediaElement"; import { MediaElement } from "Element/Embed/MediaElement";
import { Link } from "react-router-dom";
interface RevealMediaProps { interface RevealMediaProps {
creator: string; creator: string;
@ -51,7 +52,16 @@ export default function RevealMedia(props: RevealMediaProps) {
if (hideMedia) { if (hideMedia) {
return ( return (
<Reveal <Reveal
message={<FormattedMessage defaultMessage="Click to load content from {link}" values={{ link: hostname }} />}> message={
<FormattedMessage
defaultMessage="You don't follow this person, click here to load media from <i>{link}</i>, or update <a><i>your preferences</i></a> to always load media from everybody."
values={{
i: i => <i>{i}</i>,
a: a => <Link to="/settings/preferences">{a}</Link>,
link: hostname,
}}
/>
}>
<MediaElement mime={`${type}/${extension}`} url={url.toString()} onMediaClick={props.onMediaClick} /> <MediaElement mime={`${type}/${extension}`} url={url.toString()} onMediaClick={props.onMediaClick} />
</Reveal> </Reveal>
); );

View File

@ -1,7 +1,7 @@
import "./ShowMore.css"; import "./ShowMore.css";
import { useIntl } from "react-intl"; import { useIntl } from "react-intl";
import messages from "./messages"; import messages from "../messages";
interface ShowMoreProps { interface ShowMoreProps {
text?: string; text?: string;

View File

@ -8,7 +8,8 @@
} }
.thread-root.note > .body .text { .thread-root.note > .body .text {
font-size: 19px; font-size: 18px;
line-height: 27px;
} }
.thread-root.note > .footer { .thread-root.note > .footer {
@ -55,54 +56,46 @@
position: absolute; position: absolute;
left: calc(48px / 2 + 16px); left: calc(48px / 2 + 16px);
top: 48px; top: 48px;
border-left: 1px solid var(--gray-superdark); border-left: 1px solid var(--border-color);
height: 100%; height: 100%;
z-index: -1; z-index: 1;
} }
.subthread-container.subthread-mid:not(.subthread-last) .line-container:before { .subthread-container.subthread-mid:not(.subthread-last) .line-container:before {
content: ""; content: "";
position: absolute; position: absolute;
border-left: 1px solid var(--gray-superdark); border-left: 1px solid var(--border-color);
left: calc(48px / 2 + 16px); left: calc(48px / 2 + 16px);
top: 0; top: 0;
height: 48px; height: 48px;
z-index: -1; z-index: 1;
} }
.subthread-container.subthread-last .line-container:before { .subthread-container.subthread-last .line-container:before {
content: ""; content: "";
position: absolute; position: absolute;
border-left: 1px solid var(--gray-superdark); border-left: 1px solid var(--border-color);
left: calc(48px / 2 + 16px); left: calc(48px / 2 + 16px);
top: 0; top: 0;
height: 48px; height: 48px;
z-index: -1; z-index: 1;
}
.divider-container {
margin-right: 16px;
} }
.divider { .divider {
height: 1px; height: 1px;
background: var(--gray-superdark); background: var(--border-color);
} }
.divider.divider-small { .divider.divider-small {
margin-left: calc(16px + 61px); margin-left: calc(16px + 61px);
margin-right: 16px;
} }
.thread-container .collapsed, .thread-container .collapsed,
.thread-container .show-more-container { .thread-container .show-more-container {
background: var(--gray-superdark);
min-height: 48px; min-height: 48px;
} }
.thread-container .collapsed {
background-color: var(--gray-superdark);
}
.thread-container .hidden-note { .thread-container .hidden-note {
padding-left: 48px; padding-left: 48px;
} }

View File

@ -1,25 +1,17 @@
import "./Thread.css"; import "./Thread.css";
import { useMemo, useState, ReactNode } from "react"; import { useMemo, useState, ReactNode, useContext } from "react";
import { useIntl } from "react-intl"; import { useIntl } from "react-intl";
import { useNavigate, useLocation, Link, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { import { TaggedNostrEvent, u256, NostrPrefix, EventExt, parseNostrLink } from "@snort/system";
TaggedNostrEvent,
u256,
EventKind,
NostrPrefix,
EventExt,
Thread as ThreadInfo,
parseNostrLink,
} from "@snort/system";
import { eventLink, unwrap, getReactions, getAllReactions, findTag } from "SnortUtils"; import { getReactions, getAllReactions } from "SnortUtils";
import BackButton from "Element/BackButton"; import BackButton from "Element/BackButton";
import Note from "Element/Note"; import Note from "Element/Event/Note";
import NoteGhost from "Element/NoteGhost"; import NoteGhost from "Element/Event/NoteGhost";
import Collapsed from "Element/Collapsed"; import Collapsed from "Element/Collapsed";
import useThreadFeed from "Feed/ThreadFeed"; import { ThreadContext, ThreadContextWrapper, chainKey } from "Hooks/useThreadContext";
import messages from "./messages"; import messages from "../messages";
interface DividerProps { interface DividerProps {
variant?: "regular" | "small"; variant?: "regular" | "small";
@ -213,110 +205,39 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate
); );
}; };
export default function Thread() { export function ThreadRoute() {
const params = useParams(); const params = useParams();
const location = useLocation();
const link = parseNostrLink(params.id ?? "", NostrPrefix.Note); const link = parseNostrLink(params.id ?? "", NostrPrefix.Note);
const thread = useThreadFeed(link);
const [currentId, setCurrentId] = useState(link.id); return (
<ThreadContextWrapper link={link}>
<Thread />
</ThreadContextWrapper>
);
}
export function Thread(props: { onBack?: () => void; disableSpotlight?: boolean }) {
const thread = useContext(ThreadContext);
const navigate = useNavigate(); const navigate = useNavigate();
const isSingleNote = thread.data?.filter(a => a.kind === EventKind.TextNote).length === 1; const isSingleNote = thread.chains?.size === 1 && [thread.chains.values].every(v => v.length === 0);
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
function navigateThread(e: TaggedNostrEvent) { function navigateThread(e: TaggedNostrEvent) {
setCurrentId(e.id); thread.setCurrent(e.id);
//const link = encodeTLV(e.id, NostrPrefix.Event, e.relays); //router.navigate(`/e/${NostrLink.fromEvent(e).encode()}`, { replace: true })
} }
const chains = useMemo(() => {
const chains = new Map<u256, Array<TaggedNostrEvent>>();
if (thread.data) {
thread.data
?.filter(a => a.kind === EventKind.TextNote)
.sort((a, b) => b.created_at - a.created_at)
.forEach(v => {
const t = EventExt.extractThread(v);
let replyTo = t?.replyTo?.value ?? t?.root?.value;
if (t?.root?.key === "a" && t?.root?.value) {
const parsed = t.root.value.split(":");
replyTo = thread.data?.find(
a => a.kind === Number(parsed[0]) && a.pubkey === parsed[1] && findTag(a, "d") === parsed[2]
)?.id;
}
if (replyTo) {
if (!chains.has(replyTo)) {
chains.set(replyTo, [v]);
} else {
unwrap(chains.get(replyTo)).push(v);
}
}
});
}
return chains;
}, [thread.data]);
// Root is the parent of the current note or the current note if its a root note or the root of the thread
const root = useMemo(() => {
const currentNote =
thread.data?.find(
ne =>
ne.id === currentId ||
(link.type === NostrPrefix.Address && findTag(ne, "d") === currentId && ne.pubkey === link.author)
) ?? (location.state && "sig" in location.state ? (location.state as TaggedNostrEvent) : undefined);
if (currentNote) {
const currentThread = EventExt.extractThread(currentNote);
const isRoot = (ne?: ThreadInfo) => ne === undefined;
if (isRoot(currentThread)) {
return currentNote;
}
const replyTo = currentThread?.replyTo ?? currentThread?.root;
// sometimes the root event ID is missing, and we can only take the happy path if the root event ID exists
if (replyTo) {
if (replyTo.key === "a" && replyTo.value) {
const parsed = replyTo.value.split(":");
return thread.data?.find(
a => a.kind === Number(parsed[0]) && a.pubkey === parsed[1] && findTag(a, "d") === parsed[2]
);
}
if (replyTo.value) {
return thread.data?.find(a => a.id === replyTo.value);
}
}
const possibleRoots = thread.data?.filter(a => {
const thread = EventExt.extractThread(a);
return isRoot(thread);
});
if (possibleRoots) {
// worst case we need to check every possible root to see which one contains the current note as a child
for (const ne of possibleRoots) {
const children = chains.get(ne.id) ?? [];
if (children.find(ne => ne.id === currentId)) {
return ne;
}
}
}
}
}, [thread.data, currentId, location]);
const parent = useMemo(() => { const parent = useMemo(() => {
if (root) { if (thread.root) {
const currentThread = EventExt.extractThread(root); const currentThread = EventExt.extractThread(thread.root);
return ( return (
currentThread?.replyTo?.value ?? currentThread?.replyTo?.value ??
currentThread?.root?.value ?? currentThread?.root?.value ??
(currentThread?.root?.key === "a" && currentThread.root?.value) (currentThread?.root?.key === "a" && currentThread.root?.value)
); );
} }
}, [root]); }, [thread.root]);
const brokenChains = Array.from(chains?.keys()).filter(a => !thread.data?.some(b => b.id === a));
function renderRoot(note: TaggedNostrEvent) { function renderRoot(note: TaggedNostrEvent) {
const className = `thread-root${isSingleNote ? " thread-root-single" : ""}`; const className = `thread-root${isSingleNote ? " thread-root-single" : ""}`;
@ -326,8 +247,8 @@ export default function Thread() {
className={className} className={className}
key={note.id} key={note.id}
data={note} data={note}
related={getReactions(thread.data, note.id)} related={getReactions(thread.reactions, note.id)}
options={{ showReactionsLink: true }} options={{ showReactionsLink: true, showMediaSpotlight: !props.disableSpotlight }}
onClick={navigateThread} onClick={navigateThread}
/> />
); );
@ -337,20 +258,20 @@ export default function Thread() {
} }
function renderChain(from: u256): ReactNode { function renderChain(from: u256): ReactNode {
if (!from || !chains) { if (!from || thread.chains.size === 0) {
return; return;
} }
const replies = chains.get(from); const replies = thread.chains.get(from);
if (replies && currentId) { if (replies && thread.current) {
return ( return (
<Subthread <Subthread
active={currentId} active={thread.current}
notes={replies} notes={replies}
related={getAllReactions( related={getAllReactions(
thread.data, thread.reactions,
replies.map(a => a.id) replies.map(a => a.id),
)} )}
chains={chains} chains={thread.chains}
onNavigate={navigateThread} onNavigate={navigateThread}
/> />
); );
@ -359,7 +280,9 @@ export default function Thread() {
function goBack() { function goBack() {
if (parent) { if (parent) {
setCurrentId(parent); thread.setCurrent(parent);
} else if (props.onBack) {
props.onBack();
} else { } else {
navigate(-1); navigate(-1);
} }
@ -373,26 +296,36 @@ export default function Thread() {
defaultMessage: "Back", defaultMessage: "Back",
description: "Navigate back button on threads view", description: "Navigate back button on threads view",
}); });
const debug = window.location.search.includes("debug=true");
return ( return (
<> <>
{debug && (
<div className="main-content p xs">
<h1>Chains</h1>
<pre>
{JSON.stringify(
Object.fromEntries([...thread.chains.entries()].map(([k, v]) => [k, v.map(c => c.id)])),
undefined,
" ",
)}
</pre>
<h1>Current</h1>
<pre>{JSON.stringify(thread.current)}</pre>
<h1>Root</h1>
<pre>{JSON.stringify(thread.root, undefined, " ")}</pre>
<h1>Data</h1>
<pre>{JSON.stringify(thread.data, undefined, " ")}</pre>
<h1>Reactions</h1>
<pre>{JSON.stringify(thread.reactions, undefined, " ")}</pre>
</div>
)}
<div className="main-content p"> <div className="main-content p">
<BackButton onClick={goBack} text={parent ? parentText : backText} /> <BackButton onClick={goBack} text={parent ? parentText : backText} />
</div> </div>
<div className="main-content"> <div className="main-content">
{root && renderRoot(root)} {thread.root && renderRoot(thread.root)}
{root && renderChain(root.id)} {thread.root && renderChain(chainKey(thread.root))}
{brokenChains.length > 0 && <h3>Other replies</h3>}
{brokenChains.map(a => {
return (
<div className="mb10">
<NoteGhost className={`thread-note thread-root ghost-root`} key={a}>
Missing event <Link to={eventLink(a)}>{a.substring(0, 8)}</Link>
</NoteGhost>
{renderChain(a)}
</div>
);
})}
</div> </div>
</> </>
); );

View File

@ -6,30 +6,26 @@ import { FormattedMessage, useIntl } from "react-intl";
import { unwrap } from "SnortUtils"; import { unwrap } from "SnortUtils";
import { formatShort } from "Number"; import { formatShort } from "Number";
import Text from "Element/Text"; import Text from "Element/Text";
import ProfileImage from "Element/ProfileImage"; import ProfileImage from "Element/User/ProfileImage";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import messages from "./messages"; import messages from "../messages";
const Zap = ({ zap, showZapped = true }: { zap: ParsedZap; showZapped?: boolean }) => { const Zap = ({ zap, showZapped = true }: { zap: ParsedZap; showZapped?: boolean }) => {
const { amount, content, sender, valid, receiver } = zap; const { amount, content, sender, valid, receiver } = zap;
const pubKey = useLogin().publicKey; const pubKey = useLogin().publicKey;
return valid && sender ? ( return valid && sender ? (
<div className="zap note card"> <div className="card">
<div className="header"> <div className="flex f-space">
<ProfileImage pubkey={sender} /> <ProfileImage pubkey={sender} />
{receiver !== pubKey && showZapped && <ProfileImage pubkey={unwrap(receiver)} />} {receiver !== pubKey && showZapped && <ProfileImage pubkey={unwrap(receiver)} />}
<div className="amount"> <h3>
<span className="amount-number"> <FormattedMessage {...messages.Sats} values={{ n: formatShort(amount ?? 0) }} />
<FormattedMessage {...messages.Sats} values={{ n: formatShort(amount ?? 0) }} /> </h3>
</span>
</div>
</div> </div>
{(content?.length ?? 0) > 0 && sender && ( {(content?.length ?? 0) > 0 && sender && (
<div className="body"> <Text id={zap.id} creator={sender} content={unwrap(content)} tags={[]} />
<Text creator={sender} content={unwrap(content)} tags={[]} />
</div>
)} )}
</div> </div>
) : null; ) : null;
@ -63,6 +59,7 @@ export const ZapsSummary = ({ zaps }: ZapsSummaryProps) => {
{sender && ( {sender && (
<ProfileImage <ProfileImage
pubkey={anonZap ? "" : sender} pubkey={anonZap ? "" : sender}
showFollowingMark={false}
overrideUsername={anonZap ? formatMessage({ defaultMessage: "Anonymous" }) : undefined} overrideUsername={anonZap ? formatMessage({ defaultMessage: "Anonymous" }) : undefined}
/> />
)} )}

View File

@ -5,6 +5,7 @@ import { useUserProfile } from "@snort/system-react";
import SendSats from "Element/SendSats"; import SendSats from "Element/SendSats";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { ZapTarget } from "Zapper";
const ZapButton = ({ const ZapButton = ({
pubkey, pubkey,
@ -24,16 +25,22 @@ const ZapButton = ({
return ( return (
<> <>
<div className="zap-button flex" onClick={() => setZap(true)}> <button type="button" className="flex g8" onClick={() => setZap(true)}>
<Icon name="zap" className={children ? "mr5" : ""} size={15} /> <Icon name="zap-solid" />
{children} {children}
</div> </button>
<SendSats <SendSats
target={profile?.display_name || profile?.name} targets={[
lnurl={service} {
type: "lnurl",
value: service,
weight: 1,
name: profile?.display_name || profile?.name,
zap: { pubkey: pubkey },
} as ZapTarget,
]}
show={zap} show={zap}
onClose={() => setZap(false)} onClose={() => setZap(false)}
author={pubkey}
note={event} note={event}
/> />
</> </>

View File

@ -1,13 +1,16 @@
import "./ZapGoal.css"; import "./ZapGoal.css";
import { NostrEvent, NostrPrefix, createNostrLink } from "@snort/system"; import { CSSProperties, useState } from "react";
import { NostrEvent, NostrLink } from "@snort/system";
import useZapsFeed from "Feed/ZapsFeed"; import useZapsFeed from "Feed/ZapsFeed";
import { formatShort } from "Number"; import { formatShort } from "Number";
import { findTag } from "SnortUtils"; import { findTag } from "SnortUtils";
import { CSSProperties } from "react"; import Icon from "Icons/Icon";
import ZapButton from "./ZapButton"; import SendSats from "../SendSats";
import { Zapper } from "Zapper";
export function ZapGoal({ ev }: { ev: NostrEvent }) { export function ZapGoal({ ev }: { ev: NostrEvent }) {
const zaps = useZapsFeed(createNostrLink(NostrPrefix.Note, ev.id)); const [zap, setZap] = useState(false);
const zaps = useZapsFeed(NostrLink.fromEvent(ev));
const target = Number(findTag(ev, "amount")); const target = Number(findTag(ev, "amount"));
const amount = zaps.reduce((acc, v) => (acc += v.amount * 1000), 0); const amount = zaps.reduce((acc, v) => (acc += v.amount * 1000), 0);
const progress = 100 * (amount / target); const progress = 100 * (amount / target);
@ -16,7 +19,10 @@ export function ZapGoal({ ev }: { ev: NostrEvent }) {
<div className="zap-goal card"> <div className="zap-goal card">
<div className="flex f-space"> <div className="flex f-space">
<h2>{ev.content}</h2> <h2>{ev.content}</h2>
<ZapButton pubkey={ev.pubkey} event={ev.id} /> <div className="zap-button flex" onClick={() => setZap(true)}>
<Icon name="zap" size={15} />
</div>
<SendSats targets={Zapper.fromEvent(ev)} show={zap} onClose={() => setZap(false)} />
</div> </div>
<div className="flex f-space"> <div className="flex f-space">

View File

@ -1,8 +1,8 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import { useInView } from "react-intersection-observer"; import { useInView } from "react-intersection-observer";
import messages from "./messages"; import messages from "../messages";
export default function LoadMore({ export default function LoadMore({
onLoadMore, onLoadMore,

View File

@ -10,16 +10,16 @@
.latest-notes-fixed { .latest-notes-fixed {
position: fixed; position: fixed;
left: calc(50% - 261px / 2 + 0.5px); left: 45%;
top: 12px; top: 12px;
width: 261px; width: auto;
left: calc(50% - 261px / 2 + 0.5px);
z-index: 42; z-index: 42;
opacity: 0.9; opacity: 0.9;
box-shadow: 0px 0px 15px rgba(78, 0, 255, 0.6); box-shadow: 0px 0px 15px rgba(78, 0, 255, 0.6);
color: white; color: white;
background: var(--highlight); background: var(--highlight);
border-radius: 100px; border-radius: 100px;
border: none;
} }
@media (max-width: 520px) { @media (max-width: 520px) {
@ -36,6 +36,7 @@
margin: 0; margin: 0;
margin-right: -26px; margin-right: -26px;
} }
.latest-notes .pfp:last-of-type { .latest-notes .pfp:last-of-type {
margin-right: -8px; margin-right: -8px;
} }

View File

@ -1,19 +1,15 @@
import "./Timeline.css"; import "./Timeline.css";
import { FormattedMessage } from "react-intl"; import FormattedMessage from "Element/FormattedMessage";
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { useInView } from "react-intersection-observer"; import { useInView } from "react-intersection-observer";
import { TaggedNostrEvent, EventKind, u256, parseZap } from "@snort/system"; import { TaggedNostrEvent, EventKind, u256 } from "@snort/system";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { dedupeByPubkey, findTag, tagFilterOfTextRepost } from "SnortUtils"; import { dedupeByPubkey, findTag } from "SnortUtils";
import ProfileImage from "Element/ProfileImage"; import ProfileImage from "Element/User/ProfileImage";
import useTimelineFeed, { TimelineFeed, TimelineSubject } from "Feed/TimelineFeed"; import useTimelineFeed, { TimelineFeed, TimelineSubject } from "Feed/TimelineFeed";
import Zap from "Element/Zap"; import Note from "Element/Event/Note";
import Note from "Element/Note";
import NoteReaction from "Element/NoteReaction";
import useModeration from "Hooks/useModeration"; import useModeration from "Hooks/useModeration";
import ProfilePreview from "Element/ProfilePreview";
import { UserCache } from "Cache";
import { LiveStreams } from "Element/LiveStreams"; import { LiveStreams } from "Element/LiveStreams";
export interface TimelineProps { export interface TimelineProps {
@ -28,7 +24,7 @@ export interface TimelineProps {
} }
/** /**
* A list of notes by pubkeys * A list of notes by "subject"
*/ */
const Timeline = (props: TimelineProps) => { const Timeline = (props: TimelineProps) => {
const feedOptions = useMemo(() => { const feedOptions = useMemo(() => {
@ -51,7 +47,7 @@ const Timeline = (props: TimelineProps) => {
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true)) ?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
.filter(a => props.ignoreModeration || !isMuted(a.pubkey)); .filter(a => props.ignoreModeration || !isMuted(a.pubkey));
}, },
[props.postsOnly, muted, props.ignoreModeration] [props.postsOnly, muted, props.ignoreModeration],
); );
const mainFeed = useMemo(() => { const mainFeed = useMemo(() => {
@ -64,50 +60,16 @@ const Timeline = (props: TimelineProps) => {
(id: u256) => { (id: u256) => {
return (feed.related ?? []).filter(a => findTag(a, "e") === id); return (feed.related ?? []).filter(a => findTag(a, "e") === id);
}, },
[feed.related] [feed.related],
); );
const liveStreams = useMemo(() => { const liveStreams = useMemo(() => {
return (feed.main ?? []).filter(a => a.kind === EventKind.LiveEvent && findTag(a, "status") === "live"); return (feed.main ?? []).filter(a => a.kind === EventKind.LiveEvent && findTag(a, "status") === "live");
}, [feed]); }, [feed]);
const findRelated = useCallback(
(id?: u256) => {
if (!id) return undefined;
return (feed.related ?? []).find(a => a.id === id);
},
[feed.related]
);
const latestAuthors = useMemo(() => { const latestAuthors = useMemo(() => {
return dedupeByPubkey(latestFeed).map(e => e.pubkey); return dedupeByPubkey(latestFeed).map(e => e.pubkey);
}, [latestFeed]); }, [latestFeed]);
function eventElement(e: TaggedNostrEvent) {
switch (e.kind) {
case EventKind.SetMetadata: {
return <ProfilePreview actions={<></>} pubkey={e.pubkey} className="card" />;
}
case EventKind.Polls:
case EventKind.TextNote: {
const eRef = e.tags.find(tagFilterOfTextRepost(e))?.at(1);
if (eRef) {
return <NoteReaction data={e} key={e.id} root={findRelated(eRef)} />;
}
return (
<Note key={e.id} searchedValue={props.subject.discriminator} data={e} related={relatedFeed(e.id)} ignoreModeration={props.ignoreModeration} depth={0} />
);
}
case EventKind.ZapReceipt: {
const zap = parseZap(e, UserCache);
return zap.event ? null : <Zap zap={zap} key={e.id} />;
}
case EventKind.Reaction:
case EventKind.Repost: {
const eRef = findTag(e, "e");
return <NoteReaction data={e} key={e.id} root={findRelated(eRef)} />;
}
}
}
function onShowLatest(scrollToTop = false) { function onShowLatest(scrollToTop = false) {
feed.showLatest(); feed.showLatest();
if (scrollToTop) { if (scrollToTop) {
@ -144,7 +106,9 @@ const Timeline = (props: TimelineProps) => {
)} )}
</> </>
)} )}
{mainFeed.map(eventElement)} {mainFeed.map(e => (
<Note key={e.id} searchedValue={props.subject.discriminator} data={e} related={relatedFeed(e.id)} ignoreModeration={props.ignoreModeration} depth={0} />
))}
{(props.loadMore === undefined || props.loadMore === true) && ( {(props.loadMore === undefined || props.loadMore === true) && (
<div className="flex f-center"> <div className="flex f-center">
<button type="button" onClick={() => feed.loadMore()}> <button type="button" onClick={() => feed.loadMore()}>

View File

@ -0,0 +1,140 @@
import "./Timeline.css";
import { ReactNode, useCallback, useContext, useMemo, useState, useSyncExternalStore } from "react";
import FormattedMessage from "Element/FormattedMessage";
import { TaggedNostrEvent, EventKind, u256, NostrEvent, NostrLink } from "@snort/system";
import { unixNow } from "@snort/shared";
import { SnortContext } from "@snort/system-react";
import { useInView } from "react-intersection-observer";
import { dedupeByPubkey, findTag, orderDescending } from "SnortUtils";
import Note from "Element/Event/Note";
import useModeration from "Hooks/useModeration";
import { FollowsFeed } from "Cache";
import { LiveStreams } from "Element/LiveStreams";
import { useReactions } from "Feed/Reactions";
import AsyncButton from "../AsyncButton";
import useLogin from "Hooks/useLogin";
import ProfileImage from "Element/User/ProfileImage";
import Icon from "Icons/Icon";
export interface TimelineFollowsProps {
postsOnly: boolean;
liveStreams?: boolean;
noteFilter?: (ev: NostrEvent) => boolean;
noteRenderer?: (ev: NostrEvent) => ReactNode;
noteOnClick?: (ev: NostrEvent) => void;
}
/**
* A list of notes by "subject"
*/
const TimelineFollows = (props: TimelineFollowsProps) => {
const [latest, setLatest] = useState(unixNow());
const feed = useSyncExternalStore(
cb => FollowsFeed.hook(cb, "*"),
() => FollowsFeed.snapshot(),
);
const reactions = useReactions(
"follows-feed-reactions",
feed.map(a => NostrLink.fromEvent(a)),
);
const system = useContext(SnortContext);
const login = useLogin();
const { muted, isMuted } = useModeration();
const { ref, inView } = useInView();
const sortedFeed = useMemo(() => orderDescending(feed), [feed]);
const filterPosts = useCallback(
function <T extends NostrEvent>(nts: Array<T>) {
const a = nts.filter(a => a.kind !== EventKind.LiveEvent);
return a
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
.filter(a => !isMuted(a.pubkey) && login.follows.item.includes(a.pubkey) && (props.noteFilter?.(a) ?? true));
},
[props.postsOnly, muted, login.follows.timestamp],
);
const mainFeed = useMemo(() => {
return filterPosts((sortedFeed ?? []).filter(a => a.created_at <= latest));
}, [sortedFeed, filterPosts, latest, login.follows.timestamp]);
const latestFeed = useMemo(() => {
return filterPosts((sortedFeed ?? []).filter(a => a.created_at > latest));
}, [sortedFeed, latest]);
const relatedFeed = useCallback(
(id: u256) => {
return (reactions?.data ?? []).filter(a => findTag(a, "e") === id);
},
[reactions],
);
const liveStreams = useMemo(() => {
return (sortedFeed ?? []).filter(a => a.kind === EventKind.LiveEvent && findTag(a, "status") === "live");
}, [sortedFeed]);
const latestAuthors = useMemo(() => {
return dedupeByPubkey(latestFeed).map(e => e.pubkey);
}, [latestFeed]);
function onShowLatest(scrollToTop = false) {
setLatest(unixNow());
if (scrollToTop) {
window.scrollTo(0, 0);
}
}
return (
<>
{(props.liveStreams ?? true) && <LiveStreams evs={liveStreams} />}
{latestFeed.length > 0 && (
<>
<div className="card latest-notes" onClick={() => onShowLatest()} ref={ref}>
{latestAuthors.slice(0, 3).map(p => {
return <ProfileImage pubkey={p} showUsername={false} link={""} showFollowingMark={false} />;
})}
<FormattedMessage
defaultMessage="{n} new {n, plural, =1 {note} other {notes}}"
values={{ n: latestFeed.length }}
/>
<Icon name="arrowUp" />
</div>
{!inView && (
<div className="card latest-notes latest-notes-fixed pointer fade-in" onClick={() => onShowLatest(true)}>
{latestAuthors.slice(0, 3).map(p => {
return <ProfileImage pubkey={p} showUsername={false} link={""} showFollowingMark={false} />;
})}
<FormattedMessage
defaultMessage="{n} new {n, plural, =1 {note} other {notes}}"
values={{ n: latestFeed.length }}
/>
<Icon name="arrowUp" />
</div>
)}
</>
)}
{mainFeed.map(
a =>
props.noteRenderer?.(a) ?? (
<Note
data={a as TaggedNostrEvent}
related={relatedFeed(a.id)}
key={a.id}
depth={0}
onClick={props.noteOnClick}
/>
),
)}
<div className="flex f-center p">
<AsyncButton
onClick={async () => {
await FollowsFeed.loadMore(system, login, sortedFeed[sortedFeed.length - 1].created_at);
}}>
<FormattedMessage defaultMessage="Load more" />
</AsyncButton>
</div>
</>
);
};
export default TimelineFollows;

Some files were not shown because too many files have changed in this diff Show More