Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 43c288f

Browse files
committed
added folders
1 parent 42a4368 commit 43c288f

9 files changed

+81
-59
lines changed

sakuragram.sln

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sakuragram", "sakuragram\sa
77
EndProject
88
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "sakugramInstaller", "sakugramInstaller\sakugramInstaller.vdproj", "{59F75A96-DA8C-4470-85CB-86A6D8529C1C}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TdLib", "TdLib\TdLib.csproj", "{B1BE765F-2AB0-484C-90BD-21F5BD4D9F55}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TdLib", "TdLib\TdLib.csproj", "{B1BE765F-2AB0-484C-90BD-21F5BD4D9F55}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TdLib.Api", "TdLib.Api\TdLib.Api.csproj", "{E9440D98-F196-4557-B363-AA4841C0F563}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TdLib.Api", "TdLib.Api\TdLib.Api.csproj", "{E9440D98-F196-4557-B363-AA4841C0F563}"
1313
EndProject
1414
Global
1515
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -27,6 +27,12 @@ Global
2727
{7768C2E0-6568-4B3A-995C-FEFDC278FEB7}.Release|x64.ActiveCfg = Release|x64
2828
{7768C2E0-6568-4B3A-995C-FEFDC278FEB7}.Release|x64.Build.0 = Release|x64
2929
{7768C2E0-6568-4B3A-995C-FEFDC278FEB7}.Release|x64.Deploy.0 = Release|x64
30+
{59F75A96-DA8C-4470-85CB-86A6D8529C1C}.Beta|x64.ActiveCfg = Beta
31+
{59F75A96-DA8C-4470-85CB-86A6D8529C1C}.Beta|x64.Build.0 = Beta
32+
{59F75A96-DA8C-4470-85CB-86A6D8529C1C}.Debug|x64.ActiveCfg = Debug
33+
{59F75A96-DA8C-4470-85CB-86A6D8529C1C}.Debug|x64.Build.0 = Debug
34+
{59F75A96-DA8C-4470-85CB-86A6D8529C1C}.Release|x64.ActiveCfg = Release
35+
{59F75A96-DA8C-4470-85CB-86A6D8529C1C}.Release|x64.Build.0 = Release
3036
{B1BE765F-2AB0-484C-90BD-21F5BD4D9F55}.Beta|x64.ActiveCfg = Debug|Any CPU
3137
{B1BE765F-2AB0-484C-90BD-21F5BD4D9F55}.Beta|x64.Build.0 = Debug|Any CPU
3238
{B1BE765F-2AB0-484C-90BD-21F5BD4D9F55}.Debug|x64.ActiveCfg = Debug|Any CPU

sakuragram/App.xaml.cs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public App()
2626

2727
public static bool _authNeeded;
2828
public static bool _passwordNeeded;
29+
30+
public static int _folderId = -1;
2931

3032
private void PrepareTelegramApi()
3133
{

sakuragram/MainWindow.xaml.cs

+37-12
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,32 @@ public sealed partial class MainWindow : Window
1616
private static TdClient _client = App._client;
1717
private static TdApi.User _user;
1818
private static TdApi.ChatFolderInfo[] _folders = App._folders;
19-
private NotificationService _notificationService = new();
2019

21-
private int _totalUnreadCount = 0;
20+
private int _totalUnreadCount;
2221

2322
public MainWindow()
2423
{
2524
InitializeComponent();
25+
2626
#if DEBUG
2727
{
28-
Title = "sakuragram preview";
29-
TitleBar.Subtitle = "preview";
30-
Icon.ShowAsMonochrome = true;
28+
Title = "sakuragram debug";
29+
TitleBar.Subtitle = "debug";
30+
}
31+
#elif BETA
32+
{
33+
Title = "sakuragram beta";
34+
TitleBar.Subtitle = "beta";
3135
}
32-
#else
36+
#elif RELEASE
3337
{
34-
Title = "sakuragram";
35-
Icon.ShowAsMonochrome = false;
38+
Icon.Title = "sakuragram";
3639
}
3740
#endif
3841

3942
ExtendsContentIntoTitleBar = true;
4043
NavigationView.SelectedItem = NavigationView.MenuItems[0];
41-
NavigateToView("ChatsView");
44+
NavigateToView("ChatsView", null);
4245
TrySetDesktopAcrylicBackdrop();
4346

4447
var chatsIds = _client.ExecuteAsync(new TdApi.GetChats{Limit = 100}).Result.ChatIds;
@@ -58,7 +61,8 @@ public MainWindow()
5861
var folder = new NavigationViewItem
5962
{
6063
Content = chatFolderInfo.Title,
61-
Tag = "ChatsView"
64+
Tag = "ChatsView",
65+
Name = $"{chatFolderInfo.Title}_{chatFolderInfo.Id}"
6266
};
6367
NavigationView.MenuItems.Add(folder);
6468
}
@@ -126,11 +130,11 @@ private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvoke
126130

127131
var clickedView = item.Tag.ToString();
128132

129-
if (!NavigateToView(clickedView)) return;
133+
if (!NavigateToView(clickedView, item)) return;
130134
_lastItem = item;
131135
}
132136

