From cc4ad0d8d51a5da0315e03f900137b4bca4b533d Mon Sep 17 00:00:00 2001 From: "Yasmin Seidel (JasminDreasond)" Date: Sat, 20 Apr 2024 04:12:40 -0300 Subject: [PATCH] No refresh on reconnection setting added. (Experimental Tab only) --- info/dev/requests.md | 4 +- .../space-settings/PonyHouseSettings.jsx | 44 ++----------------- .../space-settings/handleBannerUpload.js | 42 ++++++++++++++++++ 3 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 src/app/organisms/space-settings/handleBannerUpload.js diff --git a/info/dev/requests.md b/info/dev/requests.md index 9cc9750c6..6e1fde186 100644 --- a/info/dev/requests.md +++ b/info/dev/requests.md @@ -1,3 +1,6 @@ +Tonar isso mais usável ao react events. +src/app/organisms/space-settings/handleBannerUpload.js + ENS Ethereum /src/app/organisms/navigation/Directs.jsx @@ -45,7 +48,6 @@ Made by Me selectedRoom.room.eventNames() Coisas que não atualiza sozinho: Lista de usuários online na room ainda não atualiza em tempo real. - Banner do space. ======================================================= diff --git a/src/app/organisms/space-settings/PonyHouseSettings.jsx b/src/app/organisms/space-settings/PonyHouseSettings.jsx index 09b4b9a01..31f1c983c 100644 --- a/src/app/organisms/space-settings/PonyHouseSettings.jsx +++ b/src/app/organisms/space-settings/PonyHouseSettings.jsx @@ -11,6 +11,7 @@ import initMatrix from '../../../client/initMatrix'; import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; import { getCurrentState } from '../../../util/matrixUtil'; +import { handleBannerUpload } from './handleBannerUpload'; function PonyHouseSettings({ roomId, room }) { const mx = initMatrix.matrixClient; @@ -23,45 +24,6 @@ function PonyHouseSettings({ roomId, room }) { setRoomIconsVisible(data); }; - const handleBannerUpload = async (url) => { - const spaceHeaderBody = $('.space-drawer-body'); - const spaceHeader = spaceHeaderBody.find('> .navbar'); - - const bannerPlace = $('.space-banner .avatar__border'); - const bannerImg = $('.space-banner img'); - - if (url === null) { - const isConfirmed = await confirmDialog( - 'Remove space banner', - 'Are you sure that you want to remove room banner?', - 'Remove', - 'warning', - ); - - if (isConfirmed) { - await mx.sendStateEvent(roomId, 'pony.house.settings', { url }, 'banner'); - - spaceHeaderBody.removeClass('drawer-with-banner'); - spaceHeader.removeClass('banner-mode').css('background-image', ''); - - bannerPlace.css('background-image', '').removeClass('banner-added'); - bannerImg.attr('src', ''); - } - } else { - await mx.sendStateEvent(roomId, 'pony.house.settings', { url }, 'banner'); - - spaceHeaderBody.addClass('drawer-with-banner'); - spaceHeader - .addClass('banner-mode') - .css('background-image', `url("${mx.mxcUrlToHttp(url, 960, 540)}")`); - - bannerPlace - .css('background-image', `url('${mx.mxcUrlToHttp(url, 400, 227)}')`) - .addClass('banner-added'); - bannerImg.attr('src', mx.mxcUrlToHttp(url, 400, 227)); - } - }; - // Pony Config const canPonyHouse = getCurrentState(room).maySendStateEvent('pony.house.settings', userId); let avatarSrc; @@ -111,8 +73,8 @@ function PonyHouseSettings({ roomId, room }) { className="space-banner" text="Banner" imageSrc={avatarSrc} - onUpload={handleBannerUpload} - onRequestRemove={() => handleBannerUpload(null)} + onUpload={(url) => handleBannerUpload(url, roomId)} + onRequestRemove={() => handleBannerUpload(null, roomId)} /> )} diff --git a/src/app/organisms/space-settings/handleBannerUpload.js b/src/app/organisms/space-settings/handleBannerUpload.js new file mode 100644 index 000000000..8503f608f --- /dev/null +++ b/src/app/organisms/space-settings/handleBannerUpload.js @@ -0,0 +1,42 @@ +import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; + +export const handleBannerUpload = async (url, roomId) => { + const mx = initMatrix.matrixClient; + + const spaceHeaderBody = $('.space-drawer-body'); + const spaceHeader = spaceHeaderBody.find('> .navbar'); + + const bannerPlace = $('.space-banner .avatar__border'); + const bannerImg = $('.space-banner img'); + + if (url === null) { + const isConfirmed = await confirmDialog( + 'Remove space banner', + 'Are you sure that you want to remove room banner?', + 'Remove', + 'warning', + ); + + if (isConfirmed) { + await mx.sendStateEvent(roomId, 'pony.house.settings', { url }, 'banner'); + + spaceHeaderBody.removeClass('drawer-with-banner'); + spaceHeader.removeClass('banner-mode').css('background-image', ''); + + bannerPlace.css('background-image', '').removeClass('banner-added'); + bannerImg.attr('src', ''); + } + } else { + await mx.sendStateEvent(roomId, 'pony.house.settings', { url }, 'banner'); + + spaceHeaderBody.addClass('drawer-with-banner'); + spaceHeader + .addClass('banner-mode') + .css('background-image', `url("${mx.mxcUrlToHttp(url, 960, 540)}")`); + + bannerPlace + .css('background-image', `url('${mx.mxcUrlToHttp(url, 400, 227)}')`) + .addClass('banner-added'); + bannerImg.attr('src', mx.mxcUrlToHttp(url, 400, 227)); + } +};