mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
fix: nb cannot be unpinned if 3 nbs are pinned
This commit is contained in:
@@ -155,9 +155,13 @@ export default React.memo(Note, function (prevProps, nextProps) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const pin = async (note) => {
|
const pin = (note) => {
|
||||||
await store.pin(note.id);
|
return store
|
||||||
|
.pin(note.id)
|
||||||
|
.then(async () => {
|
||||||
if (note.pinned) await showUnpinnedToast(note.id, "note");
|
if (note.pinned) await showUnpinnedToast(note.id, "note");
|
||||||
|
})
|
||||||
|
.catch((error) => showToast("error", error.message));
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import * as Icon from "../icons";
|
|||||||
import { hashNavigate, navigate } from "../../navigation";
|
import { hashNavigate, navigate } from "../../navigation";
|
||||||
import { getTotalNotes } from "../../common";
|
import { getTotalNotes } from "../../common";
|
||||||
import IconTag from "../icon-tag";
|
import IconTag from "../icon-tag";
|
||||||
|
import { showToast } from "../../utils/toast";
|
||||||
|
|
||||||
function Notebook(props) {
|
function Notebook(props) {
|
||||||
const { item, index } = props;
|
const { item, index } = props;
|
||||||
@@ -83,9 +84,13 @@ export default React.memo(Notebook, (prev, next) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const pin = async (notebook) => {
|
const pin = (notebook) => {
|
||||||
await store.pin(notebook);
|
return store
|
||||||
|
.pin(notebook.id)
|
||||||
|
.then(() => {
|
||||||
if (notebook.pinned) showUnpinnedToast(notebook.id, "notebook");
|
if (notebook.pinned) showUnpinnedToast(notebook.id, "notebook");
|
||||||
|
})
|
||||||
|
.catch((error) => showToast("error", error.message));
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
|
|||||||
@@ -141,8 +141,10 @@ class AppStore extends BaseStore {
|
|||||||
this.set((state) => (state.isSyncing = true));
|
this.set((state) => (state.isSyncing = true));
|
||||||
return db
|
return db
|
||||||
.sync(full, force)
|
.sync(full, force)
|
||||||
.then(async () => {
|
.then(async (result) => {
|
||||||
showToast("Sync completed.");
|
if (!result) return;
|
||||||
|
|
||||||
|
showToast("success", "Sync completed.");
|
||||||
await this.updateLastSynced();
|
await this.updateLastSynced();
|
||||||
return await this.refresh();
|
return await this.refresh();
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import Vault from "../common/vault";
|
|||||||
import BaseStore from ".";
|
import BaseStore from ".";
|
||||||
import { EV, EVENTS } from "notes-core/common";
|
import { EV, EVENTS } from "notes-core/common";
|
||||||
import Config from "../utils/config";
|
import Config from "../utils/config";
|
||||||
import { showToast } from "../utils/toast";
|
|
||||||
import { qclone } from "qclone";
|
import { qclone } from "qclone";
|
||||||
import { hashNavigate } from "../navigation";
|
import { hashNavigate } from "../navigation";
|
||||||
import { groupArray } from "notes-core/utils/grouping";
|
import { groupArray } from "notes-core/utils/grouping";
|
||||||
@@ -81,11 +80,9 @@ class NoteStore extends BaseStore {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pin = async (id) => {
|
pin = async (id) => {
|
||||||
// TODO (hack) we probably shouldn't do this here.
|
|
||||||
const note = db.notes.note(id);
|
const note = db.notes.note(id);
|
||||||
if (!note.data.pinned && db.notes.pinned.length >= 3) {
|
if (!note.data.pinned && db.notes.pinned.length >= 3) {
|
||||||
await showToast("error", "You cannot pin more than 3 notes.");
|
throw new Error("You cannot pin more than 3 notes.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!this._syncEditor(note.id, "pinned", !note.data.pinned)) {
|
if (!this._syncEditor(note.id, "pinned", !note.data.pinned)) {
|
||||||
await note.pin();
|
await note.pin();
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import createStore from "../common/store";
|
|||||||
import { store as appStore } from "./app-store";
|
import { store as appStore } from "./app-store";
|
||||||
import { store as noteStore } from "./note-store";
|
import { store as noteStore } from "./note-store";
|
||||||
import BaseStore from "./index";
|
import BaseStore from "./index";
|
||||||
import { showToast } from "../utils/toast";
|
|
||||||
import { groupArray } from "notes-core/utils/grouping";
|
import { groupArray } from "notes-core/utils/grouping";
|
||||||
import Config from "../utils/config";
|
import Config from "../utils/config";
|
||||||
|
|
||||||
@@ -36,11 +35,11 @@ class NotebookStore extends BaseStore {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pin = async (notebookId) => {
|
pin = async (notebookId) => {
|
||||||
// TODO (hack) We probably shouldn't do this here.
|
const notebook = db.notebooks.notebook(notebookId);
|
||||||
if (db.notebooks.pinned.length >= 3) {
|
if (!notebook._notebook.pinned && db.notebooks.pinned.length >= 3) {
|
||||||
return await showToast("error", "You cannot pin more than 3 notebooks.");
|
throw new Error("You cannot pin more than 3 notebooks.");
|
||||||
}
|
}
|
||||||
await db.notebooks.notebook(notebookId).pin();
|
await notebook.pin();
|
||||||
this.refresh();
|
this.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
showSessionExpiredDialog,
|
showSessionExpiredDialog,
|
||||||
} from "../common/dialog-controller";
|
} from "../common/dialog-controller";
|
||||||
import { Text } from "rebass";
|
import { Text } from "rebass";
|
||||||
import { showToast } from "../utils/toast";
|
|
||||||
import { showAccountLoggedOutNotice } from "../common/dialog-controller";
|
import { showAccountLoggedOutNotice } from "../common/dialog-controller";
|
||||||
import Config from "../utils/config";
|
import Config from "../utils/config";
|
||||||
import { onPageVisibilityChanged } from "../utils/page-visibility";
|
import { onPageVisibilityChanged } from "../utils/page-visibility";
|
||||||
@@ -64,7 +63,6 @@ class UserStore extends BaseStore {
|
|||||||
this.set((state) => (state.user.subscription = subscription));
|
this.set((state) => (state.user.subscription = subscription));
|
||||||
});
|
});
|
||||||
EV.subscribe(EVENTS.userEmailConfirmed, async () => {
|
EV.subscribe(EVENTS.userEmailConfirmed, async () => {
|
||||||
showToast("success", "Email confirmed successfully!");
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user