Skip to content

Commit fb6b034

Browse files
committed
fix: repair rename folder
1 parent 01104cf commit fb6b034

4 files changed

Lines changed: 62 additions & 5 deletions

File tree

TelegramDownloader/Data/FileService.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,8 +1914,37 @@ private async Task<List<ExpandoObject>> AddChildRecords(string id, string parent
19141914
else
19151915
{
19161916
List<BsonFileManagerModel> Data = collectionName == null ? await _db.getAllFilesInDirectoryPath2(dbName, path) : await _db.getAllFilesInDirectoryPath2(dbName, path, collectionName);
1917-
var childItem = fileDetails.Count > 0 && fileDetails[0] != null ? fileDetails[0] : Data
1918-
.Where(x => x.FilePath + "/" == path).First().toFileManagerContent();
1917+
1918+
Syncfusion.Blazor.FileManager.FileManagerDirectoryContent? childItem = null;
1919+
1920+
if (fileDetails.Count > 0 && fileDetails[0] != null)
1921+
{
1922+
childItem = fileDetails[0];
1923+
}
1924+
else
1925+
{
1926+
// Try to find the folder matching the path
1927+
var matchingFolder = Data.FirstOrDefault(x => x.FilePath + "/" == path)
1928+
?? Data.FirstOrDefault(x => x.FilePath == path.TrimEnd('/'));
1929+
1930+
if (matchingFolder != null)
1931+
{
1932+
childItem = matchingFolder.toFileManagerContent();
1933+
}
1934+
else
1935+
{
1936+
// If no matching folder found, return empty response
1937+
response.CWD = new Syncfusion.Blazor.FileManager.FileManagerDirectoryContent
1938+
{
1939+
Name = path.Split('/').LastOrDefault(s => !string.IsNullOrEmpty(s)) ?? "Unknown",
1940+
FilterPath = path,
1941+
IsFile = false
1942+
};
1943+
response.Files = new List<Syncfusion.Blazor.FileManager.FileManagerDirectoryContent>();
1944+
return response;
1945+
}
1946+
}
1947+
19191948
response.CWD = childItem;
19201949

19211950
// First try to find children in the query result (by ParentId)

TelegramDownloader/Data/db/DbService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,13 @@ public async Task<BsonFileManagerModel> updateName(string dbName, string id, str
567567
{
568568
if (collectionName == null)
569569
collectionName = "directory";
570-
var update = new UpdateDefinitionBuilder<BsonFileManagerModel>().Set(n => n.Name, newName);
570+
571+
// Calculate new FilePath (FilterPath + newName)
572+
string newFilePath = filePath + newName;
573+
574+
var update = new UpdateDefinitionBuilder<BsonFileManagerModel>()
575+
.Set(n => n.Name, newName)
576+
.Set(n => n.FilePath, newFilePath);
571577
await getDatabase(dbName).GetCollection<BsonFileManagerModel>(collectionName).UpdateOneAsync(Builders<BsonFileManagerModel>.Filter.Where(x => x.Id == id), update);
572578
if (!isFile)
573579
{

TelegramDownloader/Pages/FileManager.razor

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@
6868
</li>
6969
</ul>
7070

71-
<TelegramDownloader.Pages.Partials.impl.FileManagerImpl id="@id"></TelegramDownloader.Pages.Partials.impl.FileManagerImpl>
71+
<TelegramDownloader.Pages.Partials.impl.FileManagerImpl @ref="fileManagerImpl" id="@id"></TelegramDownloader.Pages.Partials.impl.FileManagerImpl>
7272
<TelegramDownloader.Pages.Modals.ImportDataModal id="@id" @ref="ImportModal"></TelegramDownloader.Pages.Modals.ImportDataModal>
7373
<TelegramDownloader.Pages.Modals.InfoModals.MediaUrlModal @ref="mediaUrlModal" title="WebDav URL" url="@webDavUrl"></TelegramDownloader.Pages.Modals.InfoModals.MediaUrlModal>
7474

7575
@code {
7676
private Modals.ImportDataModal ImportModal { get; set; }
77+
private TelegramDownloader.Pages.Partials.impl.FileManagerImpl fileManagerImpl { get; set; } = default!;
7778
[Parameter]
7879
public string id { get; set; }
7980
private MediaUrlModal mediaUrlModal { get; set; } = default!;
@@ -141,6 +142,12 @@
141142
try
142143
{
143144
await fs.refreshChannelFIles(id);
145+
146+
// Refresh the file manager to show updated data
147+
if (fileManagerImpl != null)
148+
{
149+
await fileManagerImpl.RefreshFileManager();
150+
}
144151
}
145152
finally
146153
{

TelegramDownloader/Shared/MobileFileManager/MobileFileManager.razor.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@
259259
-webkit-overflow-scrolling: touch;
260260
scrollbar-width: none; /* Firefox */
261261
-ms-overflow-style: none; /* IE/Edge */
262+
transition: left 0.3s ease;
263+
}
264+
265+
/* On wide screens where sidebar is on the side, account for sidebar width */
266+
@media (min-width: 2049px) {
267+
.mfm-bottom-bar {
268+
left: max(280px, 20%); /* Match sidebar min-width and width */
269+
}
262270
}
263271

264272
.mfm-bottom-bar::-webkit-scrollbar {
@@ -794,7 +802,14 @@
794802
left: 0;
795803
right: 0;
796804
z-index: 99;
797-
transition: bottom 0.2s ease;
805+
transition: bottom 0.2s ease, left 0.3s ease;
806+
}
807+
808+
/* On wide screens where sidebar is on the side, account for sidebar width */
809+
@media (min-width: 2049px) {
810+
.mfm-pagination {
811+
left: max(280px, 20%); /* Match sidebar min-width and width */
812+
}
798813
}
799814

800815
/* Move pagination up when action bar is visible */

0 commit comments

Comments
 (0)