Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce auto-updating strings objects #549

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

krlade
Copy link
Contributor

@krlade krlade commented Jun 2, 2023

Summary

@krlade krlade force-pushed the subtitle branch 2 times, most recently from a53cb9b to 9195097 Compare June 9, 2023 14:58
@krlade krlade changed the title WIP: Introduce ChatSubtitleString feat: Introduce auto-updating strings objects Jun 9, 2023
@krlade
Copy link
Contributor Author

krlade commented Jun 17, 2023

image
I love this new test 😁. Nonetheless may I ask for an initial review? I'll force push my branch anyway

ChatType::Private(user) => {
self.setup_user_info(user);
// TODO: Add handle own chat;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@krlade krlade marked this pull request as ready for review June 17, 2023 21:32
Comment on lines 143 to 145
glib::ParamSpecInt::builder("online-member-count")
.read_only()
.build(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move after unread-count.


#[derive(Debug, Default)]
pub(crate) struct UserStatusString {
pub(super) user: OnceCell<User>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a WeakRef

}

impl UserStatusString {
pub(crate) fn new(user: User) -> UserStatusString {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also implement From trait.

Comment on lines 119 to 132
if matches!(user.type_().0, UserType::Bot(_)) {
gettext("bot")
} else {
strings::user_status(&user.status().0)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use match for such things.

}),
);

if let UserStatus::Offline(data) = user.status().0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no if let else. match is more readable

_ => {
if let Some(source) = self.imp().source_id.take() {
source.remove();
self.imp().source_id.replace(None);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take already sets None. So, this line is obsolete.

@@ -52,6 +53,7 @@ mod imp {
pub(super) list_view: TemplateChild<gtk::ListView>,
#[template_child]
pub(super) chat_action_bar: TemplateChild<ChatActionBar>,
pub binding: RefCell<Option<gtk::ExpressionWatch>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this at the beginning

if let Some(action) = chat.actions().last() {
should_show_actions
.then(|| strings::chat_action(&action))
.unwrap_or(String::new())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unwrap_or_default()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, it's the same, but looks much better

if !chat.is_own_chat() {
match chat.type_() {
ChatType::Private(_) | ChatType::Secret(_) => {
if !chat.is_own_chat() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already checked that.

Comment on lines +119 to +121
.try_borrow()
.ok()
.and_then(|l| l.last().map(|(_, action)| action.clone()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, I've changed it because it was borrowed mutable multiple times and I didn't know how to fix this. I realized my workaround causes new problems, but left it for now since this pr is not ready to merge anyway.

jvlianodorneles and others added 22 commits September 23, 2023 23:50
Currently translated at 100.0% (262 of 262 strings)

Translation: Paper Plane/Main
Translate-URL: https://hosted.weblate.org/projects/paper-plane/main/pt/
Currently translated at 100.0% (262 of 262 strings)

Translation: Paper Plane/Main
Translate-URL: https://hosted.weblate.org/projects/paper-plane/main/pl/
Currently translated at 100.0% (262 of 262 strings)

Translation: Paper Plane/Main
Translate-URL: https://hosted.weblate.org/projects/paper-plane/main/pt/
Currently translated at 81.6% (214 of 262 strings)

Translation: Paper Plane/Main
Translate-URL: https://hosted.weblate.org/projects/paper-plane/main/ru/
These categories were taken form the desktop file of the official
client.
Some of them were taken form the desktop file of the official
client.
Currently translated at 100.0% (262 of 262 strings)

Translation: Paper Plane/Main
Translate-URL: https://hosted.weblate.org/projects/paper-plane/main/tr/
Currently translated at 100.0% (262 of 262 strings)

Translation: Paper Plane/Main
Translate-URL: https://hosted.weblate.org/projects/paper-plane/main/tr/
With mask it correctly matches message bubble background
We shouldn't assume that the current locale has an equivalent country
code. We need to check this and set an invalid country code in this
case to fix a crash.

Fixes paper-plane-developers#559
Avoid defining properties when not needed and move tdlib "use"
definitions.
Change send button style and stop using chat name as window title.
melix99 and others added 4 commits September 23, 2023 23:50
Also fix a crash that was caused from this update.
Tell tdlib to open selected and close unselected chat. This is needed
to recieve some updates e.g. ChatOnlineMemberCount
@krlade
Copy link
Contributor Author

krlade commented Sep 23, 2023

Oh Jeez, 26 commits 👀 I'm master of git 😁

@krlade krlade marked this pull request as draft September 23, 2023 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants