Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
set_default_options(): void {
this.options = {
uuid: uniqid.time(),
run: false,
error: false
};
}
return (options: {
variables: {
name?: string;
picture?: string;
[key: string]: any;
}
}) => {
const { name, picture } = options.variables
return changeUser({
variables: { name, picture },
optimisticResponse: {
__typename: 'Mutation',
changeUserInfo: {
__typename: 'User',
id: uniqid(),
name: name || me.name,
picture: picture || me.picture,
}
},
update: (store, { data: { changeUserInfo } }) => {
me.picture = picture || me.picture
me.name = name || me.name
store.writeQuery({
query: getMeQuery,
data: { me },
})
},
...options,
})
}
add_notification(state, message, level) {
const noti = {
id: uniqid.time(),
message,
level
};
return { notifications: [...state.notifications, noti] };
}
});
export default ({ chatId }: MessageBoxProps) => {
const [message, setMessage] = useState('')
const me = useMe()
const addMessage = useMutation(
mutation,
{
variables: {
chatId,
content: message,
},
optimisticResponse: {
__typename: 'Mutation',
addMessage: {
id: uniqid(),
__typename: 'Message',
chat: {
id: chatId,
__typename: 'Chat',
},
sender: {
id: me.id,
__typename: 'User',
name: me.name,
},
content: message,
createdAt: new Date(),
type: 0,
recipients: [],
ownership: true,
},
insert(element) {
element.id = uniqid(uniqid.time() + ".");
let response = this.data.push(element);
return response >= 0;
}
tokens.forEach((token, key) => {
if(!Array.isArray(token)){
new_source += token;
return;
}
if (token[0] == 'T_VARIABLE' && options_excludes.indexOf(token[1]) < 0) {
if(!variables[token[1]]) variables[token[1]] = uniqid.time();
}
if (token[0] == 'T_STRING' && typeof tokens[key-2] !== 'undefined' && Array.isArray(tokens[key-2]) && tokens[key-2][1] == "$this") {
if(!variables["$" + token[1]]) variables["$" + token[1]] = uniqid.time();
}
if (token[0] == 'T_STRING' && typeof tokens[key-2] !== 'undefined' && Array.isArray(tokens[key-2]) && tokens[key-2][1] == "function") {
if(!functions[token[1]]) functions[token[1]] = token[1];
}
if (options_minify_remove_comments && (token[0] == 'T_COMMENT' || token[0] == 'T_DOC_COMMENT')) {
return;
}
new_source += token[1];
});
set_default_options(): void {
this.options = {
uuid: uniqid.time(),
type: 0,
min_health: 15,
run: false,
error: false
};
}
keyGenerator: (unit) => uniqid.time(),
valueExtractor: (unit) => unit,
add_notification(state, message, level) {
const noti = {
id: uniqid.time(),
message,
level
};
return { notifications: [...state.notifications, noti] };
}
});