Init SnortDeck

This commit is contained in:
Kieran 2023-09-07 15:54:25 +01:00
parent 5960a5bf5f
commit a31e30979d
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
30 changed files with 903 additions and 436 deletions

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"/>
</g>
</symbol>
<symbol id="bell-v2" viewBox="0 0 24 24" fill="none">
<symbol id="bell-02" viewBox="0 0 24 24" fill="none">
<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="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,34 @@
<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>
</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>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -0,0 +1,10 @@
import { useArticles } from "Feed/ArticlesFeed";
import { orderDescending } from "SnortUtils";
import Note from "../Note";
export default function Articles() {
const data = useArticles();
return <>
{orderDescending(data.data ?? []).map(a => <Note data={a} key={a.id} related={[]} />)}
</>
}

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,42 @@
import { useUserProfile } from "@snort/system-react";
import Avatar from "Element/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

@ -3,7 +3,7 @@ import React, { useMemo, useState, ReactNode } from "react";
import { useNavigate, Link } from "react-router-dom";
import { useInView } from "react-intersection-observer";
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, tagToNostrLink, createNostrLinkToEvent } from "@snort/system";
import { System } from "index";
import useEventPublisher from "Feed/EventPublisher";
@ -11,7 +11,6 @@ import Icon from "Icons/Icon";
import ProfileImage from "Element/ProfileImage";
import Text from "Element/Text";
import {
eventLink,
getReactions,
dedupeByPubkey,
tagFilterOfTextRepost,
@ -40,6 +39,7 @@ import NoteReaction from "Element/NoteReaction";
import ProfilePreview from "Element/ProfilePreview";
import messages from "./messages";
import { ProxyImg } from "./ProxyImg";
export interface NoteProps {
data: TaggedNostrEvent;
@ -193,8 +193,42 @@ export function NoteInner(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} tags={ev.tags} creator={ev.pubkey} depth={props.depth} truncate={255} disableLinkPreview={true} />
{image && <ProxyImg src={image} />}
</div>
</div>
)
} else {
const body = ev?.content ?? "";
return (
<Text
id={ev.id}
content={body}
tags={ev.tags}
creator={ev.pubkey}
depth={props.depth}
disableMedia={!(options.showMedia ?? true)}
/>
);
}
}
const transformBody = () => {
const body = ev?.content ?? "";
if (deletions?.length > 0) {
return (
<b className="error">
@ -222,20 +256,11 @@ export function NoteInner(props: NoteProps) {
)}
</>
}>
<Text id={ev.id} content={body} tags={ev.tags} creator={ev.pubkey} />
{innerContent()}
</Reveal>
);
}
return (
<Text
id={ev.id}
content={body}
tags={ev.tags}
creator={ev.pubkey}
depth={props.depth}
disableMedia={!(options.showMedia ?? true)}
/>
);
return innerContent();
};
function goToEvent(
@ -253,13 +278,13 @@ export function NoteInner(props: NoteProps) {
return;
}
const link = eventLink(eTarget.id, eTarget.relays);
const link = createNostrLinkToEvent(eTarget);
// detect cmd key and open in new tab
if (e.metaKey) {
window.open(link, "_blank");
window.open(`/e/${link.encode()}`, "_blank");
} else {
navigate(link, {
state: ev,
navigate(`/e/${link.encode()}`, {
state: eTarget,
});
}
}
@ -271,8 +296,8 @@ export function NoteInner(props: NoteProps) {
}
const maxMentions = 2;
const replyId = thread?.replyTo?.value ?? thread?.root?.value;
const replyRelayHints = thread?.replyTo?.relay ?? thread.root?.relay;
const replyTo = thread?.replyTo ?? thread?.root;
const replyLink = replyTo ? tagToNostrLink([replyTo.key, replyTo.value ?? "", replyTo.relay ?? "", replyTo.marker ?? ""].filter(a => a.length > 0)) : undefined;
const mentions: { pk: string; name: string; link: ReactNode }[] = [];
for (const pk of thread?.pubKeys ?? []) {
const u = UserCache.getFromCache(pk);
@ -305,9 +330,9 @@ export function NoteInner(props: NoteProps) {
{pubMentions} {others}
</>
) : (
replyId && (
<Link to={eventLink(replyId, replyRelayHints)}>
{hexToBech32(NostrPrefix.Event, replyId)?.substring(0, 12)}
replyLink && (
<Link to={`/e/${replyLink.encode()}`}>
{replyLink.encode().substring(0, 12)}
</Link>
)
)}
@ -315,7 +340,7 @@ export function NoteInner(props: NoteProps) {
);
}
const canRenderAsTextNote = [EventKind.TextNote, EventKind.Polls];
const canRenderAsTextNote = [EventKind.TextNote, EventKind.Polls, EventKind.LongFormTextNote];
if (!canRenderAsTextNote.includes(ev.kind)) {
const alt = findTag(ev, "alt");
if (alt) {
@ -393,7 +418,7 @@ export function NoteInner(props: NoteProps) {
{options.showContextMenu && (
<NoteContextMenu
ev={ev}
react={async () => {}}
react={async () => { }}
onTranslated={t => setTranslated(t)}
setShowReactions={setShowReactions}
/>

View File

@ -12,6 +12,8 @@
width: 48px;
height: 48px;
cursor: pointer;
position: relative;
z-index: 2;
}
a.pfp {

View File

@ -0,0 +1,18 @@
.root-type {
display: flex;
align-items: center;
justify-content: center;
}
.root-type > button {
background: white;
color: black;
font-size: 16px;
padding: 10px 16px;
border-radius: 1000px;
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
}

View File

@ -0,0 +1,151 @@
import "./RootTabs.css";
import { useState, ReactNode, useEffect } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { Menu, MenuItem } from "@szhsin/react-menu";
import { FormattedMessage } from "react-intl";
import useLogin from "Hooks/useLogin";
import Icon from "Icons/Icon";
export type RootTab = "following" | "conversations" | "trending-notes" | "trending-people" | "suggested" | "tags" | "global";
export function RootTabs({ base }: { base?: string }) {
const navigate = useNavigate();
const location = useLocation();
const { publicKey: pubKey, tags } = useLogin();
const [rootType, setRootType] = useState<RootTab>("following");
const menuItems = [
{
tab: "following",
path: `${base}/notes`,
show: Boolean(pubKey),
element: (
<>
<Icon name="user-v2" />
<FormattedMessage defaultMessage="Following" />
</>
),
},
{
tab: "trending-notes",
path: `${base}/trending/notes`,
show: true,
element: (
<>
<Icon name="fire" />
<FormattedMessage defaultMessage="Trending Notes" />
</>
),
},
{
tab: "conversations",
path: `${base}/conversations`,
show: Boolean(pubKey),
element: (
<>
<Icon name="message-chat-circle" />
<FormattedMessage defaultMessage="Conversations" />
</>
),
},
{
tab: "trending-people",
path: `${base}/trending/people`,
show: true,
element: (
<>
<Icon name="user-up" />
<FormattedMessage defaultMessage="Trending People" />
</>
),
},
{
tab: "suggested",
path: `${base}/suggested`,
show: Boolean(pubKey),
element: (
<>
<Icon name="thumbs-up" />
<FormattedMessage defaultMessage="Suggested Follows" />
</>
),
},
{
tab: "global",
path: `${base}/global`,
show: true,
element: (
<>
<Icon name="globe" />
<FormattedMessage defaultMessage="Global" />
</>
),
},
] as Array<{
tab: RootTab;
path: string;
show: boolean;
element: ReactNode;
}>;
useEffect(() => {
const currentTab = menuItems.find(a => a.path === location.pathname)?.tab;
if (currentTab) {
setRootType(currentTab);
}
}, [location]);
function currentMenuItem() {
if (location.pathname.startsWith(`${base}/t/`)) {
return (
<>
<Icon name="hash" />
{location.pathname.split("/").slice(-1)}
</>
);
}
return menuItems.find(a => a.tab === rootType)?.element;
}
return (
<div className="root-type">
<Menu
menuButton={
<button type="button">
{currentMenuItem()}
<Icon name="chevronDown" />
</button>
}
align="center"
menuClassName={() => "ctx-menu"}>
<div className="close-menu-container">
<MenuItem>
<div className="close-menu" />
</MenuItem>
</div>
{menuItems
.filter(a => a.show)
.map(a => (
<MenuItem
onClick={() => {
navigate(a.path);
}}>
{a.element}
</MenuItem>
))}
{tags.item.map(v => (
<MenuItem
onClick={() => {
navigate(`${base}/t/${v}`);
}}>
<Icon name="hash" />
{v}
</MenuItem>
))}
</Menu>
</div>
);
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import "./Text.css";
import { useMemo, useState } from "react";
import { HexKey, ParsedFragment, transformText } from "@snort/system";
import { useState } from "react";
import { HexKey, ParsedFragment } from "@snort/system";
import Invoice from "Element/Invoice";
import Hashtag from "Element/Hashtag";
@ -8,7 +8,8 @@ import HyperText from "Element/HyperText";
import CashuNuts from "Element/CashuNuts";
import RevealMedia from "./RevealMedia";
import { ProxyImg } from "./ProxyImg";
import { SpotlightMedia } from "./SpotlightMedia";
import { SpotlightMediaModal } from "./SpotlightMedia";
import { useTextTransformer } from "Hooks/useTextTransformCache";
export interface TextProps {
id: string;
@ -24,8 +25,6 @@ export interface TextProps {
onClick?: (e: React.MouseEvent) => void;
}
const TextCache = new Map<string, Array<ParsedFragment>>();
export default function Text({
id,
content,
@ -42,13 +41,7 @@ export default function Text({
const [showSpotlight, setShowSpotlight] = useState(false);
const [imageIdx, setImageIdx] = useState(0);
const elements = useMemo(() => {
const cached = TextCache.get(id);
if (cached) return cached;
const newCache = transformText(content, tags);
TextCache.set(id, newCache);
return newCache;
}, [content, id]);
const elements = useTextTransformer(id, content, tags);
const images = elements.filter(a => a.type === "media" && a.mimeType?.startsWith("image")).map(a => a.content);
@ -114,7 +107,7 @@ export default function Text({
return (
<div dir="auto" className={`text${className ? ` ${className}` : ""}`} onClick={onClick}>
{renderContent()}
{showSpotlight && <SpotlightMedia images={images} onClose={() => setShowSpotlight(false)} idx={imageIdx} />}
{showSpotlight && <SpotlightMediaModal images={images} onClose={() => setShowSpotlight(false)} idx={imageIdx} />}
</div>
);
}

View File

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

View File

@ -1,23 +1,21 @@
import "./Thread.css";
import { useMemo, useState, ReactNode } from "react";
import { useMemo, useState, ReactNode, useContext } from "react";
import { useIntl } from "react-intl";
import { useNavigate, useLocation, Link, useParams } from "react-router-dom";
import { useNavigate, Link, useParams } from "react-router-dom";
import {
TaggedNostrEvent,
u256,
EventKind,
NostrPrefix,
EventExt,
Thread as ThreadInfo,
parseNostrLink,
} from "@snort/system";
import { eventLink, unwrap, getReactions, getAllReactions, findTag } from "SnortUtils";
import { eventLink, getReactions, getAllReactions } from "SnortUtils";
import BackButton from "Element/BackButton";
import Note from "Element/Note";
import NoteGhost from "Element/NoteGhost";
import Collapsed from "Element/Collapsed";
import useThreadFeed from "Feed/ThreadFeed";
import { ThreadContext, ThreadContextWrapper } from "Hooks/useThreadContext";
import messages from "./messages";
@ -162,9 +160,8 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate
return (
<>
<div
className={`subthread-container ${hasMultipleNotes ? "subthread-multi" : ""} ${
isLast ? "subthread-last" : "subthread-mid"
}`}>
className={`subthread-container ${hasMultipleNotes ? "subthread-multi" : ""} ${isLast ? "subthread-last" : "subthread-mid"
}`}>
<Divider variant="small" />
<Note
highlight={active === first.id}
@ -193,9 +190,8 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate
return (
<div
key={r.id}
className={`subthread-container ${lastReply ? "" : "subthread-multi"} ${
lastReply ? "subthread-last" : "subthread-mid"
}`}>
className={`subthread-container ${lastReply ? "" : "subthread-multi"} ${lastReply ? "subthread-last" : "subthread-mid"
}`}>
<Divider variant="small" />
<Note
className={`thread-note ${lastNote ? "is-last-note" : ""}`}
@ -213,110 +209,39 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate
);
};
export default function Thread() {
export function ThreadRoute() {
const params = useParams();
const location = useLocation();
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() {
const thread = useContext(ThreadContext);
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();
function navigateThread(e: TaggedNostrEvent) {
setCurrentId(e.id);
thread.setCurrent(e.id);
//const link = encodeTLV(e.id, NostrPrefix.Event, e.relays);
}
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(() => {
if (root) {
const currentThread = EventExt.extractThread(root);
if (thread.root) {
const currentThread = EventExt.extractThread(thread.root);
return (
currentThread?.replyTo?.value ??
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));
const brokenChains = Array.from(thread.chains?.keys()).filter(a => !thread.data?.some(b => b.id === a));
function renderRoot(note: TaggedNostrEvent) {
const className = `thread-root${isSingleNote ? " thread-root-single" : ""}`;
@ -337,20 +262,20 @@ export default function Thread() {
}
function renderChain(from: u256): ReactNode {
if (!from || !chains) {
if (!from || thread.chains.size === 0) {
return;
}
const replies = chains.get(from);
if (replies && currentId) {
const replies = thread.chains.get(from);
if (replies && thread.current) {
return (
<Subthread
active={currentId}
active={thread.current}
notes={replies}
related={getAllReactions(
thread.data,
replies.map(a => a.id),
)}
chains={chains}
chains={thread.chains}
onNavigate={navigateThread}
/>
);
@ -359,7 +284,7 @@ export default function Thread() {
function goBack() {
if (parent) {
setCurrentId(parent);
thread.setCurrent(parent);
} else {
navigate(-1);
}
@ -379,8 +304,8 @@ export default function Thread() {
<BackButton onClick={goBack} text={parent ? parentText : backText} />
</div>
<div className="main-content">
{root && renderRoot(root)}
{root && renderChain(root.id)}
{thread.root && renderRoot(thread.root)}
{thread.root && renderChain(thread.root.id)}
{brokenChains.length > 0 && <h3>Other replies</h3>}
{brokenChains.map(a => {

View File

@ -1,5 +1,5 @@
import "./Timeline.css";
import { useCallback, useContext, useMemo, useState, useSyncExternalStore } from "react";
import { ReactNode, useCallback, useContext, useMemo, useState, useSyncExternalStore } from "react";
import { FormattedMessage } from "react-intl";
import { TaggedNostrEvent, EventKind, u256, NostrEvent } from "@snort/system";
import { unixNow } from "@snort/shared";
@ -19,6 +19,9 @@ import Icon from "Icons/Icon";
export interface TimelineFollowsProps {
postsOnly: boolean;
liveStreams?: boolean;
noteFilter?: (ev: NostrEvent) => boolean;
noteRenderer?: (ev: NostrEvent) => ReactNode;
}
/**
@ -46,7 +49,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
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));
.filter(a => !isMuted(a.pubkey) && login.follows.item.includes(a.pubkey) && (props.noteFilter?.(a) ?? true));
},
[props.postsOnly, muted, login.follows.timestamp],
);
@ -83,7 +86,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
return (
<>
<LiveStreams evs={liveStreams} />
{(props.liveStreams ?? true) && <LiveStreams evs={liveStreams} />}
{latestFeed.length > 0 && (
<>
<div className="card latest-notes" onClick={() => onShowLatest()} ref={ref}>
@ -110,7 +113,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
)}
</>
)}
{mainFeed.map(a => (
{mainFeed.map(a => props.noteRenderer?.(a) ?? (
<Note data={a as TaggedNostrEvent} related={relatedFeed(a.id)} key={a.id} depth={0} />
))}
<div className="flex f-center p">

View File

@ -22,8 +22,8 @@ export default function TrendingUsers() {
if (!userList) return <PageSpinner />;
return (
<>
<div className="p">
<FollowListBase pubkeys={userList} showAbout={true} />
</>
</div>
);
}

View File

@ -0,0 +1,21 @@
import { EventKind, NoteCollection, RequestBuilder } from "@snort/system";
import { useRequestBuilder } from "@snort/system-react";
import useLogin from "Hooks/useLogin";
import { useMemo } from "react";
export function useArticles() {
const {publicKey, follows} = useLogin();
const sub = useMemo(() => {
if(!publicKey) return null;
const rb = new RequestBuilder(`articles:${publicKey}`);
rb.withFilter()
.kinds([EventKind.LongFormTextNote])
.authors(follows.item)
.limit(20);
return rb;
}, [follows.timestamp]);
return useRequestBuilder(NoteCollection, sub);
}

View File

@ -0,0 +1,22 @@
import { System } from "index";
import { useEffect } from "react";
import useLogin from "./useLogin";
export function useLoginRelays() {
const { relays } = useLogin();
useEffect(() => {
if (relays) {
(async () => {
for (const [k, v] of Object.entries(relays.item)) {
await System.ConnectToRelay(k, v);
}
for (const v of System.Sockets) {
if (!relays.item[v.address] && !v.ephemeral) {
System.DisconnectRelay(v.address);
}
}
})();
}
}, [relays]);
}

View File

@ -0,0 +1,15 @@
import { ParsedFragment, transformText } from "@snort/system";
const TextCache = new Map<string, Array<ParsedFragment>>();
export function transformTextCached(id: string, content: string, tags: Array<Array<string>>) {
const cached = TextCache.get(id);
if (cached) return cached;
const newCache = transformText(content, tags);
TextCache.set(id, newCache);
return newCache;
}
export function useTextTransformer(id: string, content: string, tags: Array<Array<string>>) {
return transformTextCached(id, content, tags);
}

View File

@ -0,0 +1,32 @@
import { useEffect } from "react";
import useLogin from "./useLogin";
export function useTheme() {
const { preferences } = useLogin();
function setTheme(theme: "light" | "dark") {
const elm = document.documentElement;
if (theme === "light" && !elm.classList.contains("light")) {
elm.classList.add("light");
} else if (theme === "dark" && elm.classList.contains("light")) {
elm.classList.remove("light");
}
}
useEffect(() => {
const osTheme = window.matchMedia("(prefers-color-scheme: light)");
setTheme(
preferences.theme === "system" && osTheme.matches ? "light" : preferences.theme === "light" ? "light" : "dark"
);
osTheme.onchange = e => {
if (preferences.theme === "system") {
setTheme(e.matches ? "light" : "dark");
}
};
return () => {
osTheme.onchange = null;
};
}, [preferences.theme]);
}

View File

@ -0,0 +1,110 @@
import { unwrap } from "@snort/shared";
import { EventExt, EventKind, NostrLink, NostrPrefix, TaggedNostrEvent, u256, Thread as ThreadInfo, } from "@snort/system";
import useThreadFeed from "Feed/ThreadFeed";
import { findTag } from "SnortUtils";
import { ReactNode, createContext, useMemo, useState } from "react";
import { useLocation } from "react-router-dom";
export interface ThreadContext {
current: string,
root?: TaggedNostrEvent,
chains: Map<string, Array<TaggedNostrEvent>>,
data: Array<TaggedNostrEvent>,
setCurrent: (i: string) => void;
}
export const ThreadContext = createContext({} as ThreadContext)
export function ThreadContextWrapper({ link, children }: { link: NostrLink, children?: ReactNode }) {
const location = useLocation();
const [currentId, setCurrentId] = useState(link.id);
const thread = useThreadFeed(link);
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 ctxValue = useMemo(() => {
return {
current: currentId,
root,
chains,
data: thread.data,
setCurrent: v => setCurrentId(v)
} as ThreadContext
}, [root, chains]);
return <ThreadContext.Provider value={ctxValue}>
{children}
</ThreadContext.Provider>
}

View File

@ -0,0 +1,97 @@
.deck-layout {
display: flex;
height: 100vh;
overflow-y: hidden;
}
.deck-layout .deck-cols {
display: flex;
height: 100vh;
overflow-y: hidden;
overflow-x: auto;
}
.deck-layout .deck-cols .deck-col-header {
padding: 8px 16px;
border: 1px solid var(--border-color);
border-collapse: collapse;
font-size: 20px;
font-weight: 700;
min-height: 40px;
max-height: 40px;
}
.deck-layout .deck-cols .deck-col-header:not(:last-of-type) {
border-right: 0;
}
.deck-layout .deck-cols > div {
display: flex;
flex-direction: column;
height: 100vh;
width: 550px;
min-width: 550px;
}
.deck-layout .deck-cols > div > div:not(:first-of-type) {
overflow-y: scroll;
}
.image-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 4px;
}
.image-grid > .media-note {
border: 1px solid var(--border-color);
background-image: var(--img);
background-position: center;
background-size: cover;
aspect-ratio: 1;
cursor: pointer;
}
.thread-overlay .modal-body {
background-color: unset;
padding: 0;
width: 100vw;
height: 100vh;
display: flex;
flex-direction: row;
border-radius: unset;
gap: 16px;
--border-color: #3A3A3A;
}
.thread-overlay .modal-body > div:last-of-type {
width: 550px;
min-width: 550px;
height: 100vh;
overflow-y: auto;
background-color: var(--gray-superdark);
}
.thread-overlay .spotlight {
flex-grow: 1;
margin: auto;
text-align: center;
}
.thread-overlay .spotlight .details {
right: calc(28px + 550px + 16px);
}
.thread-overlay .spotlight .right {
right: calc(24px + 550px + 16px);
}
.thread-overlay .spotlight img,
.thread-overlay .spotlight video {
max-width: calc(100vw - 550px - 16px);
}
.thread-overlay .main-content {
border: 0;
border-bottom: 1px solid var(--border-color);
}

View File

@ -0,0 +1,107 @@
import "./Deck.css";
import { CSSProperties, useContext, useState } from "react";
import { Outlet } from "react-router-dom";
import { FormattedMessage } from "react-intl";
import { NostrPrefix, createNostrLink } from "@snort/system";
import { DeckNav } from "Element/Deck/Nav";
import useLoginFeed from "Feed/LoginFeed";
import { useLoginRelays } from "Hooks/useLoginRelays";
import { useTheme } from "Hooks/useTheme";
import Articles from "Element/Deck/Articles";
import TimelineFollows from "Element/TimelineFollows";
import { transformTextCached } from "Hooks/useTextTransformCache";
import Icon from "Icons/Icon";
import NotificationsPage from "./Notifications";
import useImgProxy from "Hooks/useImgProxy";
import Modal from "Element/Modal";
import { Thread } from "Element/Thread";
import { RootTabs } from "Element/RootTabs";
import { SpotlightMedia } from "Element/SpotlightMedia";
import { ThreadContext, ThreadContextWrapper } from "Hooks/useThreadContext";
export function SnortDeckLayout() {
const [thread, setThread] = useState<string>();
useLoginFeed();
useTheme();
useLoginRelays();
const { proxy } = useImgProxy();
return <div className="deck-layout">
<DeckNav />
<div className="deck-cols">
<div>
<div className="deck-col-header flex">
<div className="flex f-1 g8">
<Icon name="rows-01" size={24} />
<FormattedMessage defaultMessage="Notes" />
</div>
<div className="f-1">
<RootTabs base="/deck" />
</div>
</div>
<div>
<Outlet />
</div>
</div>
<div>
<div className="deck-col-header flex g8">
<Icon name="file-06" size={24} />
<FormattedMessage defaultMessage="Articles" />
</div>
<div>
<Articles />
</div>
</div>
<div>
<div className="deck-col-header flex g8">
<Icon name="camera-lens" size={24} />
<FormattedMessage defaultMessage="Media" />
</div>
<div className="image-grid p">
<TimelineFollows postsOnly={true} liveStreams={false} noteFilter={e => {
const parsed = transformTextCached(e.id, e.content, e.tags);
const images = parsed.filter(a => a.type === "media" && a.mimeType?.startsWith("image/"));
return images.length > 0;
}} noteRenderer={e => {
const parsed = transformTextCached(e.id, e.content, e.tags);
const images = parsed.filter(a => a.type === "media" && a.mimeType?.startsWith("image/"));
return <div className="media-note" key={e.id} style={{
"--img": `url(${proxy(images[0].content)})`
} as CSSProperties} onClick={() => setThread(e.id)}></div>
}} />
</div>
</div>
<div>
<div className="deck-col-header flex g8">
<Icon name="bell-02" size={24} />
<FormattedMessage defaultMessage="Notifications" />
</div>
<div>
<NotificationsPage />
</div>
</div>
</div>
{thread && <>
<Modal onClose={() => setThread(undefined)} className="thread-overlay">
<ThreadContextWrapper link={createNostrLink(NostrPrefix.Note, thread)}>
<SpotlightFromThread onClose={() => setThread(undefined)} />
<div>
<Thread />
</div>
</ThreadContextWrapper>
</Modal>
</>}
</div>
}
function SpotlightFromThread({ onClose }: { onClose: () => void }) {
const thread = useContext(ThreadContext);
const parsed = thread.root ? transformTextCached(thread.root.id, thread.root.content, thread.root.tags) : [];
const images = parsed.filter(a => a.type === "media" && a.mimeType?.startsWith("image/"));
return <SpotlightMedia images={images.map(a => a.content)} idx={0} onClose={onClose} />
}

View File

@ -10,7 +10,6 @@ import messages from "./messages";
import Icon from "Icons/Icon";
import { RootState } from "State/Store";
import { setShow, reset } from "State/NoteCreator";
import { System } from "index";
import useLoginFeed from "Feed/LoginFeed";
import { NoteCreator } from "Element/NoteCreator";
import { mapPlanName } from "./subscribe";
@ -22,6 +21,8 @@ import Toaster from "Toaster";
import Spinner from "Icons/Spinner";
import { NostrPrefix, createNostrLink, tryParseNostrLink } from "@snort/system";
import { fetchNip05Pubkey } from "Nip05/Verifier";
import { useTheme } from "Hooks/useTheme";
import { useLoginRelays } from "Hooks/useLoginRelays";
export default function Layout() {
const location = useLocation();
@ -30,10 +31,13 @@ export default function Layout() {
const isReplyNoteCreatorShowing = replyTo && isNoteCreatorShowing;
const dispatch = useDispatch();
const navigate = useNavigate();
const { publicKey, relays, preferences, subscriptions } = useLogin();
const { publicKey, subscriptions } = useLogin();
const currentSubscription = getCurrentSubscription(subscriptions);
const [pageClass, setPageClass] = useState("page");
useLoginFeed();
useTheme();
useLoginRelays();
const handleNoteCreatorButtonClick = () => {
if (replyTo) {
@ -62,46 +66,6 @@ export default function Layout() {
}
}, [location]);
useEffect(() => {
if (relays) {
(async () => {
for (const [k, v] of Object.entries(relays.item)) {
await System.ConnectToRelay(k, v);
}
for (const v of System.Sockets) {
if (!relays.item[v.address] && !v.ephemeral) {
System.DisconnectRelay(v.address);
}
}
})();
}
}, [relays]);
function setTheme(theme: "light" | "dark") {
const elm = document.documentElement;
if (theme === "light" && !elm.classList.contains("light")) {
elm.classList.add("light");
} else if (theme === "dark" && elm.classList.contains("light")) {
elm.classList.remove("light");
}
}
useEffect(() => {
const osTheme = window.matchMedia("(prefers-color-scheme: light)");
setTheme(
preferences.theme === "system" && osTheme.matches ? "light" : preferences.theme === "light" ? "light" : "dark",
);
osTheme.onchange = e => {
if (preferences.theme === "system") {
setTheme(e.matches ? "light" : "dark");
}
};
return () => {
osTheme.onchange = null;
};
}, [preferences.theme]);
return (
<div className={pageClass}>
{!shouldHideHeader && (
@ -220,7 +184,7 @@ const AccountHeader = () => {
{unreadDms > 0 && <span className="has-unread"></span>}
</Link>
<Link className="btn" to="/notifications" onClick={goToNotifications}>
<Icon name="bell-v2" size={24} />
<Icon name="bell-02" size={24} />
{hasNotifications && <span className="has-unread"></span>}
</Link>
<Avatar

View File

@ -49,5 +49,6 @@
.notification-group .content img {
width: unset;
max-width: 100%;
max-height: 300px; /* Cap images in notifications to 300px height */
}

View File

@ -1,18 +0,0 @@
.root-type {
padding: 8px 12px;
display: flex;
align-items: center;
justify-content: center;
}
.root-type > button {
background: white;
color: black;
font-size: 16px;
padding: 10px 16px;
border-radius: 1000px;
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
}

View File

@ -1,8 +1,7 @@
import { ReactNode, useEffect, useState } from "react";
import { Link, Outlet, RouteObject, useLocation, useNavigate, useParams } from "react-router-dom";
import { useEffect, useState } from "react";
import { Link, Outlet, RouteObject, useParams } from "react-router-dom";
import { FormattedMessage } from "react-intl";
import { Menu, MenuItem } from "@szhsin/react-menu";
import "./Root.css";
import { unixNow } from "@snort/shared";
import Timeline from "Element/Timeline";
import { System } from "index";
@ -10,165 +9,26 @@ import { TimelineSubject } from "Feed/TimelineFeed";
import { debounce, getRelayName, sha256 } from "SnortUtils";
import useLogin from "Hooks/useLogin";
import Discover from "Pages/Discover";
import Icon from "Icons/Icon";
import TrendingUsers from "Element/TrendingUsers";
import TrendingNotes from "Element/TrendingPosts";
import HashTagsPage from "Pages/HashTagsPage";
import SuggestedProfiles from "Element/SuggestedProfiles";
import { TaskList } from "Tasks/TaskList";
import TimelineFollows from "Element/TimelineFollows";
import { RootTabs } from "Element/RootTabs";
import messages from "./messages";
import { unixNow } from "@snort/shared";
interface RelayOption {
url: string;
paid: boolean;
}
type RootPage = "following" | "conversations" | "trending-notes" | "trending-people" | "suggested" | "tags" | "global";
export default function RootPage() {
const navigate = useNavigate();
const location = useLocation();
const { publicKey: pubKey, tags, preferences } = useLogin();
const [rootType, setRootType] = useState<RootPage>("following");
const menuItems = [
{
tab: "following",
path: "/notes",
show: Boolean(pubKey),
element: (
<>
<Icon name="user-v2" />
<FormattedMessage defaultMessage="Following" />
</>
),
},
{
tab: "trending-notes",
path: "/trending/notes",
show: true,
element: (
<>
<Icon name="fire" />
<FormattedMessage defaultMessage="Trending Notes" />
</>
),
},
{
tab: "conversations",
path: "/conversations",
show: Boolean(pubKey),
element: (
<>
<Icon name="message-chat-circle" />
<FormattedMessage defaultMessage="Conversations" />
</>
),
},
{
tab: "trending-people",
path: "/trending/people",
show: true,
element: (
<>
<Icon name="user-up" />
<FormattedMessage defaultMessage="Trending People" />
</>
),
},
{
tab: "suggested",
path: "/suggested",
show: Boolean(pubKey),
element: (
<>
<Icon name="thumbs-up" />
<FormattedMessage defaultMessage="Suggested Follows" />
</>
),
},
{
tab: "global",
path: "/global",
show: true,
element: (
<>
<Icon name="globe" />
<FormattedMessage defaultMessage="Global" />
</>
),
},
] as Array<{
tab: RootPage;
path: string;
show: boolean;
element: ReactNode;
}>;
useEffect(() => {
if (location.pathname === "/") {
const t = pubKey ? preferences.defaultRootTab ?? "/notes" : "/trending/notes";
navigate(t);
} else {
const currentTab = menuItems.find(a => a.path === location.pathname)?.tab;
if (currentTab) {
setRootType(currentTab);
}
}
}, [location]);
function currentMenuItem() {
if (location.pathname.startsWith("/t/")) {
return (
<>
<Icon name="hash" />
{location.pathname.split("/").slice(-1)}
</>
);
}
return menuItems.find(a => a.tab === rootType)?.element;
}
return (
<>
<div className="main-content root-type">
<Menu
menuButton={
<button type="button">
{currentMenuItem()}
<Icon name="chevronDown" />
</button>
}
align="center"
menuClassName={() => "ctx-menu"}>
<div className="close-menu-container">
<MenuItem>
<div className="close-menu" />
</MenuItem>
</div>
{menuItems
.filter(a => a.show)
.map(a => (
<MenuItem
onClick={() => {
navigate(a.path);
}}>
{a.element}
</MenuItem>
))}
{tags.item.map(v => (
<MenuItem
onClick={() => {
navigate(`/t/${v}`);
}}>
<Icon name="hash" />
{v}
</MenuItem>
))}
</Menu>
<div className="main-content p">
<RootTabs />
</div>
<div className="main-content">
<Outlet />
@ -196,7 +56,7 @@ const FollowsHint = () => {
return null;
};
const GlobalTab = () => {
export const GlobalTab = () => {
const { relays } = useLogin();
const [relay, setRelay] = useState<RelayOption>();
const [allRelays, setAllRelays] = useState<RelayOption[]>();
@ -272,7 +132,7 @@ const GlobalTab = () => {
);
};
const NotesTab = () => {
export const NotesTab = () => {
return (
<>
<FollowsHint />
@ -282,71 +142,81 @@ const NotesTab = () => {
);
};
const ConversationsTab = () => {
export const ConversationsTab = () => {
return <TimelineFollows postsOnly={false} />;
};
const TagsTab = () => {
export const TagsTab = (params: { tag?: string }) => {
const { tag } = useParams();
const t = params.tag ?? tag ?? "";
const subject: TimelineSubject = {
type: "hashtag",
items: [tag ?? ""],
discriminator: `tags-${tag}`,
items: [t],
discriminator: `tags-${t}`,
streams: true,
};
return <Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} />;
};
const DefaultTab = () => {
const { preferences, publicKey } = useLogin();
const tab = publicKey ? preferences.defaultRootTab ?? `notes` : `trending/notes`;
const elm = RootTabRoutes.find(a => a.path === tab)?.element;
return elm;
}
export const RootTabRoutes = [
{
path: "",
element: <DefaultTab />
},
{
path: "global",
element: <GlobalTab />,
},
{
path: "notes",
element: <NotesTab />,
},
{
path: "conversations",
element: <ConversationsTab />,
},
{
path: "discover",
element: <Discover />,
},
{
path: "tag/:tag",
element: <TagsTab />,
},
{
path: "trending/notes",
element: <TrendingNotes />,
},
{
path: "trending/people",
element: <TrendingUsers />,
},
{
path: "suggested",
element: (
<div className="p">
<SuggestedProfiles />
</div>
),
},
{
path: "t/:tag",
element: <HashTagsPage />,
},
];
export const RootRoutes = [
{
path: "/",
element: <RootPage />,
children: [
{
path: "global",
element: <GlobalTab />,
},
{
path: "notes",
element: <NotesTab />,
},
{
path: "conversations",
element: <ConversationsTab />,
},
{
path: "discover",
element: <Discover />,
},
{
path: "tag/:tag",
element: <TagsTab />,
},
{
path: "trending/notes",
element: <TrendingNotes />,
},
{
path: "trending/people",
element: (
<div className="p">
<TrendingUsers />
</div>
),
},
{
path: "suggested",
element: (
<div className="p">
<SuggestedProfiles />
</div>
),
},
{
path: "/t/:tag",
element: <HashTagsPage />,
},
],
children: RootTabRoutes,
},
] as RouteObject[];

View File

@ -261,6 +261,10 @@ button.icon:hover {
display: inline-flex;
}
.light .btn {
color: #64748B;
}
.btn-warn {
border-color: var(--error);
}
@ -353,6 +357,7 @@ input:disabled {
.f-center {
justify-content: center;
align-items: center;
}
.f-1 {

View File

@ -28,7 +28,7 @@ import Store from "State/Store";
import Layout from "Pages/Layout";
import LoginPage from "Pages/LoginPage";
import ProfilePage from "Pages/ProfilePage";
import { RootRoutes } from "Pages/Root";
import { RootRoutes, RootTabRoutes } from "Pages/Root";
import NotificationsPage from "Pages/Notifications";
import SettingsPage, { SettingsRoutes } from "Pages/SettingsPage";
import ErrorPage from "Pages/ErrorPage";
@ -40,13 +40,14 @@ import HelpPage from "Pages/HelpPage";
import { NewUserRoutes } from "Pages/new";
import { WalletRoutes } from "Pages/WalletPage";
import NostrLinkHandler from "Pages/NostrLinkHandler";
import Thread from "Element/Thread";
import { ThreadRoute } from "Element/Thread";
import { SubscribeRoutes } from "Pages/subscribe";
import ZapPoolPage from "Pages/ZapPool";
import DebugPage from "Pages/Debug";
import { db } from "Db";
import { preload, RelayMetrics, UserCache, UserRelays } from "Cache";
import { LoginStore } from "Login";
import { SnortDeckLayout } from "Pages/DeckLayout";
const WasmQueryOptimizer = {
expandFilter: (f: ReqFilter) => {
@ -152,7 +153,7 @@ export const router = createBrowserRouter([
},
{
path: "/e/:id",
element: <Thread />,
element: <ThreadRoute />,
},
{
path: "/p/:id",
@ -200,6 +201,18 @@ export const router = createBrowserRouter([
},
],
},
{
path: "/deck",
element: <SnortDeckLayout />,
loader: async () => {
if (!didInit) {
didInit = true;
return await initSite();
}
return null;
},
children: RootTabRoutes
}
]);
const root = ReactDOM.createRoot(unwrap(document.getElementById("root")));

View File

@ -24,6 +24,7 @@ enum EventKind {
TagLists = 30002, // NIP-51c
Badge = 30009, // NIP-58
ProfileBadges = 30008, // NIP-58
LongFormTextNote = 30023, // NIP-23
LiveEvent = 30311, // NIP-102
ZapstrTrack = 31337,
SimpleChatMetadata = 39_000, // NIP-29

View File

@ -22,6 +22,22 @@ export function linkToEventTag(link: NostrLink) {
}
}
export function tagToNostrLink(tag: Array<string>) {
switch(tag[0]) {
case "e": {
return createNostrLink(NostrPrefix.Event, tag[1], tag.slice(2));
}
case "p": {
return createNostrLink(NostrPrefix.Profile, tag[1], tag.slice(2));
}
case "a": {
const [kind, author, dTag] = tag[1].split(":");
return createNostrLink(NostrPrefix.Address, dTag, tag.slice(2), Number(kind), author);
}
}
throw new Error(`Unknown tag kind ${tag[0]}`);
}
export function createNostrLinkToEvent(ev: TaggedNostrEvent | NostrEvent) {
const relays = "relays" in ev ? ev.relays : undefined;