Tauri: Fix badge centering (#6690)
This commit is contained in:
parent
6908e40e0f
commit
d32d1b3328
@ -1,8 +1,7 @@
|
|||||||
import type { FC } from '../../lib/teact/teact';
|
|
||||||
import { memo, useEffect } from '../../lib/teact/teact';
|
import { memo, useEffect } from '../../lib/teact/teact';
|
||||||
|
|
||||||
|
import { ALL_FOLDER_ID } from '../../config';
|
||||||
import { updateAppBadge } from '../../util/appBadge';
|
import { updateAppBadge } from '../../util/appBadge';
|
||||||
import { getAllNotificationsCount } from '../../util/folderManager';
|
|
||||||
import { formatIntegerCompact } from '../../util/textFormat';
|
import { formatIntegerCompact } from '../../util/textFormat';
|
||||||
|
|
||||||
import { useFolderManagerForUnreadCounters } from '../../hooks/useFolderManager';
|
import { useFolderManagerForUnreadCounters } from '../../hooks/useFolderManager';
|
||||||
@ -12,9 +11,9 @@ interface OwnProps {
|
|||||||
isForAppBadge?: boolean;
|
isForAppBadge?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UnreadCounter: FC<OwnProps> = ({ isForAppBadge }) => {
|
const UnreadCounter = ({ isForAppBadge }: OwnProps) => {
|
||||||
useFolderManagerForUnreadCounters();
|
const unreadCounters = useFolderManagerForUnreadCounters();
|
||||||
const unreadNotificationsCount = getAllNotificationsCount();
|
const unreadNotificationsCount = unreadCounters[ALL_FOLDER_ID]?.notificationsCount || 0;
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|
||||||
|
|||||||
2
tauri/Cargo.lock
generated
2
tauri/Cargo.lock
generated
@ -5653,7 +5653,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "telegram_air"
|
name = "telegram_air"
|
||||||
version = "2.9.4"
|
version = "2.9.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ab_glyph",
|
"ab_glyph",
|
||||||
"cocoa",
|
"cocoa",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "telegram_air"
|
name = "telegram_air"
|
||||||
version = "2.9.4"
|
version = "2.9.5"
|
||||||
description = "Telegram Air"
|
description = "Telegram Air"
|
||||||
authors = ["Alexander Zinchuk"]
|
authors = ["Alexander Zinchuk"]
|
||||||
license = "GPLv3"
|
license = "GPLv3"
|
||||||
|
|||||||
@ -121,10 +121,7 @@ pub fn generate_counter_png(size: u32, count: i32, is_muted: bool) -> Vec<u8> {
|
|||||||
|
|
||||||
if let (Some(text), Some(font), Some(scale)) = (text, font, scale) {
|
if let (Some(text), Some(font), Some(scale)) = (text, font, scale) {
|
||||||
let x = edge_space as f32 + ((badge_width as f32 - text_width as f32) / 2.0).ceil();
|
let x = edge_space as f32 + ((badge_width as f32 - text_width as f32) / 2.0).ceil();
|
||||||
|
let y = edge_space as f32 + ((badge_height as f32 - text_height as f32) / 2.0).ceil();
|
||||||
let baseline_offset = scale.y * 0.15;
|
|
||||||
let y = edge_space as f32
|
|
||||||
+ ((badge_height as f32 - text_height as f32) / 2.0 - baseline_offset).ceil();
|
|
||||||
|
|
||||||
draw_text_mut(
|
draw_text_mut(
|
||||||
&mut img,
|
&mut img,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user