Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
tuta-sudipg committed Aug 15, 2024
1 parent bff7585 commit 759eaa0
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 348 deletions.
10 changes: 5 additions & 5 deletions src/calendar-app/calendar/search/view/CalendarSearchViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
ofClass,
TypeRef,
} from "@tutao/tutanota-utils"
import { areResultsForTheSameQuery, hasMoreResults, isSameSearchRestriction, CalendarSearchModel } from "../model/CalendarSearchModel.js"
import { areResultsForTheSameQuery, CalendarSearchModel, hasMoreResults, isSameSearchRestriction } from "../model/CalendarSearchModel.js"
import { NotFoundError } from "../../../../common/api/common/error/RestError.js"
import { createRestriction, decodeCalendarSearchKey, encodeCalendarSearchKey, getRestriction } from "../model/SearchUtils.js"
import Stream from "mithril/stream"
Expand Down Expand Up @@ -415,15 +415,15 @@ export class CalendarSearchViewModel {

return { items: entries, complete }
},
loadSingle: async (elementId: Id) => {
loadSingle: async (_listId: Id, elementId: Id) => {
const lastResult = this._searchResult
if (!lastResult) {
return null
}
const id = lastResult.results.find((r) => r[1] === elementId)
if (id) {
const targetId = lastResult.results.find((r) => elementIdPart(r) === elementId)
if (targetId) {
return this.entityClient
.load(lastResult.restriction.type, id)
.load(lastResult.restriction.type, targetId)
.then((entity) => new SearchResultListEntry(entity))
.catch(
ofClass(NotFoundError, (_) => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/mailFunctionality/SharedMailUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export async function getMoveTargetFolderSystems(model: MailModel, mails: readon
return folderSystem.getIndentedList().filter((f: IndentedFolder) => {
if (f.folder.isMailSet && firstMail.sets.length > 0) {
const folderId = firstMail.sets[0]
return isSameId(f.folder._id, folderId)
return !isSameId(f.folder._id, folderId)
} else {
return f.folder.mails !== getListId(firstMail)
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/settings/UserListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class UserListView implements UpdatableSettingsViewer {

return { items: allUserGroupInfos, complete: true }
},
loadSingle: async (elementId) => {
loadSingle: async (_istId: Id, elementId: Id) => {
const listId = await this.listId.getAsync()
try {
return await locator.entityClient.load<GroupInfo>(GroupInfoTypeRef, [listId, elementId])
Expand Down
2 changes: 1 addition & 1 deletion src/mail-app/contacts/view/ContactListViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class ContactListViewModel {
const items = await this.getRecipientsForList(listId)
return { items, complete: true }
},
loadSingle: async (elementId: Id) => {
loadSingle: async (_listId: Id, elementId: Id) => {
return this.entityClient.load(ContactListEntryTypeRef, [listId, elementId])
},
sortCompare: (rl1, rl2) => rl1.emailAddress.localeCompare(rl2.emailAddress),
Expand Down
2 changes: 1 addition & 1 deletion src/mail-app/contacts/view/ContactViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ContactViewModel {
const items = await this.entityClient.loadAll(ContactTypeRef, this.contactListId)
return { items, complete: true }
},
loadSingle: async (elementId: Id) => {
loadSingle: async (_listId: Id, elementId: Id) => {
const listId = await this.contactModel.getContactListId()
if (listId == null) return null
return this.entityClient.load(ContactTypeRef, [listId, elementId])
Expand Down
49 changes: 29 additions & 20 deletions src/mail-app/search/view/SearchViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export class SearchViewModel {
this.loadingAllForSearchResult &&
isSameSearchRestriction(this._searchResult?.restriction, this.loadingAllForSearchResult.restriction) &&
!this.listModel.isLoadedCompletely()
) {
) {
await this.listModel.loadMore()
if (
this._searchResult.restriction &&
Expand Down Expand Up @@ -577,9 +577,18 @@ export class SearchViewModel {
const index = this._searchResult?.results.findIndex(
(email) => update.instanceId === elementIdPart(email) && update.instanceListId !== listIdPart(email),
)
const mail = await this.entityClient.load(MailTypeRef, [update.instanceListId, update.instanceId])
if (mail.sets.length > 0) {
} else {
}
// loading mail instance
// read sets
// check if one set is included in the folderIds
if (index >= 0) {
const restrictionLength = this._searchResult.restriction.folderIds.length
if ((restrictionLength > 0 && this._searchResult.restriction.folderIds.includes(update.instanceListId)) || restrictionLength === 0) {
if ((restrictionLength > 0 && this._searchResult.restriction.folderIds.some((folderId, index, arr) -> {
folderId ==
}) || restrictionLength === 0) {
// We need to update the listId of the updated item, since it was moved to another folder.
const newIdTuple: IdTuple = [update.instanceListId, update.instanceId]
this._searchResult.results[index] = newIdTuple
Expand Down Expand Up @@ -622,23 +631,23 @@ export class SearchViewModel {

getSelectedMails(): Mail[] {
return this.listModel
.getSelectedAsArray()
.map((e) => e.entry)
.filter(assertIsEntity2(MailTypeRef))
.getSelectedAsArray()
.map((e) => e.entry)
.filter(assertIsEntity2(MailTypeRef))
}

getSelectedContacts(): Contact[] {
return this.listModel
.getSelectedAsArray()
.map((e) => e.entry)
.filter(assertIsEntity2(ContactTypeRef))
.getSelectedAsArray()
.map((e) => e.entry)
.filter(assertIsEntity2(ContactTypeRef))
}

getSelectedEvents(): CalendarEvent[] {
return this.listModel
.getSelectedAsArray()
.map((e) => e.entry)
.filter(assertIsEntity2(CalendarEventTypeRef))
.getSelectedAsArray()
.map((e) => e.entry)
.filter(assertIsEntity2(CalendarEventTypeRef))
}

private onListStateChange(newState: ListState<SearchResultListEntry>) {
Expand Down Expand Up @@ -705,21 +714,21 @@ export class SearchViewModel {

return { items: entries, complete }
},
loadSingle: async (elementId: Id) => {
loadSingle: async (_listId: Id, elementId: Id) => {
const lastResult = this._searchResult
if (!lastResult) {
return null
}
const id = lastResult.results.find((r) => r[1] === elementId)
const id = lastResult.results.find((resultId) => elementIdPart(resultId) === elementId)
if (id) {
return this.entityClient
.load(lastResult.restriction.type, id)
.then((entity) => new SearchResultListEntry(entity))
.catch(
ofClass(NotFoundError, (_) => {
return null
}),
)
.load(lastResult.restriction.type, id)
.then((entity) => new SearchResultListEntry(entity))
.catch(
ofClass(NotFoundError, (_) => {
return null
}),
)
} else {
return null
}
Expand Down
2 changes: 1 addition & 1 deletion src/mail-app/settings/KnowledgeBaseListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class KnowledgeBaseListView implements UpdatableSettingsViewer {
throw new Error("fetch knowledgeBase entry called for specific start id")
}
},
loadSingle: (elementId) => {
loadSingle: (_listId: Id, elementId: Id) => {
return this.entityClient.load<KnowledgeBaseEntry>(KnowledgeBaseEntryTypeRef, [this.getListId(), elementId])
},
autoSelectBehavior: () => ListAutoSelectBehavior.OLDER,
Expand Down
2 changes: 1 addition & 1 deletion src/mail-app/settings/TemplateListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class TemplateListView implements UpdatableSettingsViewer {
throw new Error("fetch template entry called for specific start id")
}
},
loadSingle: (elementId) => {
loadSingle: (_listId, elementId) => {
return this.entityClient.load<EmailTemplate>(EmailTemplateTypeRef, [this.templateListId(), elementId])
},
autoSelectBehavior: () => ListAutoSelectBehavior.OLDER,
Expand Down
2 changes: 1 addition & 1 deletion src/mail-app/settings/groups/GroupListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class GroupListView implements UpdatableSettingsViewer {
throw new Error("fetch user group infos called for specific start id")
}
},
loadSingle: async (elementId) => {
loadSingle: async (_listId: Id, elementId: Id) => {
const listId = await this.listId.getAsync()
try {
return await locator.entityClient.load<GroupInfo>(GroupInfoTypeRef, [listId, elementId])
Expand Down
2 changes: 1 addition & 1 deletion tuta-sdk/rust/sdk/src/entities/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4294,7 +4294,7 @@ impl Entity for WebsocketCounterData {
pub struct WebsocketCounterValue {
pub _id: CustomId,
pub count: i64,
pub mailListId: GeneratedId,
pub counterId: GeneratedId,
}

impl Entity for WebsocketCounterValue {
Expand Down
7 changes: 7 additions & 0 deletions tuta-sdk/rust/sdk/src/entities/tutanota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ pub struct Mail {
pub mailDetails: Option<IdTuple>,
pub mailDetailsDraft: Option<IdTuple>,
pub sender: MailAddress,
pub sets: Vec<IdTuple>,
pub errors: Option<Errors>,
}

Expand Down Expand Up @@ -1453,6 +1454,8 @@ pub struct MailBox {
pub _ownerKeyVersion: Option<i64>,
pub _permissions: GeneratedId,
pub lastInfoDate: DateTime,
pub archivedMailBags: Vec<MailBag>,
pub currentMailBag: Option<MailBag>,
pub folders: Option<MailFolderRef>,
pub mailDetailsDrafts: Option<MailDetailsDraftsRef>,
pub receivedAttachments: GeneratedId,
Expand Down Expand Up @@ -1564,7 +1567,10 @@ pub struct MailFolder {
pub _ownerKeyVersion: Option<i64>,
pub _permissions: GeneratedId,
pub folderType: i64,
pub isLabel: bool,
pub isMailSet: bool,
pub name: String,
pub entries: GeneratedId,
pub mails: GeneratedId,
pub parentFolder: Option<IdTuple>,
pub errors: Option<Errors>,
Expand Down Expand Up @@ -1668,6 +1674,7 @@ impl Entity for MailboxServerProperties {
pub struct MoveMailData {
pub _format: i64,
pub mails: Vec<IdTuple>,
pub sourceFolder: Option<IdTuple>,
pub targetFolder: IdTuple,
}

Expand Down
Loading

0 comments on commit 759eaa0

Please sign in to comment.