fix ts errors

This commit is contained in:
ammarahm-ed
2021-12-19 00:34:24 +05:00
parent f5e7e10dbf
commit 97f7fc14c9
2 changed files with 25 additions and 15 deletions

View File

@@ -45,11 +45,11 @@ export interface TrashStore extends State {
export interface UserStore extends State {
user: object,
user: Object| null,
premium: boolean,
lastSynced: string,
syncing: boolean,
setUser: (user: object) => void,
setUser: (user: Object | null) => void,
setPremium: (premium: boolean) => void,
setSyncing: (syncing: boolean) => void,
setLastSynced: (lastSynced: string) => void,
@@ -113,9 +113,11 @@ export interface MenuStore extends State {
export interface EditorStore extends State {
currentEditingNote: string | null,
setCurrentlyEditingNote: (note: string) => void,
sessionId:string,
setSessionId:(sessionId:string) => void
setCurrentlyEditingNote: (note: string | null) => void,
sessionId:string | null,
setSessionId:(sessionId:string | null) => void,
searchReplace:boolean,
setSearchReplace:(searchReplace:boolean) => void
}
@@ -129,9 +131,9 @@ export interface SearchStore extends State {
export interface SelectionStore extends State {
selectedItemsList: object[],
selectedItemsList: Array<Object>,
selectionMode: boolean,
setAll: (all: object[]) => void,
setAll: (all: Array<Object>,) => void,
setSelectionMode: (mode: boolean) => void,
setSelectedItem: (item: Item) => void,
clearSelection: () => void,
@@ -176,7 +178,8 @@ export type Announcement = {
timestamp: number
platforms: string[]
isActive: boolean
userTypes: string[]
userTypes: string[],
appVersion:number
}
export interface MessageStore extends State {

View File

@@ -20,6 +20,7 @@ import {
UserStore,
Announcement
} from './interfaces';
//@ts-ignore
import {groupArray} from 'notes-core/utils/grouping';
import {EditorWebView, post} from '../views/Editor/Functions';
import tiny from '../views/Editor/tiny/tiny';
@@ -163,10 +164,10 @@ interface AttachmentStore {
hash: string;
recieved: number;
type: 'upload' | 'download';
};
};
} | null
}
encryptionProgress: number;
setEncryptionProgress: (encryptionProgress) => void;
setEncryptionProgress: (encryptionProgress:number) => void;
remove: (hash: string) => void;
setProgress: (
sent: number,
@@ -183,6 +184,7 @@ export const useAttachmentStore = create<AttachmentStore>((set, get) => ({
progress: {},
remove: hash => {
let _p = get().progress;
if (!_p) return;
_p[hash] = null;
tiny.call(
EditorWebView,
@@ -200,6 +202,7 @@ export const useAttachmentStore = create<AttachmentStore>((set, get) => ({
},
setProgress: (sent, total, hash, recieved, type) => {
let _p = get().progress;
if (!_p) return;
_p[hash] = {sent, total, hash, recieved, type};
let progress = {total, hash, loaded: type === 'download' ? recieved : sent};
tiny.call(
@@ -212,7 +215,7 @@ export const useAttachmentStore = create<AttachmentStore>((set, get) => ({
);
set({progress: {..._p}});
},
encryptionProgress: null,
encryptionProgress: 0,
setEncryptionProgress: encryptionProgress =>
set({encryptionProgress: encryptionProgress}),
loading: {total: 0, current: 0},
@@ -281,7 +284,9 @@ export const useEditorStore = create<EditorStore>((set, get) => ({
setSessionId:(sessionId) => {
console.log(sessionId,'session id');
set({sessionId});
}
},
searchReplace:false,
setSearchReplace:(searchReplace) => set({searchReplace})
}));
export const useSearchStore = create<SearchStore>((set, get) => ({
@@ -296,6 +301,7 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({
selectedItemsList: [],
selectionMode: false,
setAll: all => {
//@ts-ignore
history.selectedItemsList = all;
set({selectedItemsList: all});
},
@@ -318,6 +324,7 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({
selectedItems.push(item);
}
selectedItems = [...new Set(selectedItems)];
//@ts-ignore
history.selectedItemsList = selectedItems;
history.selectionMode =
@@ -417,7 +424,7 @@ export function clearAllStores() {
export const allowedPlatforms = ['all', 'mobile', Platform.OS];
async function shouldShowAnnouncement(announcement) {
async function shouldShowAnnouncement(announcement:Announcement) {
if (!announcement) return false;
let removed = (await MMKV.getStringAsync(announcement.id)) === 'removed';
if (removed) return false;
@@ -448,7 +455,7 @@ async function shouldShowAnnouncement(announcement) {
case 'unverified':
return !PremiumService.getUser()?.isEmailVerified;
case 'proExpired':
return subStatus === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED || subStatus === SUBSCRIPTION_STATUS.PREMIUM_CANCELED;
return subStatus === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED || subStatus === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED;
case 'any':
default:
return true;