Skip to content

Commit

Permalink
Re-implement the "copy from inbox" feature.
Browse files Browse the repository at this point in the history
This can be used to make Kanmail work with Gmail labels better by
keeping emails in the inbox when moving them to other folders, meaning
they remain in the Gmail inbox and get labelled with the folder name.
  • Loading branch information
Fizzadar committed Jan 15, 2022
1 parent ccc885f commit 382fc28
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions kanmail/client/components/settings/AccountForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ export default class AccountForm extends React.Component {
'type': 'checkbox'
})}
</div>
<div className="half">
<label
className="checkbox"
htmlFor="folderSettings-copy_from_inbox"
>Copy (not move) emails out of the inbox?</label>
{this.renderInput('folderSettings', 'copy_from_inbox', {
'type': 'checkbox'
})}
</div>
</div>
</div>

Expand Down
9 changes: 7 additions & 2 deletions kanmail/client/util/threads.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import _ from 'lodash';

import requestStore from 'stores/request.js';
import settingsStore from 'stores/settings.js';
import { getColumnStore } from 'stores/columns.js';
import { getEmailStore } from 'stores/emailStoreProxy.js';


export function moveOrCopyThread(moveData, targetFolder, setIsMovingFunction=null) {
setIsMovingFunction = setIsMovingFunction || moveData.sourceThreadComponent.setIsMoving;
setIsMovingFunction();

const { messageUids, oldColumn, accountName, thread } = moveData;
const emailStore = getEmailStore();

const accountSettings = settingsStore.getAccountSettings(accountName);
const handler =
accountSettings.folders.copy_from_inbox === true && oldColumn == 'inbox' ?
emailStore.copyEmails : emailStore.moveEmails;

const targetColumnStore = getColumnStore(targetFolder);
targetColumnStore.addIncomingThread(thread);

Expand All @@ -21,7 +26,7 @@ export function moveOrCopyThread(moveData, targetFolder, setIsMovingFunction=nul
}

const moveThread = () => {
emailStore.moveEmails(accountName, messageUids, oldColumn, targetFolder).then(() => {
handler(accountName, messageUids, oldColumn, targetFolder).then(() => {
emailStore.syncFolderEmails(
oldColumn,
{accountName: accountName},
Expand Down
1 change: 1 addition & 0 deletions kanmail/settings/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
# Folder settings
'save_sent_copies': bool,
'delete_on_trash': bool,
'copy_from_inbox': bool,
# Folder aliases
**{
alias: str
Expand Down

0 comments on commit 382fc28

Please sign in to comment.