I am creating a user (collection element) to be stored in my chat (collection element). chat contains IsarLinks<user>.
I create a user and save it (which it correctly does). but when I add it this error pops up.
And this is the line where error arises
final _chat = chat()
..users.add(store)
..chatname = _user.name;
further this is where I save the chat
Future<void> MakeChatwithUserAsync(chat _chat)async{
final isar = await db;
var isarCollection = isar.chats;
await isar.writeTxn(() async {
isar.chats.putSync(_chat);
// _chat.users.loadSync();
await _chat.users.save();
});
print("chat saved");
}
Isar version used is isar-3.0.0-dev.7
and flutter doctor shows everything fine
How can this be fixed?
I expected it to work perfectly as I followed the docs, but this did not happen. I tried exploring the function definitions and scrolled on the internet but it was of no use. I want to
complete my project of making WhatsApp like app with flutter
Related
I have created a Taskpane Word Add-Ins, written in React Typescript.
This sideload add-in is going to search a list of words in Word document and replace them by new words. All functionality works well in desktop MS Word and find all the words. When I upload manifest to Word 365 online, Taskpane loads and looks find but when I click on button to search, then nothing find. The result of search function is always empty object {}
Below you can see my code for searching part that will trigger when user click on search button. It is working on desktop version but is not working in Word 365 online
(async () => {
try {
let options = Word.SearchOptions.newObject(context);
options.matchCase = false;
options.matchWholeWord = true;
options.ignorePunct = true;
await Promise.all(
WordList.map(async (data: customWord) => {
// NOTE: In Word 365 online, searchResults is always {}
const searchResults = textSelected
? context.document.getSelection().search(data.word, options)
: context.document.body.search(data.word, options);
searchResults.load("items, text");
allSearchResults.push(searchResults);
})
);
} catch (error) {
console.error(error);
}
})();
Does anyone know why search result is empty in Word Online? Is it related to code Promise.all() when running via browser?
I figured it out where the issue comes from. This issue occurs when having matchWholeWord option in your search function or al least set it to True. By removing this option I was able to see the result in Word online eventhough the result I got wasn't as I expected which is make sense. I didn't try for other search options and don't know for others and these are only three of in my case. Below is my change to get result in Word online.
let options = Word.SearchOptions.newObject(context);
options.matchCase = false;
options.ignorePunct = true;
This is a SearchOption bug in Word online which is reported as an issue in office-js GitHub repo.
https://github.com/OfficeDev/office-js/issues/218
Microsoft common! Fix it! We need it!
I have a bot written in discord.net hosted inside a docker container. There is a simple slash command that queries a database as follows-
[SlashCommand("getmoney", "get current total of currency for given user")]
[DefaultPermission(true)]
public async Task GetMoney(Discord.IUser user)
{
var userHelper = new UserHelper(_dbContext);
var userRecord = userHelper.FindOrAddUser(user.Id.ToString());
await ReplyAsync($"{user.Username} has {userRecord.Funds} Dollars!");
}
This works fine.
I then updated the command to use DeferAsync() and followupAsync()
[SlashCommand("getmoney", "get current total of currency for given user")]
[DefaultPermission(true)]
public async Task GetMoney(Discord.IUser user)
{
await DeferAsync();
var userHelper = new UserHelper(_dbContext);
var userRecord = userHelper.FindOrAddUser(user.Id.ToString());
await FollowupAsync($"{user.Username} has {userRecord.Funds} Dollars!");
}
Which works fine running locally in debug. But when running in a container all slash commands now timeout, even ones in different module classes. There are no errors in the log file when a command is sent.
I tried rebuilding a new image from a commit before the change and hosting it in the same place and that works fine, which means something about this change is causing the issue without triggering any errors in logs.
I am currently trying to produce a forum page where users can post products onto a forum page for other users to see. I have it writing to the db and saving the products - however i now want to read back from the products and produce each product for other users to see. Cant seem to find much guidance on it.
enter image description here
Image is current code of the readProducts function that I have created. Thanks
(async () => {
// Creates a new Query object to help us fetch MyCustomClass objects
const query = new Parse.Query('MyCustomClass');
try {
// Executes the query, which returns an array of MyCustomClass
const results = await query.find();
console.log(`ParseObjects found: ${JSON.stringify(results)}`);
} catch (error) {
console.log(`Error: ${JSON.stringify(error)}`);
}
})();
I am currently developing a small web app using MERN. Here I have developed the backend part and frontend part of it. I want to get the response data category-wise. For example, in my database there are details of assets(Laptops, mobiles etc) with attributes like assetName and assetCategory. There's a functionality to search those assets category-wise. In the frontend, I have used a search bar and user can type the category of asset which is wanted to see. Then backend server gives the response of that. I have developed routes and controllers for the backend part and I will show the controller here.
//find assets by category
exports.assetsByCategory = async(req,res) => {
const CATEGORY = req.body.assetCategory;
const asset = await Asset.find({"assetCategory" :{$regex: new RegExp([CATEGORY?.toLowerCase()], "i") }})
.then((assets)=>{
res.json(assets)
}).catch((err)=>{
console.log(err);
res.status(500).send({message:"No assets like that category!",error:err.message})
})
}
The code for this function which is in the frontend part will be shown here.
function searchCategoryBar(e)
{
e.preventDefault();
const searchedCategory = {assetCategory}
console.log(searchedCategory)
axios.get("http://localhost:8070/assets/category",searchedCategory).then((asset)=>{
setAssets(asset.data);
console.log(asset.data);
}).catch((err)=>{
alert(err.message);
})
}
So that, when I type "lap" on the search bar and then the response must be shown the asset list of laptop category. But in here, response shows all the assets lists without category-wise.
Please give me some help to solve this issue, Thank you!
I'm working on an AngularJS project with the Play Framework 2.2. I'm supposed to develop a mobile version for the web application (not responsive, its part of a given uni project). For the desktop version I'm loading the index page with:
def index(any: String) = Assets.at(path = "/public", file = "app/html/index.html")
which works fine. Detection of the mobile browser works as well by examining the user agent in a Scala Action.
I changed the above code as follows to get the request header:
def index(any: String) = Action { implicit request: RequestHeader =>
if(isMobile(request)) {
// result for mobile version
}
else //result for desktop version
}
However, I don't know how to serve the different asset files as result type.
Any help is appreciated.
If I understand your question correctly, you wish to serve different files from Assets.at() based on your isMobile test, but can't work out how to get the types to line up?
Assets.at() returns an Action[AnyContent] which is at its simplest a function from Request[AnyContent] to Future[Result].
So knowing this, we just need a couple of tweaks to your index function and everything fits:
def index(any: String) = Action.async { request: Request[AnyContent] =>
if(isMobile(request)) {
Assets.at(path = "/public", file = "mobile.html").apply(request)
} else {
Assets.at(path = "/public", file = "desktop.html")(request)
}
}
Explanations:
The inner call returns a Future[Result] so we've become an Action.async
implicit is not needed here so I dropped it
An Action needs to be given a Request not a RequestHeader so I changed that
I'm showing both .apply(request) and just (request) - they are exactly the same