133-
private bool NavigateToView(string clickedView)
137+
private bool NavigateToView(string clickedView, NavigationViewItem item)
134138
{
135139
var view = Assembly.GetExecutingAssembly().GetType($"sakuragram.Views.{clickedView}");
136140

@@ -139,6 +143,27 @@ private bool NavigateToView(string clickedView)
139143

140144
ContentFrame.Navigate(view, null, new EntranceNavigationTransitionInfo());
141145

146+
if (clickedView == "ChatsView" && item != null)
147+
{
148+
foreach (var folder in _folders)
149+
{
150+
if (item.Name == $"{folder.Title}_{folder.Id}")
151+
{
152+
App._folderId = folder.Id;
153+
break;
154+
}
155+
else if (item.Name == "NavViewChats")
156+
{
157+
App._folderId = -1;
158+
break;
159+
}
160+
else
161+
{
162+
continue;
163+
}
164+
}
165+
}
166+
142167
NavigationView.PaneDisplayMode = clickedView switch
143168
{
144169
"SettingsView" => NavigationViewPaneDisplayMode.LeftCompact,

sakuragram/Views/Chats/Chat.xaml.cs

+5-35
Original file line numberDiff line numberDiff line change
@@ -338,50 +338,19 @@ private async void GetMessagesAsync(long chatId)
338338
{
339339
await DispatcherQueue.GetForCurrentThread().EnqueueAsync(async () =>
340340
{
341-
int offset = -99;
342-
int limit = 100;
343-
List<long> addedMessages = new();
344-
345341
var firstMessages = await _client.ExecuteAsync(new TdApi.GetChatHistory
346342
{
347343
ChatId = chatId,
348-
Offset = offset,
349-
Limit = limit,
344+
Limit = 100,
345+
Offset = -1,
350346
OnlyLocal = false
351347
});
352348

353-
foreach (var message in firstMessages.Messages_)
349+
foreach (var message in firstMessages.Messages_.Reverse())
354350
{
355-
if (addedMessages.Contains(message.Id)) continue;
356351
GenerateMessageByType(message);
357-
addedMessages.Add(message.Id);
358352
_lastMessageId = message.Id;
359353
}
360-
361-
while (true)
362-
{
363-
var messages = await _client.ExecuteAsync(new TdApi.GetChatHistory
364-
{
365-
ChatId = chatId,
366-
Offset = offset,
367-
Limit = limit,
368-
FromMessageId = _lastMessageId,
369-
OnlyLocal = false
370-
});
371-
372-
if (messages.Messages_.Length == 0)
373-
break;
374-
375-
foreach (var message in messages.Messages_)
376-
{
377-
if (addedMessages.Contains(message.Id)) continue;
378-
GenerateMessageByType(message);
379-
addedMessages.Add(message.Id);
380-
_lastMessageId = message.Id;
381-
}
382-
383-
offset += 1;
384-
}
385354
});
386355
}
387356

@@ -399,7 +368,8 @@ private void GenerateMessageByType(TdApi.Message message)
399368
}
400369
case TdApi.MessageContent.MessageChatChangeTitle or TdApi.MessageContent.MessagePinMessage
401370
or TdApi.MessageContent.MessageGiftedPremium
402-
or TdApi.MessageContent.MessageGameScore or TdApi.MessageContent.MessageChatBoost:
371+
or TdApi.MessageContent.MessageGameScore or TdApi.MessageContent.MessageChatBoost
372+
or TdApi.MessageContent.MessageUnsupported:
403373
{
404374
var changeTitleMessage = new ChatServiceMessage();
405375
MessagesList.Children.Add(changeTitleMessage);

sakuragram/Views/Chats/Messages/ChatServiceMessage.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
mc:Ignorable="d">
8+
mc:Ignorable="d"
9+
Margin="0, 4, 0, 4">
910

1011
<Border Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
1112
CornerRadius="15"

sakuragram/Views/ChatsView.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
ViewChanging="ScrollViewer_OnViewChanging">
6262
<StackPanel>
6363
<StackPanel x:Name="PinnedChatsList" Width="350" Height="Auto"/>
64-
<MenuFlyoutSeparator Margin="0, 4, 0, 4" />
64+
<MenuFlyoutSeparator x:Name="Separator" Margin="0, 4, 0, 4" />
6565
<StackPanel x:Name="ChatsList" Width="350" Height="Auto" Loaded="ChatList_OnLoaded" />
6666
</StackPanel>
6767
</ScrollViewer>

sakuragram/Views/ChatsView.xaml.cs

+20-1
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,20 @@ await DispatcherQueue.GetForCurrentThread().EnqueueAsync(() =>
181181
_pinnedChats.Add(chat.Id);
182182
break;
183183
}
184+
case TdApi.ChatList.ChatListFolder chatListFolder:
185+
{
186+
if (App._folderId != -1)
187+
{
188+
chatListFolder.ChatFolderId = App._folderId;
189+
_pinnedChats.Add(chat.Id);
190+
}
191+
break;
192+
}
184193
}
185194
}
186195

