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