Skip to content

Commit

Permalink
No refresh on reconnection setting added. (Experimental Tab only)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Apr 20, 2024
1 parent b7f0f3e commit cc4ad0d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 42 deletions.
4 changes: 3 additions & 1 deletion info/dev/requests.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.

=======================================================

Expand Down
44 changes: 3 additions & 41 deletions src/app/organisms/space-settings/PonyHouseSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)}
/>
)}
</li>
Expand Down
42 changes: 42 additions & 0 deletions src/app/organisms/space-settings/handleBannerUpload.js
Original file line number Diff line number Diff line change
@@ -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));
}
};

0 comments on commit cc4ad0d

Please sign in to comment.