Skip to content

Commit

Permalink
code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sairaj-mote committed Jan 5, 2024
1 parent 84846ce commit cee5644
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
7 changes: 2 additions & 5 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,8 @@ ol li::before {

#background_image {
z-index: -2;
-o-object-fit: cover;
object-fit: cover;
-o-object-fit: fill;
object-fit: fill;
filter: blur(var(--blur, 1rem));
transform: scale(calc(1 + var(--scale, 1.1) / 10));
}
Expand Down Expand Up @@ -2157,9 +2157,6 @@ sm-chip .badge {
padding-bottom: 6rem;
}

.has-bg-image .received::after {
border-color: transparent rgba(var(--foreground-color), 0.6) transparent transparent;
}
.has-bg-image #emoji_picker {
--background: rgba(var(--foreground-color), 0.6);
}
Expand Down
2 changes: 1 addition & 1 deletion css/main.min.css

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -973,10 +973,9 @@ ol {

#background_image {
z-index: -2;
object-fit: cover;
object-fit:fill;
filter: blur(var(--blur, 1rem));
transform: scale(calc(1 + (var(--scale, 1.1) / 10)));

&[src=""],
&:not([src]) {
display: none;
Expand Down Expand Up @@ -2206,11 +2205,6 @@ sm-chip {
}

.has-bg-image {
.received::after {
border-color: transparent rgba(var(--foreground-color), 0.6) transparent
transparent;
}

#emoji_picker {
--background: rgba(var(--foreground-color), 0.6);
}
Expand Down
21 changes: 11 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4414,7 +4414,10 @@ <h5>FLO data</h5>
}
}
function handleGroupDescriptionChange(e) {
rmMessenger.changeGroupDescription(floGlobals.viewingDetailsOfAddress, e.detail.value.trim())
const description = e.detail.value.trim();
if (description === '') return notify('Description cannot be empty', 'error')
if (description.length > 100) return notify('Description cannot be more than 100 characters', 'error')
rmMessenger.changeGroupDescription(floGlobals.viewingDetailsOfAddress, description)
.then(res => {
notify('Changed group description', 'success')
})
Expand Down Expand Up @@ -4631,9 +4634,9 @@ <h5>FLO data</h5>
document.body.style.setProperty('--accent-color', color);
})

getRef('select_bg_image').addEventListener('change', async function (e) {
await compactIDB.writeData('userSettings', true, 'hasSelectedBg')
compactIDB.writeData('userSettings', this.files[0], 'bgImage')
getRef('select_bg_image').addEventListener('change', function (e) {
Promise.all([compactIDB.writeData('userSettings', true, 'hasSelectedBg'),
compactIDB.writeData('userSettings', this.files[0], 'bgImage')])
.then(async res => {
setBgImage()
notify('Background applied', 'success')
Expand All @@ -4657,12 +4660,12 @@ <h5>FLO data</h5>
})
async function setBgImage() {
try {
const hasSelectedBg = await compactIDB.readData('userSettings', 'hasSelectedBg')
const image = await compactIDB.readData('userSettings', 'bgImage')
if (image) {
const url = URL.createObjectURL(image)
const { hasSelectedBg = false, bgImage, bgOpacity, bgBlur } = await compactIDB.readAllData('userSettings')
if (bgImage) {
const url = URL.createObjectURL(bgImage)
if (hasSelectedBg) {
getRef('background_image').src = url
getRef('selected_bg_preview').click()
addClass(['#chat_view', '#mail', '#chat_preview'], 'has-bg-image')
getRef('select_bg_button').textContent = 'Change background'
getRef('selected_bg_preview').classList.add('bg-preview--selected')
Expand All @@ -4674,7 +4677,6 @@ <h5>FLO data</h5>
getRef('selected_bg_preview').classList.remove('hidden')
getRef('selected_bg_preview').querySelector('img').src = url
}
const [bgOpacity, bgBlur] = await Promise.all([compactIDB.readData('userSettings', 'bgOpacity'), compactIDB.readData('userSettings', 'bgBlur')])
if (bgOpacity !== undefined) {
getRef('backdrop_opacity').value = bgOpacity * 100
getRef('backdrop_opacity_value').value = `${parseInt(bgOpacity * 100)}%`
Expand All @@ -4685,7 +4687,6 @@ <h5>FLO data</h5>
getRef('backdrop_blur_value').value = `${parseInt(bgBlur * 100)}%`
getRef('background_image').style.setProperty('--blur', `${bgBlur}rem`)
getRef('background_image').style.setProperty('--scale', bgBlur)

}
}
catch (err) {
Expand Down

0 comments on commit cee5644

Please sign in to comment.