196+
if (_pinnedChats.Count == 0) Separator.Visibility = Visibility.Collapsed;
197+
187198
await DispatcherQueue.GetForCurrentThread().EnqueueAsync(() =>
188199
{
189200
var chatEntry = new ChatEntry();
@@ -281,7 +292,15 @@ private void ButtonSavedMessages_OnClick(object sender, RoutedEventArgs e)
281292

282293
private void ChatList_OnLoaded(object sender, RoutedEventArgs e)
283294
{
284-
GenerateChatEntries(new TdApi.ChatList.ChatListMain());
295+
if (App._folderId != -1)
296+
{
297+
GenerateChatEntries(new TdApi.ChatList.ChatListFolder{ChatFolderId = App._folderId});
298+
}
299+
else
300+
{
301+
GenerateChatEntries(new TdApi.ChatList.ChatListMain());
302+
App._folderId = -1;
303+
}
285304
}
286305

287306
private void ButtonNewMessage_OnClick(object sender, RoutedEventArgs e)

sakuragram/Views/Settings/Advanced.xaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@
4141
<controls:SettingsCard Header="DC1"
4242
HeaderIcon="{ui:FontIcon Glyph=&#xE770;}">
4343
<TextBlock x:Name="TextBlockDC1Ping"
44-
Text="0 ms"/>
44+
Text="Connecting..."/>
4545
</controls:SettingsCard>
4646
<controls:SettingsCard Header="DC2"
4747
HeaderIcon="{ui:FontIcon Glyph=&#xE770;}">
4848
<TextBlock x:Name="TextBlockDC2Ping"
49-
Text="0 ms"/>
49+
Text="Connecting..."/>
5050
</controls:SettingsCard>
5151
<controls:SettingsCard Header="DC3"
5252
HeaderIcon="{ui:FontIcon Glyph=&#xE770;}">
5353
<TextBlock x:Name="TextBlockDC3Ping"
54-
Text="0 ms"/>
54+
Text="Connecting..."/>
5555
</controls:SettingsCard>
5656
<controls:SettingsCard Header="DC4"
5757
HeaderIcon="{ui:FontIcon Glyph=&#xE770;}">
5858
<TextBlock x:Name="TextBlockDC4Ping"
59-
Text="0 ms"/>
59+
Text="Connecting..."/>
6060
</controls:SettingsCard>
6161
<controls:SettingsCard Header="DC5"
6262
HeaderIcon="{ui:FontIcon Glyph=&#xE770;}">
6363
<TextBlock x:Name="TextBlockDC5Ping"
64-
Text="0 ms"/>
64+
Text="Connecting..."/>
6565
</controls:SettingsCard>
6666
</controls:SettingsExpander.Items>
6767
</controls:SettingsExpander>

sakuragram/sakuragram.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<OutputType>WinExe</OutputType>
44
<TargetFramework>net8.0-windows10.0.26100.0</TargetFramework>
5-
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
5+
<TargetPlatformMinVersion>10.0.22000.0</TargetPlatformMinVersion>
66
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
77
<RootNamespace>sakuragram</RootNamespace>
88
<ApplicationManifest>app.manifest</ApplicationManifest>
@@ -13,7 +13,6 @@
1313
<UseWinUI>true</UseWinUI>
1414
<EnableMsixTooling>true</EnableMsixTooling>
1515
<SupportedOSPlatformVersion>10.0.22000.0</SupportedOSPlatformVersion>
16-
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1716
<GenerateDocumentationFile>False</GenerateDocumentationFile>
1817
<WindowsSdkPackageVersion>10.0.26100.38</WindowsSdkPackageVersion>
1918
<ApplicationIcon>StoreLogo.scale-400.ico</ApplicationIcon>

0 commit comments

Comments
 (0)